重启、启动、关闭
nginx重启之前,一定要先检测配置文件的正确性,以防止nginx无法启动。
确定配置文件正确性之后,再进行其他命令的操作
- 检测配置文件的正确性(先进入nginx的sbin目录,以运行nginx命令)
./nginx -t
./nginx -t -c /path/to/nginx.conf
两种新式都可以执行nginx
配置文件的正确性,正确会返回结果:nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
- 重启(修改配置后重新加载生效)
./nginx -s reload
- 关闭
./nginx -s stop
快速停止nginx
./nginx -s quit
完整有序的停止nginx