centos7 安装nginx后无法访问
尝试curl http://127.0.0.1 正常,这时候基本上可以判断是防火墙的问题
关闭防火墙

systemctl start firewalld.service#启动firewall
systemctl stop firewalld.service#停止firewall
systemctl disable firewalld.service#禁止firewall开机启动,enable
firewall-cmd --state #防火墙状态

或者开放80端口
添加防火墙规则
firewall-cmd --permanent --zone=public --add-port=80/tcp //http协议基于TCP传输协议,放行80端口
firewall-cmd --list-all //查看防火墙规则
firewall-cmd --query-service nginx //查看服务启动的状态
firewall-cmd --add-service=ftp --permanent //永久开放ftp服务
firewall-cmd --remove-service=ftp --permanent //永久关闭ftp服务
firewall-cmd --get-service //查看服务名称

这个时候发现还是无法正常访问,又折腾了半天,才找到原因,我用的是阿里云的服务器
阿里云有一个安全组规则,其中限制了外部网络设备对阿里云实例服务器的访问权限。
默认打开了 SSH 连接的 22 端口,80和443端口是关闭的,这个时候还需要在阿里云实例中,选择网络与安全中的安全组,添加安全组规则。
添加80/80,0.0.0.0/0,这个时候nginx才可以正常访问