您的位置:首页 > 运维架构 > Nginx

Nginx重新编译添加模块

2017-01-10 09:39 746 查看
下载Nginx源码(尽量与原来版本一样,此处我使用的是 nginx-1.5.1.tar.gz)

tar -zxf nginx-1.5.1.tar.gz

cd nginx-1.5.1

之前使用的编译参数为: ./configure --prefix=/usr/local/webserver/nginx
使用 nginx -V 可以看到没有添加任何模块:
[root@iZ25ljcq1ahZ vhost]# /usr/local/webserver/nginx/sbin/nginx -V
nginx version: nginx/1.5.1
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC)
configure arguments: --prefix=/usr/local/webserver/nginx


下面是重新编译时的代码和使用的模块:

./configure --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module

然后make, make执行完只有千万不要执行make install,否则就会覆盖安装了,那就呵呵了。。。

在make执行完之后,在源码目录中的objs目录中有一个可执行的nginx文件,这个就是重新编译后的程序了。

备份旧的nginx文件:
cd /usr/local/webserver/nginx/sbin
mv nginx nginx.bak

将新的nginx文件放入到sbin中:
cp nginx-1.5.1/objs/nginx /usr/local/webserver/nginx/sbin

测试一下新的程序是否正确:
[root@iZ25ljcq1ahZ objs]# /usr/local/webserver/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/webserver/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/webserver/nginx/conf/nginx.conf test is successful
经检查没有问题,平滑启动或者重启nginx服务器后,查看nginx新版本及其编译参数:
[root@iZ25ljcq1ahZ ~]# /usr/local/webserver/nginx/sbin/nginx -V
nginx version: nginx/1.5.1
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-17) (GCC)
TLS SNI support enabled
configure arguments: --prefix=/usr/local/webserver/nginx --with-http_stub_status_module --with-http_ssl_module
发现新添加的模块已经安装完成了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  模块 nginx 重新编译