您的位置:首页 > 博客中心 > 互联网 >

安装Nginx后不能访问虚拟机中的浏览器解决办法

时间:2022-05-11 12:26

首先检查Nginx是否启动成功

[root@web1 extra]# ps aux|grep nginx     (一切正常)
root 3269 0.0 0.1 46764 1464 ? Ss 09:34 0:00 nginx: master process nginx -c /application/nginx/conf/nginx.conf
nginx 3273 0.0 0.1 48848 1752 ? S 09:34 0:00 nginx: worker process
root 3797 0.0 0.0 112824 976 pts/1 R+ 09:48 0:00 grep --color=auto nginx

检查80端口是否被分配给Nginx

[root@web1 extra]# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1173/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1174/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1334/master
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 2691/sshd: root@pts
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 694/rpcbind
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 3269/nginx: master     #端口被分配给你Nginx
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 1650/dnsmasq
tcp6 0 0 :::22 :::* LISTEN 1173/sshd
tcp6 0 0 ::1:631 :::* LISTEN 1174/cupsd
tcp6 0 0 ::1:25 :::* LISTEN 1334/master
tcp6 0 0 ::1:6010 :::* LISTEN 2691/sshd: root@pts
tcp6 0 0 :::111 :::* LISTEN 694/rpcbind

以上的配置都是正确的,之所以安装完Nginx后在虚拟机中不能访问浏览器,是因为对80端口的防火墙未进行配置

对80端口进行防火墙的配置

[root@web1 extra]# firewall-cmd --zone=public --add-port=80/tcp --permanent
success

现在重启防火墙服务

[root@web1 extra]# systemctl restart firewalld.service

此刻在虚拟机中重新验证,发现虚拟机可以访问网页了。

 

本类排行

今日推荐

热门手游