Skip to content

Instantly share code, notes, and snippets.

@yungke
Last active December 29, 2015 09:15
Show Gist options
  • Save yungke/632327fe744789251a49 to your computer and use it in GitHub Desktop.
Save yungke/632327fe744789251a49 to your computer and use it in GitHub Desktop.
nginx_ngx_pagespeed
/usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.9.9
built by gcc 4.8.2 20140120 (Red Hat 4.8.2-15) (GCC)
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module
service nginx restart
curl -I 'https://gtour.info/' | grep X-Page-Speed
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
X-Page-Speed: 1.10.33.2-7600
sudo yum install gcc-c++ pcre-devel zlib-devel make unzip
PS_NGX_EXTRA_FLAGS="--with-cc=/usr/lib/gcc-mozilla/bin/gcc --with-ld-opt=-static-libstdc++"
sudo rpm --import https://linux.web.cern.ch/linux/scientific6/docs/repository/cern/slc6X/i386/RPM-GPG-KEY-cern
sudo wget -O /etc/yum.repos.d/slc6-devtoolset.repo https://linux.web.cern.ch/linux/scientific6/docs/repository/cern/devtoolset/slc6-devtoolset.repo
sudo yum install devtoolset-2-gcc-c++ devtoolset-2-binutils
PS_NGX_EXTRA_FLAGS="--with-cc=/opt/rh/devtoolset-2/root/usr/bin/gcc"
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 配置文件語法是否正確
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
# 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
NGINX_VERSION=1.9.9
cd /root/oneinstack/src
tar -xvzf nginx-1.9.9.tar.gz
cd nginx-1.9.9/
./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --add-module=$HOME/ngx_pagespeed-release-1.10.33.2-beta ${PS_NGX_EXTRA_FLAGS}
make
cd
NPS_VERSION=1.10.33.2
wget https://github.com/pagespeed/ngx_pagespeed/archive/release-${NPS_VERSION}-beta.zip -O release-${NPS_VERSION}-beta.zip
unzip release-${NPS_VERSION}-beta.zip
cd ngx_pagespeed-release-${NPS_VERSION}-beta/
wget https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz
tar -xzvf ${NPS_VERSION}.tar.gz # extracts to psol/
mkdir /var/ngx_pagespeed_cache
chown www.www /var/ngx_pagespeed_cache
cp /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf$(date +%m%d) #備份nginx配置文件
vi /usr/local/nginx/conf/nginx.conf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment