Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I want to add a new subdomain to an existing site. I'm using Apache on Debian, with a number of working virtual hosts on the site already - not set up by me.

The /etc/apache2/apache2.conf file contains the following lines (incidentally httpd.conf exists but is empty, I don't know if that's significant):

# Include the virtual host configurations:
Include /etc/apache2/sites-enabled/

In the /etc/apache2/sites-enabled/ directory, there is a whole bunch of files, called things like


Each of these files has a VirtualHost entry - e.g. forum.mysite.org looks like this:

<VirtualHost *:80>
    ServerName forum.mysite.org
    WSGIScriptAlias /var/docs/forum.wsgi
    ... etc

My question is this. To add a new subdomain, do I simply need to create a new file in /etc/apache2/sites-enabled/ and set ServerName and WSGIScriptAlias appropriately? Or is there more to it than that?

share|improve this question

migrated from superuser.com Aug 9 '10 at 16:45

This question came from our site for computer enthusiasts and power users.

if all you want is to add a subdomain to an existent site, for example if the site was forum.mysite.org you could open that file and add bellow ServerName the follow ServerAlias new_sub_domain.mysite.org if ServerAlias already exist just go to the end of the line hit space and add the new subdomain, save and restart apache. –  Prix Aug 9 '10 at 20:05

2 Answers 2

Yes, create a new file in /etc/apache2/sites-available, perhaps copying one of the previous files and modifying it. Then save (keeping to the already-present naming structure will probably help to keep things organised),

a2ensite example.mysite.org

or whatever you've called the file will tell Apache to enable the site, automatically creating the symlink needed in /etc/apache2/sites-enabled. Then

/etc/init.d/apache2 reload

as pQd has already said.

Presumably DNS entries have been set up pointing *.mysite.org to the IP of the server or the FQDN mysite.org, otherwise you'll have to do this or add a new DNS record for each subdomain.mysite.org as well.

share|improve this answer

pretty much it. usually in debian you have actual files in /etc/apache2/sites-available and sites-enabled directory contains only sym-links to earlier ones.

after any modifications tell apache about change in configs:

/etc/init.d/apache2 reload
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.