yum安装nginx
访问nginx的官网:http://www.nginx.org/
具体步骤如下:
- 切换到
/etc/yum.repos.d/
下,创建一个新的repo
包
cd /etc/yum.repos.d/
vim nginx.repo
- 添加内容是拷贝官方提示的内容
[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 install yum-utils -y
yum-config-manager --enable nginx-mainline
yum install nginx -y
- 安装完成后,可以检查版本及相关信息
nginx -v //查看版本
nginx -V //查看模块信息
- 启动Nginx
systemctl stop firewalld //关闭防火墙
setenforce 0 //关闭setenforce
systemctl start nginx //启动Nginx
systemctl enable nginx //设置开机自启
- 在浏览器里检测
安装完成!