nginx reload错误

今天修改过nginx.conf文件后
nginx -s reload重启nginx服务错误

# nginx -s reload
nginx: [error] open() "/var/run/nginx.pid" failed (2: No such file or directory)

查看配置文件,文件正确

# nginx  -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

原因:nginx reload 只是重新加载配置文件,nginx关闭后找不到
解决方法如下:

# nginx -c /etc/nginx/nginx.conf
# nginx  -s reload

或者

# nginx  -s reload -c /etc/nginx/nginx.conf