在 Debian 系统上,Nginx 通常作为 systemd 服务 来管理。下面是常见的启动、停止和开机自启方法。
sudo systemctl start nginx
sudo systemctl enable nginx
sudo systemctl status nginx
如果看到 active (running) 说明已成功启动。
停止 Nginx
sudo systemctl stop nginx
重启 Nginx
sudo systemctl restart nginx
重新加载配置(不中断服务)
sudo systemctl reload nginx
sudo apt update
sudo apt install nginx
安装完成后默认一般会直接启动。
在浏览器访问:
http://服务器IP
或命令行测试:
curl http://localhost
如果你遇到 启动失败、端口被占用 或 权限问题,可以把 systemctl status nginx 或错误日志(/var/log/nginx/error.log)发出来,我可以帮你具体分析。