nginx文件非常小但是性能非常的高效,原因之一是nginx自带的功能相对较少,把很多功能以第三方模块的方式实现,让用户按需添加。在安装模块方面,nginx显得没有apache安装模块方便,当然也没有php安装扩展方便.在原生的nginx,他不可以动态加载模块,所以当你安装第三方模块的时候需要覆盖nginx文件.接下来看看如何安装nginx第三模块吧.
nginx第三方模块安装方法:
1
./configure --prefix=/你的安装目录--add-module=/第三方模块目录
在已安装nginx情况下安装nginx模块找到安装nginx的源码根目录,如果没有的话下载新的源码/usr/local/nginx/sbin/nginx -V
以下是重新编译的代码和模块
./configure \
--prefix=/usr/local/nginx \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-file-aio \
--with-http_realip_module \
make #千万别make install,否则就覆盖安装了
make完之后在objs目录下就多了个nginx,这个就是新版本的程序了备份旧的nginx程序
cp /usr/local/nginx/sbin/nginx/usr/local/nginx/sbin/nginx.bak
1
cp /usr/local/nginx/sbin/nginx/usr/local/nginx/sbin/nginx.bak
把新的nginx程序覆盖旧的cp objs/nginx /usr/local/nginx/sbin/nginx
测试新的nginx程序是否正确
/usr/local/nginx/sbin/nginx -t
nginx: theconfiguration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx:configuration file /usr/local/nginx/conf/nginx.conf test issuccessful
平滑重启nginx
/usr/local/nginx/sbin/nginx -s reload
查看ngixn版本极其编译参数/usr/local/nginx/sbin/nginx -V这是我重新编译的代码:
./configure --prefix=/usr/local/nginx --with-google_perftools_module --user=www --group=www --with-http_stub_status_module --with-http_gzip_static_module --with-openssl=/usr/ --with-pcre=/mydata/soft/pcre-8.31