Table of Contents
Configuration of a Virtual Host
In the example configuration the
What | Configuration |
---|---|
Domain Name is: | paywyw.com |
The webserver's Host OS is: | Ubuntu |
The Apache webserver's IP is: | 176.34.101.53 |
1. Parking and redirecting
After registering and parking the domain by some registrar (in my case Godaddy) redirect the domain to your server.
To redirect all subdomains to the webserver ip use the wildcard: '*'
To redirect the domain paywyw.com itself to the webserver ip use: '@'
2. Creating the new domain
Under /etc/apache2/sites-available do add a new file which will represent the new Virtual Host:
Here are some example Virtual-Host files listed:
To add a default Virtual Host, which will handle redirects from any Domain do add a file named default (and <fc #FF0000>enable the virtual host as shown in step 3</fc>). All redirects, which are not matched by any VirtualHost Entry will be handled by this VirtualHost.
<VirtualHost *:80> DocumentRoot /path/to/the/website/available/under/paywyw.com/ </VirtualHost>
To add a default Virtual Host, which will handle redirects from a concrete (sub)domain do (and <fc #FF0000>enable the virtual host as shown in step 3</fc>)
<VirtualHost *:80> ServerName subdomainname.paywyw.com ServerAlias www.subdomainname.paywyw.com DocumentRoot /path/to/the/website/available/under/paywyw.com/ </VirtualHost>
3. Enabling the new Domain on the Webserver
Do run the command and pass the name of the file, representing the VirtualHost as parameter:
root@irony:~# a2ensite default Site www.example.com installed; run /etc/init.d/apache2 reload to enable. root@irony:~# a2ensite subdomainname.paywyw.com Site www.example.com installed; run /etc/init.d/apache2 reload to enable.
Or just create a symbolic links in the folder /etc/apache2/sites-enabled to every file in the folder /etc/apache2/sites-available. The name of the link should be the same as the name of the file.
root@irony:/etc/apache2/sites-enabled# ln -s /etc/apache2/sites-enabled/default