How can I run multiple web domains on my server?

Now, to run multiple domains on one web server, you need to create a so-called virtual host. When a browser calls your web server, the browser also transmits the exact domain name and based on this information, the web server then displays a directory set for this domain.

To provide this functionality, you must create a virtual host for the domain in the Apache configuration.

Under Debian GNU/Linux, these are managed in individual text files under /etc/apache2/sites-available/. Here you can see a VHost declaration for the named domain, "example.org", this is representative for the domain you want to create and you have to replace it with your domain:

<VirtualHost *>
ServerName example.org
ServerAlias www.example.org

DocumentRoot /var/www/example.org

<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>

<Directory /var/www/example.org>
Options FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

ErrorLog /var/log/apache2/error_example.org.log
LogLevel warn
CustomLog /var/log/apache2/access.example.org.log combined
ServerSignature On

</VirtualHost>

Save this file under the name "example.org". After that you can activate it with the following command:

# a2ensite example.org

...and finally restart the web server with the following command:

# service restart apache2

Kommentieren nicht möglich