apachecentosservervagrantprivate-network

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


I'm setting a centos 6.5 in vagrant as server.

I use private_network setting with IP: 192.168.33.20

I used ip address 192.168.33.20 to access SSH and SFTP on virtual machine.

But only I can't access website by that IP address (192.168.33.20) although I have installed httpd and httpd is running

[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

checking SELinux, it is disabled

# 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

Changing HTTP Port

[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

I cannot access my Web Server from my host


Solution

  • Open port 80, go to and write

    # vi /etc/sysconfig/iptables
    

    Insert a new line

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

    That's all to resolve the problem