通过yum来安装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源
yum -y install epel-release
更新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
查看防火墙状态
systemctl status firewalld.service
开启防火墙
systemctl start firewalld.service
关闭防火墙
systemctl stop firewalld.service
禁用防火墙开机自启动
systemctl disable firewalld.service
其他命令
重启nginx服务器
./nginx -s reload