linux使用nginx

本文介绍了如何通过yum在CentOS中安装nginx,包括添加第三方yum源、更新源、确保开机自启动以及管理防火墙。步骤包括安装EPEL,更新yum,然后重新安装nginx,以及设置nginx自动启动和防火墙控制。
摘要由CSDN通过智能技术生成

通过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
  • 11
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值