nginx编译优化

post by rocdk890 / 2012-4-30 8:12 Monday linux技术

  今天去nginx.org官网看到已经发布nginx-1.2.0稳定版,决定把自己vps上的nginx-1.0.15升级到1.2.0.好了来看教程吧.
   系统:centos 5.5
   需要的软件:nginx-1.2.0.tar.gz ngx_cache_purge-1.3.tar.gz Nginx-accesskey-2.0.3.tar.gz agentzh-memc-nginx-module-v0.13rc3-1-gee3fe43.tar.gz agentzh-srcache-nginx-module-v0.13rc6-6-g01829d9.tar.gz
1.解压并修改nginx
tar zxf nginx-1.2.0.tar.gz && cd nginx-1.2.0
vi src/http/ngx_http_header_filter_module.c
vi src/core/nginx.h
上面这个不懂的,可以去看我这篇文章编译安装nginx并修改版本头信息用tcmalloc优化nginx
vi auto/cc/gcc
# debug
CFLAGS="$CFLAGS -g"
然后注释掉CFLAGS行,如下
# debug
#CFLAGS="$CFLAGS -g"

2.编译安装nginx
./configure --user=nginx --group=nginx --add-module=../agentzh-memc-nginx-module-ee3fe43 \
--add-module=../agentzh-srcache-nginx-module-01829d9 \
--prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf  \
--error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi \
--pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx --with-http_secure_link_module \
--with-http_random_index_module --with-http_ssl_module --with-http_realip_module --with-http_addition_module \
--with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_gzip_static_module \
--with-http_stub_status_module --with-http_perl_module --with-http_geoip_module --with-mail \
--with-mail_ssl_module --with-cc-opt=-O3 --with-cpu-opt=pentium
这里要说句,因为nginx从1.1版本开始就已经自动集成ngx_http_upstream_keepalive了,所以不需要再去编译安装上了.
make && make install

重启nginx,再试验nginx -v,可以看到nginx已经升级到1.2.0版本了.

夜空- 本站版权
1、本站所有主题由该文章作者发表,该文章作者与夜空享有文章相关版权
2、其他单位或个人使用、转载或引用本文时必须同时征得该文章作者和夜空的同意
3、本帖部分内容转载自其它媒体,但并不代表本站赞同其观点和对其真实性负责
4、如本帖侵犯到任何版权问题,请立即告知本站,本站将及时予与删除并致以最深的歉意
5、原文链接:blog.slogra.com/post-184.html

标签: nginx 升级 编译 减小 大小 体积

评论: