OS版本:CentOS 7.2
nginx版本:1.8.1
所需包:openssl-1.0.2m.tar.gz zlib-1.2.8.tar.gz pcre-8.36.tar.gz nginx-1.8.1.tar.gz
1,安装openssl-1.0.2m
tar -xzvf openssl-1.0.2m.tar.gz
cd openssl-1.0.2m
./config --prefix=/usr/local/openssl-1.0.2m
make && make install
2,安装zlib-1.2.8.tar.gz
tar -xzvf zlib-1.2.8.tar.gz
cd zlib-1.2.8
./configure --prefix=/usr/local/zlib-1.2.8
make && make install
3,安装pcre-8.36.tar.gz
tar -xzvf pcre-8.36.tar.gz
cd pcre-8.36
./configure --prefix=/usr/local/pcre-8.36
make && make install
4,安装nginx-1.8.1
tar -xzvf nginx-1.8.1.tar.gz
cd nginx-1.8.1
#with-pcre 制定依赖包位置,prefix配置安装路径
./configure --with-pcre=../pcre-8.36 --with-zlib=../zlib-1.2.8 --with-openssl=../openssl-1.0.2m --prefix=/usr/local/nginx-1.8.1
5,检测是否安装成功
cd /usr/local/nginx-1.8.1/sbin
./nginx -t
[root@localhost sbin]# ./nginx -t
nginx: the configuration file /usr/local/nginx-1.8.1/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx-1.8.1/conf/nginx.conf test is successful
出现这种提示表示安装成功
6,启动nginx
cd /usr/local/nginx-1.8.1/sbin
./nginx
查看端口 netstat -ntlp
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 28409/nginx: master
关闭nginx
./nginx -s stop
修改配置后重新加载配置
./nginx -s reload