技术交流QQ群:①185473046   ②190706903   ③203744115   网站地图
登录

下次自动登录
现在的位置: 首页LNMP>正文
CentOS下安装gperftools优化nginx
2012年11月08日 LNMP 评论数 6 ⁄ 被围观 27,522次+

说明:

操作系统:CentOS Nginx安装路径:/usr/local/nginx Nginx配置文件路径:/usr/local/nginx/conf/nginx.conf nginx安装包目录:/usr/local/src/nginx-1.2.4 Nginx 软件版本:nginx-1.2.4

一、下载软件包

http://mirror.yongbok.net/nongnu/libunwind/libunwind-1.1.tar.gz  #下载libunwind
https://gperftools.googlecode.com/files/gperftools-2.0.tar.gz   #下载gperftools
上传软件包到服务器的/usr/local/src目录下面

二、安装gperftools

1、安装libunwind(安装gperftools前需要先安装libunwind)
cd /usr/local/src  #进入安装目录
tar zxvf libunwind-1.1.tar.gz  #解压
cd libunwind-1.1
./configure #配置
make #编译
make install #安装
系统运维 www.osyunwei.com 温馨提醒:qihang01原创内容 版权所有,转载请注明出处及原文链接
2、安装gperftools
cd /usr/local/src
tar zxvf gperftools-2.0.tar.gz
cd gperftools-2.0 #进入目录
./configure --enable-frame-pointers #配置
make
make install
3、配置gperftools
vi /etc/ld.so.conf.d/usr_local_lib.conf  #编辑,添加以下内容
/usr/local/lib
:wq! #保存退出

/sbin/ldconfig  #执行此命令

cd /usr/local/src/nginx-1.2.4 #进入nginx安装包目录

./configure --prefix=/usr/local/nginx --with-google_perftools_module --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-openssl=/usr/ --with-pcre=/usr/local/src/pcre-8.31
#重新配置nginx,添加--with-google_perftools_module参数

make #编译
make install  #安装

mkdir /tmp/tcmalloc  #新建目录
chmod  777 /tmp/tcmalloc -R  #设置目录权限

4、配置nginx

vi /usr/local/nginx/conf/nginx.conf #编辑,在#pid logs/nginx.pid;这行的下面添加
google_perftools_profiles /tmp/tcmalloc;
:wq! #保存退出
系统运维 www.osyunwei.com 温馨提醒:qihang01原创内容 版权所有,转载请注明出处及原文链接
service nginx restart  #重启nginx

三、测试

lsof -n | grep tcmalloc #测试tcmalloc
lsof -n | grep nginx  #测试nginx

至此,CentOS下安装gperftools优化nginx完成。
     

  系统运维技术交流QQ群:①185473046 系统运维技术交流□Ⅰ ②190706903 系统运维技术交流™Ⅱ ③203744115 系统运维技术交流™Ⅲ

目前有 6 条留言 其中:访客:6 条, 博主:0 条

  1. 13558871@qq.com : 2012年11月09日11:53:14  1楼

    这样性能有多少改善啊。。。

  2. 442405@qq.com : 2012年11月09日12:17:38  2楼

    good

  3. Stanley : 2012年11月09日14:16:11  3楼

    yum安装的nginx,悲哀了。 :sad:

  4. ぃ无奈的秋 : 2012年11月12日12:38:41  4楼

    学习了!

  5. 若和 : 2012年11月21日11:07:07  5楼

    使用gperftools也能优化MYSQL,正在试~ :lol:

  6. 529904565@qq.com : 2013年01月24日17:16:29  6楼

    先看看 再说了 :razz:

给我留言

您必须 [ 登录 ] 才能发表留言!



Copyright© 2011-2024 系统运维 All rights reserved
版权声明:本站所有文章均为作者原创内容,如需转载,请注明出处及原文链接
陕ICP备11001040号-3