Virtual Box + CentOS Minimal + Apache build Web server

Source: Internet
Author: User

This article does not introduce information about Virtual box, CentOS, Apache installation, mainly for post-installation related configuration, so that the host can access the client machine (Guest:centos in Virtual box) to provide Web services.

  1. Virtual Box Network settings

    many articles on the internet say to use Host access to Guest 's Web service requires two networks (NAT and Hostonly), in fact we only need to use a NAT network to achieve the purpose.

    take NIC 1 as an example , Select " network address Translation (NAT)" In the connection mode, and set the promiscuous to " deny ";

    Simple to use NAT does not allow the Host to access Guest directly , it needs to set the port mapping,

    As shown , we map some ports of host to the guest, such as the 80 port that we are asking for CentOS when we visit http://127.0.0.1:80.

  2. Configuration of CentOS

    when the port mapping is set , the Web service provided by the guest is not opened when the http://127.0.0.1:80 is accessed through the browser, but the guest is properly connected via SSH.

    through netstat-tlpn to view the port information for CentOS:

    Although there is a listening port , but only for TCP6 (IP6), and TCP (IP4) and the end of listening to the port, so when using a browser connection does not open the Web service normally.

    You can open ports with the following command and allow iptable4s access :

    iptables-i input-p tcp-m tcp--dport 80-j ACCEPT

    or

    Iptables-i input-i eth1-p tcp-m tcp--dport 80-j ACCEPT

    and use Service Iptables Save Save the configuration .

    Use The Internet Explorer accesses Apache in CentOS as shown below :

    1. Resources

      set iptable4s and open the appropriate port :

      Http://serverfault.com/questions/324190/virtualbox-and-centos-6-cannot-connect-to-httpd

      To install the iptables4 service :

      Http://stackoverflow.com/questions/24756240/how-can-i-use-iptables-on-centos-7

       

Virtual Box + CentOS Minimal + Apache build Web server

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.