当前位置:首页 > linux > 正文

linux下安装nginx教程(linux安装nginx详细步骤)

  • linux
  • 2024-04-03 02:24:04
  • 6914
Linux 下安装 Nginx 教程
1. 启用官方存储库
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:nginx/stable
2. 更新软件包列表
sudo apt update
3. 安装 Nginx
sudo apt install nginx
4. 验证安装
sudo nginx -v
它将显示 Nginx 版本信息。
5. 启动 Nginx
sudo systemctl start nginx
6. 启用 Nginx
sudo systemctl enable nginx
7. 检查 Nginx 状态
sudo systemctl status nginx
它将显示 Nginx 的当前状态。
一些关键要素:
ppa:nginx/stable: 这是 Nginx 官方稳定存储库。
-v: nginx -v 命令用于查看 Nginx 版本。
systemctl start nginx: 此命令用于启动 Nginx 服务。
systemctl enable nginx: 此命令用于在系统启动时自动启动 Nginx。
sudo: 在 Ubuntu 中,需要使用 sudo 命令来运行管理命令。