rmdir.cn

systemctl start nginx

启动 systemd 管理的 Nginx 服务

语法

sudo systemctl start nginx

说明

适用于已安装 nginx.service 的 systemd Linux 系统。start 只启动服务,不自动设置开机自启。执行前确认配置正确、端口未被其他程序占用;容器或非 systemd 环境不适用。

参数

  • nginx必填

    服务单元名称,实例化单元需使用真实名称

示例

检查后启动

默认发行版安装的常用启动流程。

sudo nginx -t && sudo systemctl start nginx

注意事项:会让服务开始监听端口,确认防火墙和站点公开范围。

确认启动结果

启动后检查进程和最近日志摘要。

systemctl status nginx --no-pager --full

注意事项:检查所用 nginx -t 与单元启动参数是否一致,定制安装可先用 systemctl cat nginx 查看。

参考资料