Nginx配置文件修改与重启

当以下任何命令出现权限问题时,首先查看是否拥有权限,再次查看是否加上sudo

1.查看nginx路径

nginx的配置放在nginx.conf文件中,一般我们可以使用以下命令查看服务器中存在的nginx.conf文件。

[root@ITRI-IoTPlatform-Test ~]# locate nginx.conf
/usr/local/etc/nginx/nginx.conf
/usr/local/etc/nginx/nginx.conf.default

如果服务器中存在多个nginx.conf文件,我们并不知道实际上调用的是哪个配置文件,因此我们必须找到实际调用的配置文件才能进行修改

[root@ITRI-IoTPlatform-Test ~]# ps aux|grep nginx
root              352   0.0  0.0  2468624    924   ??  S    10:43上午   0:00.08 nginx: worker process  
root              232   0.0  0.0  2459408    532   ??  S    10:43上午   0:00.02 nginx: master process /usr/local/opt/nginx/bin/nginx -g daemon off;  
root             2345   0.0  0.0  2432772    640 s000  S+    1:01下午   0:00.00 grep nginx

nginx的路径为:/usr/local/opt/nginx/bin/nginx

2.Nginx强制关闭

root@hecs02:/etc/nginx# pkill -9 nginx

3.Nginx重启

(1)、一般重启

i、查看Nginx master进程号

root@hecs02:/etc/nginx# ps -ef|grep nginx

(2)、修改配置文件后重启

i、查看修改的配置文件是否有误,前提Nginx必须开启状态

root@hecs02:/usr/sbin# ./nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

ii、确认修改没有问题后,重启Nginx

# 指定配置文件
root@hecs02:/usr/sbin# ./nginx -c /etc/nginx/nginx.conf

# 重启
root@hecs02:/usr/sbin# ./nginx -s reload

定位后Nginx可执行程序,然后输入 -s reload,完成重启,该重启不需要关闭Nginx服务器.

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值