Nginx 的启动方式取决于您的操作系统和安装方式。以下是不同环境下启动 Nginx 的方法:
sudo systemctl start nginx
sudo service nginx start
sudo nginx
cd C:\nginx
start nginx
或者直接双击 nginx.exe
brew services start nginx
sudo systemctl status nginx # 对于 systemd 系统
或者访问 http://localhost
或 http://127.0.0.1
查看默认欢迎页面
停止 Nginx:
sudo systemctl stop nginx
重启 Nginx:
sudo systemctl restart nginx
重新加载配置(不中断服务):
sudo systemctl reload nginx
检查配置文件语法:
sudo nginx -t
如果您在启动过程中遇到问题,可以检查错误日志(通常位于 /var/log/nginx/error.log
)来排查原因。