Linux 下安装Nginx两种方法- yum安装

直接通过命令 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

启动完毕

nginx安装完毕

注意

通过命令

systemctl enable nginx

让nginx开机自启可以在每次开机之后不用执行nginx启动命令

systemctl disable firewalld.service

防火墙停止,并关闭开机自启

systemctl stop firewalld.service
systemctl disable firewalld.service

用安装包上传方式来安装nginx

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值