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?

link|improve this question
feedback

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

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

3 Answers

up vote 8 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.

link|improve this answer
1  
If you want to disable a site, you would run a2dissite site.mysite.com – Jason Leveille Nov 11 '09 at 1:43
feedback

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).

link|improve this answer
feedback

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!

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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