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

I'm a noob, please be nice.

Can anyone tell me, in a nutshell, what the purpose of these two directories are in Debian?

/etc/apache2/sites-enabled /etc/apache2/sites-available

I notice that diffing sites-available/000-default and sites-enabled/default shows they are identical...

What gives?

share|improve this question

migrated from stackoverflow.com Nov 11 '09 at 5:09

This question came from our site for professional and enthusiast programmers.

3 Answers 3

up vote 21 down vote accepted

sites-available contains the apache config files for each of your sites. For example:

<VirtualHost *:80>
  ServerName site.mysite.com
  ServerAdmin my@email.com

  DirectoryIndex index.php
  DocumentRoot /home/user/public_html/site.mysite.com/public

  LogLevel warn
  ErrorLog /home/user/public_html/site.mysite.com/logs/error.log
  CustomLog /home/user/public_html/site.mysite.com/logs/access.log combined
</VirtualHost>

When you want to add a new site (for example, site.mysite.com), you add it here, and use:

a2ensite site.mysite.com

To enable the site. Once the site is enabled, a symlink to the config file is placed in the sites-enabled directory, indicating that the site is enabled.

share|improve this answer
3  
If you want to disable a site, you would run a2dissite site.mysite.com –  Jason Leveille Nov 11 '09 at 1:43
    
a2ensite and a2dissite are located in /usr/sbin which is currently not included in the default user path so tab completion won't work. When typing sudo a2 and pressing the tab key however you will be offered both a2ensite and a2dissite. –  Stefan Schmidt Jun 29 '13 at 19:39

More important than the mechanics of the system is the rationale...

Debian provides the two separate directories so that if you're automatically managing your Apache configs, you can just have all of the vhosts drop into sites-available on all your machines, and then individual vhosts can be enabled on the server that will actually serve them. It also means you can near-instantaneously disable a site if it's causing problems (a2dissite example.com; /etc/init.d/apache2 reload).

share|improve this answer

To add to those above, the file in sites-enabled is a symlink to the sites-available file:

ls -l /etc/apache2/sites-enabled/

It's not just the same content, it's the same actual file!

share|improve this answer

Your Answer

 
discard

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

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