小松博客安装ngx_pagespeed模块主要是为了节约带宽可以加速你的网站,减少页面加载时间,而且无需修改代码只要安装模块就行,下面开始模块安装
github: https://github.com/pagespeed/ngx_pagespeed/tree/v1.11.33.4-beta
模块安装的路径,下面的代码依次执行
mkdir /usr/local/openresty/nginx/modules cd /usr/local/openresty/nginx/modules
rpm --import https://linux.web.cern.ch/linux/scientific6/docs/repository/cern/slc6X/i386/RPM-GPG-KEY-cern wget -O /etc/yum.repos.d/slc6-devtoolset.repo https://linux.web.cern.ch/linux/scientific6/docs/repository/cern/devtoolset/slc6-devtoolset.repo --no-check-certificate sudo yum install devtoolset-2-gcc-c++ devtoolset-2-binutils PS_NGX_EXTRA_FLAGS="--with-cc=/opt/rh/devtoolset-2/root/usr/bin/gcc" NPS_VERSION=1.11.33.4 #安装的版本 wget https://github.com/pagespeed/ngx_pagespeed/archive/v${NPS_VERSION}-beta.zip unzip v${NPS_VERSION}-beta cd ngx_pagespeed-${NPS_VERSION}-beta/ psol_url=https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz [ -e scripts/format_binary_url.sh ] && psol_url=$(scripts/format_binary_url.sh PSOL_BINARY_URL) wget ${psol_url} --no-check-certificate tar -xzvf $(basename ${psol_url})
我之前安装的openresty的版本为1.11.2.2,下载进入进行编译
cd /root/openresty-1.11.2.2 ./configure --user=www --group=www --prefix=/usr/local/openresty --with-luajit --without-http_redis2_module --with-http_stub_status_module --with-http_v2_module --with-http_gzip_static_module --with-http_sub_module --with-openssl=/root/openssl-1.0.2j --add-module=/usr/local/openresty/nginx/modules/ngx_pagespeed-${NPS_VERSION}-beta ${PS_NGX_EXTRA_FLAGS} gmake
替换编译后的nginx
service openresty stop mv /usr/local/openresty/nginx/sbin/nginx /usr/local/openresty/nginx/sbin/nginx.old cp /root/openresty-1.11.2.2/build/nginx-1.11.2/objs/nginx /usr/local/openresty/nginx/sbin/nginx service openresty start
检查模块是否安装成功
/usr/local/openresty/nginx/sbin/nginx -V