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.
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
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>
Restart Apache Service
sudo service apache2 restart
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