宝塔Nginx自编译

编译前先将已经安装的Nginx文件进行备份

通过ps命令查看nginx文件的路径。以下所有步骤都以自身nginx路径为准

# ps -elf | grep nginx
# cd /www/server/nginx/sbin/
# cp nginx nginx.bak

然后查看当前NGINX编译的参数

/www/server/nginx/sbin/nginx -V

将./configure arguents:之后的内容复制到记事本备用

内容如下:

–user=www –group=www –prefix=/www/server/nginx –add-module=/www/server/nginx/src/ngx_devel_kit –with-openssl=/www/server/nginx/src/openssl –add-module=/www/server/nginx/src/ngx_cache_purge –add-module=/www/server/nginx/src/nginx-sticky-module –add-module=/www/server/nginx/src/lua_nginx_module –with-http_stub_status_module –with-http_ssl_module –with-http_v2_module –with-http_image_filter_module –with-http_gzip_static_module –with-http_gunzip_module –with-ipv6 –with-http_sub_module –with-http_flv_module –with-http_addition_module –with-http_realip_module –with-http_mp4_module –with-ld-opt=-Wl,-E –with-pcre=pcre-8.42 –with-cc-opt=-Wno-error –add-module=/www/server/nginx/src/ngx-pagespeed

我们将它改成

./configure –user=www –group=www –prefix=/www/server/nginx –add-module=/www/server/nginx/src/ngx_devel_kit –with-openssl=/www/server/nginx/src/openssl –add-module=/www/server/nginx/src/ngx_cache_purge –add-module=/www/server/nginx/src/nginx-sticky-module –add-module=/www/server/nginx/src/lua_nginx_module –with-http_stub_status_module –with-http_ssl_module –with-http_v2_module –with-http_image_filter_module –with-http_gzip_static_module –with-http_gunzip_module –with-ipv6 –with-http_sub_module –with-http_flv_module –with-http_addition_module –with-http_realip_module –with-http_mp4_module –with-ld-opt=-Wl,-E –with-pcre=pcre-8.42 –with-cc-opt=-Wno-error –add-module=/www/server/nginx/src/ngx-pagespeed –with-stream –with-stream_ssl_preread_module

多加了两个参数

然后在src目录执行(cd /www/server/nginx/src)

./configure --user=www --group=www --prefix=/www/server/nginx --add-module=/www/server/nginx/src/ngx_devel_kit --with-openssl=/www/server/nginx/src/openssl --add-module=/www/server/nginx/src/ngx_cache_purge --add-module=/www/server/nginx/src/nginx-sticky-module --add-module=/www/server/nginx/src/lua_nginx_module --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_image_filter_module --with-http_gzip_static_module --with-http_gunzip_module --with-ipv6 --with-http_sub_module --with-http_flv_module --with-http_addition_module --with-http_realip_module --with-http_mp4_module --with-ld-opt=-Wl,-E --with-pcre=pcre-8.42 --with-cc-opt=-Wno-error --add-module=/www/server/nginx/src/ngx-pagespeed --with-stream --with-stream_ssl_preread_module

然后

make && make install

重启nginx

service nginx restart

然后

nginx -V 看看模块是不是加载了


发表评论

电子邮件地址不会被公开。 必填项已用*标注