问题:
使用命令:/usr/local/nginx/sbin/nginx -s reload
重启nginx出现报错,报错如下
nginx: [error] open() “/usr/local/nginx/logs/nginx.pid” failed (2: No such file or directory)
报错说的是:打开/usr/local/nginx/logs/nginx.pid失败,没有这样的文件或目录,应该是logs目录下没有nginx.pid这个文件。
解决方法:
重新指定启动之时加载的配置文件,然后再重启。
例如nginx的配置文件目录是:/usr/local/nginx/conf/nginx.conf
先执行平滑启动nginx命令:
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
然后再执行重启nginx命令:
/usr/local/nginx/sbin/nginx -s reload
进行平滑重启nginx就不会出现报错提示了
实例如下:
[root@localhost ~]# /usr/local/nginx/sbin/nginx -s stop
[root@localhost ~]# /usr/local/nginx/sbin/nginx -s reload
nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or directory)
[root@localhost ~]# netstat -atunp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1325/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1793/master
tcp 0 0 192.168.41.191:22 192.168.41.119:55080 ESTABLISHED 9925/sshd: root@not
tcp 0 0 192.168.41.191:22 192.168.41.119:62664 ESTABLISHED 9983/sshd: root@not
tcp 0 0 192.168.41.191:22 192.168.41.119:55077 ESTABLISHED 9920/sshd: root@pts
tcp 0 48 192.168.41.191:22 192.168.41.119:62657 ESTABLISHED 9977/sshd: root@pts
tcp6 0 0 :::22 :::* LISTEN 1325/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1793/master
[root@localhost ~]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
[root@localhost ~]# /usr/local/nginx/sbin/nginx -s reload
[root@localhost ~]# netstat -atunp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 17291/nginx: master
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1325/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1793/master
tcp 0 0 192.168.41.191:22 192.168.41.119:55080 ESTABLISHED 9925/sshd: root@not
tcp 0 0 192.168.41.191:22 192.168.41.119:62664 ESTABLISHED 9983/sshd: root@not
tcp 0 0 192.168.41.191:22 192.168.41.119:55077 ESTABLISHED 9920/sshd: root@pts
tcp 0 48 192.168.41.191:22 192.168.41.119:62657 ESTABLISHED 9977/sshd: root@pts
tcp6 0 0 :::22 :::* LISTEN 1325/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1793/master