1、 安装依赖包

yum install -y wget gcc gcc-c++ make pcre pcre-devel zlib zlib-devel openssl openssl-devel

2、 安装nginx

wget http://nginx.org/download/nginx-1.14.2.tar.gz

tar zxf nginx-1.14.2.tar.gz

cd nginx-1.14.2

./configure --prefix=/usr/local/nginx

make

make install

3、 启动

环境变量:

Vi  /etc/profile

加入:export PATH=$PATH:/usr/local/nginx/sbin/

 source /etc/profile 


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

nginx #启动

 

ss -lntup |grep nginx #启动检查

tcp    LISTEN     0      128       *:80                    *:*                   users:(("nginx",pid=38818,fd=6),("nginx",pid=38817,fd=6))

nginx -s stop #关闭nginx