I'm trying to configuring my Apache to 'answer' to multiple domains.


www.site1.com -> /var/www/site1.com/

www.siteX.com -> /var/www/siteX.com/

www.bibibi.com -> /var/www/bibibi.com/

Can I use single 000-default.conf (with multiple declaration) or do I need to use different .conf file and enable with a2ensite ?



Technically you can do whatever you like as long as Apache httpd accepts your configuration as valid.

Professionally speaking: follow the conventions established by your distribution. That will ensure predictable behavior of other tooling (such as for instance certbot/letsencrypt) and protect the sanity of yourself and others.


What do you mean by 'multiple' domains? Do you want multiple different sites or virtual hosts? Or do you want that one virtual hosts to handle all your domains?

If the latter just adjust your ServerName, and ServerAlias options correctly for that virtual host.

<VirtualHost *:80>
    ServerName primarydomain.example.info
    ServerAlias example.com example.org example.gov

You can configure multiple virtual hosts in a single file, but it's a bad practice.

The trick is you need understand how the file structure works

  1. a2ensite this command just create a symbolic link into /etc/apache2/sites-enabled to enable the new site (the new site .conf file should be locate it inside /etc/apache2/sites-available) .
  2. When you are working with multiple virtual host its a good practice create multiple files inside /etc/apache2/sites-available. This allow you disable a single site removing the symbolic link locate it in /etc/apache2/sites-enabled whitout removing the config file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.