Nginx服务启动和停止命令:启动命令:Ubuntu/Debian:sudo service nginx startRed Hat/CentOS:sudo systemctl start nginx停止命令:Ubuntu/Debian:sudo service nginx stopRed Hat/CentOS:sudo systemctl stop nginx

Nginx 启动和停止命令
启动命令
-
Ubuntu/Debian:
sudo service nginx start
-
Red Hat/CentOS:
sudo systemctl start nginx
停止命令
-
Ubuntu/Debian:
sudo service nginx stop
-
Red Hat/CentOS:
sudo systemctl stop nginx
详细说明
启动命令
-
service:用于管理系统服务。 -
nginx:指定要启动的服务名称。 -
start:指示服务启动。
停止命令
-
service:用于管理系统服务。 -
nginx:指定要停止的服务名称。 -
stop:指示服务停止。
需要注意的是,在 Ubuntu/Debian 系统中,可以使用 start 和 stop 命令直接在终端中启动或停止 Nginx 服务,而无需使用 sudo service。但是,在 Red Hat/CentOS 系统中,必须使用 systemctl 命令来管理服务。
使用 systemctl 命令时,还可以指定其他选项,例如:
-
restart:重新启动服务。 -
reload:重新加载服务配置。 -
status:查看服务状态。
例如:
sudo systemctl reload nginx










