Centos7 yum 安装nginx

nginxyum.jpg

安装yum工具

yum install yum-utils
到 cd /etc/yum.repos.d/ 目录下
新建 vim nginx.repo 文件
输入以下信息(添加yum源)
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
通过yum search nginx看看是否已经添加源成功
yum install nginx

安装完后,rpm -qa | grep nginx 查看安装结果

其他命令:

启动nginx:

systemctl start nginx

加入开机启动:

systemctl enable nginx

查看nginx的状态:

systemctl status nginx
qrcode