1. Resolve the DNS of http://www.a.com and http://www.b.com to your server IP.
2. Remove the Apache default host configuration file. You also do not want to create 2 virtual host after people can also directly access/var/www/bar;
Enter/etc/apache2/sites-enabled/; Delete the 000-default file.
3. In the/etc/apache2/sites-enabled/directory, create 2 files with VI. File name with www.a.com.conf; Www.b.com.conf
Fill in the following code into the www.a.com.conf:
1 <VirtualHost*:80>2 ServerName www.a.com3 ServerAdmin [email protected]4 documentroot/var/www/www.a.com5 <Directory/>6 Options followsymlinks7 allowoverride None8 </Directory>9 <Directory/var/www/www.a.com/>Ten Options Indexes followsymlinks multiviews One allowoverride None A Order Allow,deny - allow from all - </Directory> the - scriptalias/cgi-bin//usr/lib/cgi-bin/ - <Directory"/usr/lib/cgi-bin"> - allowoverride None + Options +execcgi-multiviews +symlinksifownermatch - Order Allow,deny + allow from all A </Directory> at - #ErrorLog ${apache_log_dir}/error.log - - # Possible Values Include:debug, info, notice, warn, error, Crit, - # Alert, Emerg. - LogLevel warn in - #CustomLog ${apache_log_dir}/access.log Combined to + alias/doc/"/usr/share/doc/" - <Directory"/usr/share/doc/"> the Options Indexes multiviews followsymlinks * allowoverride None $ Order Deny,allowPanax Notoginseng Deny from all - Allow from 127.0.0.0/255.0.0.0:: 1/128 the </Directory> + A </VirtualHost>
www.a.com.conf
1 <VirtualHost*:80>2 ServerName www.b.com3 ServerAdmin [email protected]4 documentroot/var/www/www.b.com5 <Directory/>6 Options followsymlinks7 allowoverride None8 </Directory>9 <Directory/var/www/www.b.com/>Ten Options Indexes followsymlinks multiviews One allowoverride None A Order Allow,deny - allow from all - </Directory> the - scriptalias/cgi-bin//usr/lib/cgi-bin/ - <Directory"/usr/lib/cgi-bin"> - allowoverride None + Options +execcgi-multiviews +symlinksifownermatch - Order Allow,deny + allow from all A </Directory> at - #ErrorLog ${apache_log_dir}/error.log - - # Possible Values Include:debug, info, notice, warn, error, Crit, - # Alert, Emerg. - LogLevel warn in - #CustomLog ${apache_log_dir}/access.log Combined to + alias/doc/"/usr/share/doc/" - <Directory"/usr/share/doc/"> the Options Indexes multiviews followsymlinks * allowoverride None $ Order Deny,allowPanax Notoginseng Deny from all - Allow from 127.0.0.0/255.0.0.0:: 1/128 the </Directory> + A </VirtualHost>
www.b.com.conf
Apache detailed permissions can be modified on the above configuration file.
Article turned from: http://forum.ubuntu.org.cn/viewtopic.php?t=341070
"Go" ubuntu+apache bind multiple domain names