通过yum来安装nginx
直接通过命令 yum install -y nginx
yum install -y nginx
如果出现以下错误
[root@localhost /]# yum install -y nginx
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
没有可用软件包 nginx。
错误:无须任何处理
出现这个是因为:nginx位于第三方的yum源里面,不在centos官方yum源里面
所以通过
yum -y install epel-release
来安装yum源
之后更新yum源
yum -y update
更新完毕之后重新安装nginx
yum install -y nginx
启动完毕
注意
通过命令
systemctl enable nginx
让nginx开机自启可以在每次开机之后不用执行nginx启动命令
systemctl disable firewalld.service
防火墙停止,并关闭开机自启
systemctl stop firewalld.service
systemctl disable firewalld.service