Q关于Vagrant:我在流浪汉中设置了一个centos 6.5,我已经安装了httpd但我无法在虚拟机上访问网站

时间:2015-09-27 19:40:02

标签: apache centos server vagrant private-network

我在流浪汉中设置了一个centos 6.5作为服务器。

我使用private_network设置IP:192.168.33.20

我使用ip地址192.168.33.20来访问虚拟机上的SSH和SFTP。

但我只能通过该IP地址(192.168.33.20)访问网站,尽管我已经安装了httpd且httpd正在运行

[root@centos65 ~]# netstat -nltp
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:45525               0.0.0.0:*                   LISTEN      1082/rpc.statd
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1208/sshd
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      1285/master
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      1062/rpcbind
tcp        0      0 :::22                       :::*                        LISTEN      1208/sshd
tcp        0      0 ::1:25                      :::*                        LISTEN      1285/master
tcp        0      0 :::34314                    :::*                        LISTEN      1082/rpc.statd
tcp        0      0 :::111                      :::*                        LISTEN      1062/rpcbind
tcp        0      0 :::80                       :::*                        LISTEN      3202/httpd

检查SELinux,它被禁用

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.
SELINUXTYPE=targeted

更改HTTP端口

[root@centos65 ~]# sudo netstat -nltd
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:49655               0.0.0.0:*                   LISTEN
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN
tcp        0      0 :::22                       :::*                        LISTEN
tcp        0      0 ::1:25                      :::*                        LISTEN
tcp        0      0 :::45389                    :::*                        LISTEN
tcp        0      0 :::111                      :::*                        LISTEN
tcp        0      0 :::8080                     :::*                        LISTEN

我无法从我的主机访问我的Web服务器

1 个答案:

答案 0 :(得分:-2)

打开端口80,转到并写入

# vi /etc/sysconfig/iptables

插入新行

-A INPUT -p tcp -m state –state NEW –dport 80 -j ACCEPT

这就是解决问题的方法