关于 Vagrant 的问题:我在 vagrant 中设置了一个 centos 6.5,我已经安装了 httpd 但我无法在虚拟机上访问网站
Q about Vagrant: I'm setting a centos 6.5 in vagrant, I have installed httpd but I can't access website on virtual machine
我在 vagrant 中设置了一个 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 服务器
打开80端口,去写入
# vi /etc/sysconfig/iptables
插入一个新行
-A INPUT -p tcp -m state –state NEW –dport 80 -j ACCEPT
这就是解决问题的全部
我在 vagrant 中设置了一个 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 服务器
打开80端口,去写入
# vi /etc/sysconfig/iptables
插入一个新行
-A INPUT -p tcp -m state –state NEW –dport 80 -j ACCEPT
这就是解决问题的全部