centos7 nginx常用命令

  • 设置nginx服务
    键入如下命令 vim /lib/systemd/system/nginx.service
    写入内容:
[Unit]
Description=nginx service
After=network.target 
   
[Service] 
Type=forking 
ExecStart=/usr/local/nginx-1.19.3/sbin/nginx
ExecReload=/usr/local/nginx-1.19.3/sbin/nginx -s reload
ExecStop=/usr/local/nginx-1.19.3/sbin/nginx -s quit
PrivateTmp=true 
   
[Install] 
WantedBy=multi-user.target
  • 随服务器启动
    systemctl enable nginx.service
  • 重启 nginx 服务
    systemctl restart nginx.service
  • 停止 nginx 服务
    systemctl stop nginx.service
  • 查看 nginx 运行状态
    systemctl status nginx.service
  • 测试配置文件是否正常
    /usr/sbin/nginx -t
  • 测试是否启动成功
    curl -i localhost:8008

你可能感兴趣的:(centos7 nginx常用命令)