Linx操作Nginx命令

在 CentOS 上操作 Nginx 包括安装、启动、停止、重新加载配置等。以下是在 CentOS 上操作 Nginx 的常用命令:

  1. 安装 Nginx:

    sudo yum install nginx
    
  2. 启动 Nginx:

    sudo systemctl start nginx
    
  3. 停止 Nginx:

    sudo systemctl stop nginx
    
  4. 重新加载 Nginx 配置:

    sudo systemctl reload nginx
    
  5. 重启 Nginx:

    sudo systemctl restart nginx
    
  6. 查看 Nginx 状态:

    sudo systemctl status nginx
    
  7. 开机自启动 Nginx:

    sudo systemctl enable nginx
    
  8. 停止开机自启动 Nginx:

    sudo systemctl disable nginx
    

以上命令中,使用了 systemctl 来管理 Nginx 服务。在执行任何涉及到配置文件的操作(如重新加载配置、重启)之前,确保已经保存了修改的配置文件。

注意:在执行上述命令时,可能需要管理员权限。如果提示需要管理员权限,请使用 sudo 命令来运行相应的命令。

posted @ 2023-08-10 10:45  今晚打老虎!  阅读(64)  评论(0编辑  收藏  举报