以下是 Nginx 在 Linux 系统下的常用服务管理命令:
# 大多数 Linux 发行版
sudo systemctl start nginx
# 旧版系统使用 service 命令
sudo service nginx start
# 优雅停止(等待处理完当前请求)
sudo systemctl stop nginx
# 快速停止
sudo nginx -s stop
# 完全重启服务
sudo systemctl restart nginx
# 仅重新加载配置(不中断服务)
sudo systemctl reload nginx
# 或者使用 nginx 命令
sudo nginx -s reload
sudo systemctl status nginx
sudo systemctl enable nginx
sudo systemctl disable nginx
sudo nginx -t
注意:
1. 需要 root 权限或 sudo 执行这些命令
2. 不同 Linux 发行版可能略有差异
3. 修改配置后,通常只需要 reload
而不需要完全 restart