/usr/local/nginx/sbin/nginx -V #查看版本 nginx version: YWS/1.0 built by gcc 4.1.2 20080704 (Red Hat 4.1.2-52) TLS SNI support disabled configure arguments: --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --add-module=../ngx_cache_purge-1.3 #注意這裡的編譯項 cd lnmp/nginx/ wget http://www.nginx.org/download/nginx-1.0.15.tar.gz tar xzf nginx-1.0.15.tar.gz cd nginx-1.0.15 #修改版本信息 sed -i 's@#define NGINX_VERSION.*$@#define NGINX_VERSION "1.0"@g' src/core/nginx.h sed -i 's@#define NGINX_VER.*NGINX_VERSION$@#define NGINX_VER "YWS/" NGINX_VERSION@g' src/core/nginx.h ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --add-module=../ngx_cache_purge-1.3 make //注意只make 不要make install mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx$(date +%m%d) #備份nginx原文件 cp objs/nginx /usr/local/nginx/sbin/nginx #復制編譯make後的文件覆蓋nginx原文件 /usr/local/nginx/sbin/nginx -t #檢測nginx文件配置 kill -USR2 `cat /usr/local/nginx/logs/nginx.pid` #把nginx.pid改成nginx.pid.oldbin跟著啟動新的nginx kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin` #退出舊的nignx