Creating Multiple Virtual Hosts in Apache2 on Ubuntu
Starting, Stopping, Restarting Apache
1 | /etc/init.d/apache2 start|stop|restart |
Make sure the domain names to resolve to the IP address of your webserver.
/etc/apache2/conf.d/virtual.conf
/etc/apache2/sites-available -> /etc/apache2/sites-enabled
Create files in /etc/apache2/sites-available, these files should be as below. Then sym link it to same named file in /etc/apache2/sites-enabled
2 | # Example.com (/etc/apache2/sites-available/www.example.com) |
5 | ServerAdmin webmaster@example.com |
6 | ServerName www.example.com |
7 | ServerAlias example.com |
9 | # Indexes + Directory Root. |
10 | DirectoryIndex index.html |
11 | DocumentRoot /home/www/www.example.com/htdocs/ |
14 | ScriptAlias /cgi-bin/ /home/www/www.example.com/cgi-bin/ |
20 | ErrorLog /home/www/www.example.com/logs/error.log |
21 | CustomLog /home/www/www.example.com/logs/access.log combined |
2 | # Example.net (/etc/apache2/sites-available/www.example.net) |
5 | ServerAdmin webmaster@example.net |
6 | ServerName www.example.net |
7 | ServerAlias example.net |
9 | # Indexes + Directory Root. |
10 | DirectoryIndex index.html |
11 | DocumentRoot /home/www/www.example.net/htdocs/ |
14 | ScriptAlias /cgi-bin/ /home/www/www.example.net/cgi-bin/ |
21 | ErrorLog /home/www/www.example.net/logs/error.log |
22 | CustomLog /home/www/www.example.net/logs/access.log combined |
Disqus comments