How to add multiple virtual hosts under ubuntu14.04 LTS when the lamp installation is complete

Source: Internet
Author: User

When we install the lamp environment, we usually use localhost for local address access, however, when we are in the experimental environment, for example, to build a website test.cn To do experiments, this is the use of virtual host.


Here I use the PHP environment is Lamp-server, operating system for Ubuntu 14.04 LTS.


  1. Add this 127.0.0.1 food.cn under the/etc/hosts.

    127.0.0.1 localhost
    127.0.1.1 Wen
    127.0.0.1 test.cn #添加自己的域名
    # The following lines is desirable for IPV6 capable hosts
    :: 1 ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 Ip6-mcastprefix
    Ff02::1 Ip6-allnodes
    Ff02::2 ip6-allrouters

  2. sudo gedit/etc/apache2/sites-available/000-default.conf configuring virtual hosts, copying and localhost configuration and removing related annotations

    <virtualhost *:80>
    ServerAdmin test.cn #添加自己定义的域名
    Documentroot/var/www/test #添加自己域名所对应的目录
    Errorlog ${apache_log_dir}/error.log
    Customlog ${apache_log_dir}/access.log combined
    </VirtualHost>


  3. Restart Apache Service
    sudo service apache2 restart


  4. Open the browser, enter test.cn that can use this domain name to access their own defined files.


Note: In this configuration process, the most important is to find the virtual host configuration file, in Utubtu Lts is placed in,/etc/apache2/sites-available/000-default.conf, open can

This article is from the "Small City Studio" blog, please be sure to keep this source http://xcroom.blog.51cto.com/7941996/1629187

How to add multiple virtual hosts under ubuntu14.04 LTS when the lamp installation is complete

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.