nginx安装(每步都测试过)

os:centos7.2

nginx:1.9.9

选择版本

前往官方网站:http://nginx.org/download
选择一个适合的稳定版本,比如nginx-1.9.9,获得下载地址:
http://nginx.org/download/nginx-1.9.9.tar.gz

安装相关支持库

yum -y install gcc gcc-c++ autoconf openssl openssl-devel pcre-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/

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 ./incubator-pagespeed-ngx-1.8.31.4-beta
cd incubator-pagespeed-ngx-1.8.31.4-beta
tar -xzvf 1.8.31.4.tar.gz
cd ..
cp -r incubator-pagespeed-ngx-1.8.31.4-beta /media/ngx_pagespeed-1.8.31.4-beta

安装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 --with-stream

make && make install

启动nginx并验证

/usr/local/nginx/sbin/nginx

打开浏览器,输入[http://serverip/,显示welcom界面即安装成功。

你可能感兴趣的:(nginx安装(每步都测试过))