1.安装说明
在新计算机上首次安装nginx之前,需要设置nginx软件包存储库。 之后,您可以从存储库安装和更新nginx。
[root@localhost ~]# sudo yum -y install yum-utils #先决条件
2.配置nginx的Yum源
[root@localhost ~]# vim /etc/yum.repos.d/nginx.repo
添加如下几行代码
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
3.yum安装
[root@localhost ~]# yum -y install nginx
这就安装成功了。是不是很快呢?
其中第二步的代码也可以从官网上找到,步骤如下:
配置Yum源的官网
4.如果你想要网页显示出nginx的话,你需要
[root@localhost ~]# setenforce 0 #关闭selinux
[root@localhost ~]# systemctl stop firewalld #关闭防火墙
[root@localhost ~]# systemctl start nginx #启动nginx