1、安装依赖包
yum -y install wget gcc gcc-c++ -y
2、安装libunwind库
可以从下载wget http://ftp.twaren.net/Unix/NonGNU//libunwind/libunwind-1.1.tar.gztar zxvf libunwind-1.1.tar.gzcd libunwind-1.1CFLAGS=-fPIC ./configuremake CFLAGS=-fPICmake CFLAGS=-fPIC install
3、安装google-perftools
下载tar zxvf gperftools-2.1.tar.gzcd gperftools-2.1./configuremakemake installecho "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf/sbin/ldconfig
为google-perftools创建一个线程目录
mkdir /tmp/tcmallocchmod 777 /tmp/tcmalloc
4、安装OpenResty
请参看我另一篇博客
编译时增加--with-google_perftools_module
./configure --prefix=/usr/local/openresty --with-google_perftools_module --with-http_stub_status_module --with-http_gzip_static_module --with-luajit
查看nginx安装的模块
/usr/local/openresty/nginx/sbin/nginx -V
修改nginx主配置文件,在pid这行的下面添加如下代码
验证google-perftools是否已经正常加载,可通过如下命令查看
lsof -n | grep tcmalloc