CentOS 6.x 和 CentOS 7.x 中 Nginx 的操作命令(启动/重启/退出/...)

流过昼夜 提交于 2020-01-07 01:43:01

CentOS 6.x 和 CentOS 7.x 中 Nginx 的操作命令(启动/重启/退出/...)

--------- CentOS 6.x 中 Nginx 的操作命令 ---------

# nginx                               // 不指定配置文件启动 Nginx,默认读取 /etc/nginx/nginx.conf 配置文件。
# nginx -c <配置文件>       // 指定配置文件启动 Nginx 。
# nginx -t                           // 测试配置文件是否有语法错误,通过这种方式,也就知道了默认配置文件是哪个文件。
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

# nginx -s reopen       // 重启 Nginx
# nginx -s reload        // 重新加载 Nginx 配置文件,然后以优雅的方式重启 Nginx 。
# nginx -s stop           // 强制停止 Nginx 服务
# nginx -s quit            // 优雅地停止 Nginx 服务(即处理完所有请求后再停止服务)


--------- CentOS 7.x 中 Nginx 的操作命令 --------- 

# systemctl start nginx.service            // 启动 Nginx 服务
# systemctl stop nginx.service            // 停止 Nginx 服务
# systemctl restart nginx.service        // 重启 Nginx 服务
# systemctl reload nginx.service        // 重新加载 Nginx 配置文件,然后以优雅的方式重启 Nginx 。
# systemctl status nginx.service        // 查看状态
# systemctl enable nginx.service       // 设置开机自启动
# systemctl disable nginx.service      // 停止开机自启动

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!