第一步:关闭全部nginx服务

pkill -9 nginx

nginx 启动指定配置文件 nginx根据配置文件启动_nginx 启动指定配置文件

 

# 运行命令参看nginx服务是否关闭
netstat -tnulp | grep nginx # 参看端口是否关闭
systemctl status nginx  # 查看服务是否关闭

关闭后状态:

nginx 启动指定配置文件 nginx根据配置文件启动_配置文件_02

 

 

 

nginx 启动指定配置文件 nginx根据配置文件启动_nginx 启动指定配置文件_03

第二步:加载指定配置文件

 

nginx -c -t /software/nginx/nginx.conf# 配置文件路径
# -c </path/to/config> 为 Nginx 指定一个配置文件,来代替缺省的。

# -t 不运行,而仅仅测试配置文件。nginx 将检查配置文件的语法的正确性,并尝试打开配置文件中所引用到的文件

 

 

 

nginx 启动指定配置文件 nginx根据配置文件启动_端口号_04

 

 

第三步:开启nginx服务

systemctl start nginx

 

# 参看运行nginx状态
systemctl status nginx
netstat -natp

nginx 启动指定配置文件 nginx根据配置文件启动_nginx 启动指定配置文件_05

 

 

nginx 启动指定配置文件 nginx根据配置文件启动_配置文件_06

 注:如果没有设置端口号防火墙,需要设置端口号防火墙;