1,说明:
/root/nginx-1.2.9: 该目录是 nginx 安装文件所在的目录。
nginx的目录是:/usr/local/nginx。
查看 nginx 初始编译选项:
[root@kvm61-05 ~]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.2.9
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-54)
TLS SNI support disabled
configure arguments: --user=nginx --group=nginx --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-pcre
2,下载proxy_cache所需的压缩包ngx_cache_purge-2.1.tar.gz。
[root@kvm61-05]# wget
解压 purge 模块:
[root@kvm61-05 ~]# tar xvf ngx_cache_purge-2.1.tar.gz
3,之后,重新./configure,make编译,不用make install。千万要注意:到这里就可以了,千万不要make install,不然文件就会被覆盖了
[root@kvm61-05 ~]# cd nginx-1.2.9
./configure --user=nginx --group=nginx --add-module=../ngx_cache_purge-2.1 --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-pcre
编译:
[root@kvm61-05 nginx-1.2.9]# make
4,替换:
[root@kvm61-05 nginx-1.2.9]# cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
[root@kvm61-05 nginx-1.2.9]# ps -ef | grep nginx
root 29950 25137 0 09:44 pts/0 00:00:00 grep nginx
如果有nginx进程,需要把nginx进程杀掉,不然复制会报错
[root@kvm61-05 nginx-1.2.9]# killall nginx
[root@kvm61-05 nginx-1.2.9]# killall nginx
nginx: no process killed
[root@kvm61-05 nginx-1.2.9]# pwd
/root/nginx-1.2.9
[root@kvm61-05 nginx-1.2.9]# cp ./objs/nginx /usr/local/nginx/sbin/
cp: overwrite `/usr/local/nginx/sbin/nginx'? yes
现在就可以开启 nginx 了:
[root@kvm61-05 nginx-1.2.9]# /usr/local/nginx/sbin/nginx
[root@kvm61-05 nginx-1.2.9]#
[root@kvm61-05 nginx-1.2.9]#
[root@kvm61-05 nginx-1.2.9]# ps -ef | grep nginx
root 30113 1 0 09:50 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx 30114 30113 0 09:50 ? 00:00:00 nginx: worker process
root 30116 25137 0 09:50 pts/0 00:00:00 grep nginx
[root@kvm61-05 nginx-1.2.9]# netstat -anpt | grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 30113/nginx
5,重新查看编译选项,可以看到 cache_purge 这个模块成功编译进去
[root@kvm61-05 nginx-1.2.9]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.2.9
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-54)
TLS SNI support disabled
configure arguments: --user=nginx --group=nginx --add-module=../ngx_cache_purge-2.1 --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-pcre
阅读(1557) | 评论(0) | 转发(0) |