centos7-配置阿里yum源安装nginx

centos7-配置阿里yum源安装nginx

目录

一、环境准备

二、安装 

三、常见无法访问情况排查


一、环境准备

1.备份本地yum源文件

[root@ccie /]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo_bak

2.下载yum源配置文件(演示下载阿里源)

博客演示系统版本:CentOS Linux release 7.7.1908 (Core)  阿里云服务器

[root@ccie /]# wget -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

3.更新yum缓存,查看当前yum源

[root@ccie /]# yum makecache  //更新yum源
[root@ccie /]# yum repolist   //查看yum源
yum源详细

二、安装 

1.yum安装

[root@ccie /]# yum install -y  nginx

目前阿里源nginx版本:nginx-1.16.1-1.el7.x86_64

 2.启动nginx服务

[root@ccie /]# systemctl start nginx
这里不报错即可,不会出现成功反馈

3.测试

[root@ccie /]# curl http://127.0.0.1
出现如图现象,即安装成功
这里出现的是网页源码

 

浏览器中输入服务器地址测试图

三、常见无法访问情况排查

  • 查看防火墙:
    [root@ccie /]# firewall-cmd --list-port 查看防火墙开放端口,80端口是否打开
    [root@ccie /]#  firewall-cmd --zone=public --add-port=80/tcp --permanent //开放防火墙80端口
    [root@ccie /]# firewall-cmd --reload  //重启防火墙,开放端口才会生效
    
  • selinux
    [root@ccie /]#  setenforce 0 //关闭slinux
    

     

  • 云服务器上(调整安全策略组)

阿里云调整如下:

登录命令控制台-实例-更多-网络和安全组-安全组配置

 

点击配置规则

 

添加安全组规则-开放需要的端口
posted @ 2020-03-13 10:09  ASQW234  阅读(1384)  评论(0编辑  收藏  举报