一安装依赖(安装过的跳过)

yum -y install gcc gcc-c++ automake pcre pcre-devel zlib zlib-devel openssl-devel
或者去nginx官网下载
解压–编译–安装
解压
tar -zxvf nginx-1.16.1.tar.gz
进入解压目录
gg
cd nginx-1.16.1/
编译
# 需要使用https执行指令
./configure  --with-http_ssl_module
# 不需要使用https执行
./configure 


  1. 安装
make && make install
四、开放访问端口80(可自定义)
# 不同centos 系统指令有差别
/sbin/iptables -I INPUT  -p tcp --dport 80 -j ACCEPT
1
2
五、nginx服务的启动操作
启动
cd /usr/local/nginx/sbin
# 默认配置文件启动
./nginx
# 指定配置文件启动
./nginx -c  /usr/local/nginx/conf/nginx.conf
1
2
3
4
5
6
停止
cd /usr/local/nginx/sbin
# 停止指令
./nginx -s stop
1
2
3
六、开机启动nginx