① Installing the Apache server
$ sudo apt-get update
$ sudo apt-get install apache2
② Configuring a single IP multi-site
$ sudo vi/etc/apache2/sites-available/000-default.conf
#DocumentRoot/var/www/html comment out the line
$ cat/etc/apache2/sites-available/000-default.conf|grep-v "#"
<virtualhost *:80>
ServerAdmin [email protected]
ServerName www.tian.com
DocumentRoot "/var/www/tian.com"
Errorlog ${apache_log_dir}/error.log
Customlog ${apache_log_dir}/access.log combined
</VirtualHost>
<virtualhost *:8080>
ServerName www.baidu.org
DocumentRoot "/var/www/baidu.org"
Errorlog ${apache_log_dir}/error.log
Customlog ${apache_log_dir}/access.log combined
</VirtualHost>
Note 1: Here the * refers to 127.0.01
NOTE 2: Configure multi-IP multi-site to remove the above *, replace with the required IP
③ Adding a listening port
$ sudo vi/etc/apache2/ports.conf
Listen 80
Listen 8080
④ Modify the host file and add the following
$ sudo vi/etc/hosts
127.0.0.1 www.tian.com
127.0.0.1 www.baidu.org
NOTE 1: Simulation experiment, actually add DNS
NOTE 2: Multiple IP can be modified to the corresponding IP
⑤ Browser for verification
This article is from the Notepad blog, so be sure to keep this source http://wangzhijian.blog.51cto.com/6427016/1690495
Ubuntu under Apache Multi-site Virtual host Configuration