linux安装nginx的命令行
linux安装nginx的命令行详细介绍
在不同的 Linux 发行版中,安装 Nginx 的命令有所不同,下面为你介绍常见发行版的安装方法。
基于 Debian 或 Ubuntu 的系统
可使用 apt 包管理器来安装 Nginx,步骤如下:
- 更新软件包列表:
bash
update
- 安装 Nginx:
bash
nginx
基于 CentOS 或 RHEL 的系统
借助 yum 或者 dnf 包管理器安装 Nginx,步骤如下:
- 启用 Nginx 存储库:
bash
yum epel-release
或者
bash
dnf epel-release
- 安装 Nginx:
bash
yum nginx
或者
bash
dnf nginx
基于 Arch Linux 的系统
利用 pacman 包管理器安装 Nginx,命令如下:
bash
pacman nginx
安装完成后,你可以启动 Nginx 服务,并设置其开机自启:
bash
systemctl start nginxsystemctl nginx
你还可以通过如下命令检查 Nginx 服务状态:
bash
systemctl status nginx
912 systemctl status nginx