os:centos7.2
nginx:1.9.9
选择版本
安装相关支持库
yum -y install gcc gcc-c++ autoconf openssl openssl-devel
安装pcre,为了重写rewrite, zlib:为了gzip压缩,ngx_pagespeed插件:前端网页访问提速优化插件
pcre安装
wget http://sourceforge.net/projects/pcre/files/pcre/8.36/pcre-8.36.tar.gz
tar -zxvf pcre-8.36.tar.gz
cd pcre-8.36
./configure
make && make install
ln -s /usr/local/lib/libpcre.so.1 /lib64/
zlib安装
wget http://zlib.net/zlib-1.2.8.tar.gz
tar -zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure
make && make install
pagespeed安装
wget https://github.com/pagespeed/ngx_pagespeed/archive/v1.8.31.4-beta.tar.gz
wget https://dl.google.com/dl/page-speed/psol/1.8.31.4.tar.gz
tar -zxvf v1.8.31.4-beta.tar.gz
cp 1.8.31.4.tar.gz ./ngx_pagespeed-1.8.31.4-beta
cd ngx_pagespeed-1.8.31.4-beta
tar -xzvf 1.8.31.4.tar.gz
安装nginx
groupadd www
useradd -g www www
wget http://nginx.org/download/nginx-1.9.9.tar.gz
tar -zxvf nginx-1.9.9.tar.gz
cd nginx-1.9.9
./configure --user=www --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --add-module=/media/ngx_pagespeed-1.8.31.4-beta
make && make install
启动nginx并验证
/usr/local/nginx/sbin/nginx