Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been trying to follow a few basic tutorials explaining how to get Apache up and running (on ubuntu, running on Amazon). I've mostly come up blank, because all the tutorials told me to configure httpd.conf (to add DocumentRoot, etc.).

I've now stumbled across one tutorial that told me to add site configurations to the sites-available directory (under /etc/apache), and then symlink to it from sites-enabled. Configuring this way seems to work.

But now I'm confused - how am I supposed to configure Apache? Most tutorials still seem to say that I should be using httpd.conf. Which one should I be using? What's the difference? Why are all the tutorials "wrong" (if they are)?

share|improve this question
up vote 20 down vote accepted

The sites-available method is generally considered the "Debian Way":

  • "main" config in /etc/apache2/apache2.conf
  • "user" config in /etc/apache2/httpd.conf
  • vhosts in /etc/apache2/sites-available files (one per file, typically)
    • you might want to number them, e.g.,
  • ports (Listen directives) in /etc/apache2/ports.conf
  • mods in /etc/apache2/mods-available

You can manipulate these with symlinks or with the a2 series of commands:

a2ensite/a2dissite <site_config_filename>
a2enmod/a2dismod <module_name>

Depending on personal preference, you can restart Apache using apachectl, /etc/init.d/apache2 (start|stop|reload|restart), or service apache2 (start|stop|reload|restart)

An example where you would use httpd.conf instead of a vhost entry would be for a global redirect or rewrite rule, for example. Other tidbits -- generally, you should leave apache2.conf alone, and make sure you set up a consistent naming scheme for vhosts in the sites-available directory.

share|improve this answer
Great summary! Much more clear and concise than the one I was working on. +1. – Steven Monday Dec 26 '10 at 18:44
Sites available provides good modularization of the configuration. It enables you to focus on a single site's configuration easily. It also makes it much easier to compare sites on a server or to move or replicate a site between servers. – BillThor Dec 26 '10 at 22:04
Thanks Sam, nice explanation! – Ida Ebkes Apr 17 '13 at 10:19
+1. When you need to maintain these configurations go to 'sites-enabled' instead of 'sites-available' and access them directly from there. This way you will always be able to determine and access the currently used site configurations. – Ross Feb 4 '15 at 22:50

The location and organisation of the configuration files is configurable and can change between major releases or between distributions.

The Apache Wiki has a handy guide to the names and locations of the configuration files.

Because the config files can contain include directives, parts of the configuration can be separated out into smaller files. Since a standard Apache configuration file contains many comments and lots of standard items, it makes some sense to separate out the parts you are most likely to change.

The name of the main configuration file can be changed at compilation time and in recent releases it has changed from httpd.conf to apache2.conf

Over the years there has been some evolution in the organisation of the included configuration files too.

For example, I installed Apache2 on a Ubuntu-based system using apt-get install apache2 - here's the included files

/etc/apache2$ ls
apache2.conf  envvars     mods-available  ports.conf       sites-enabled
conf.d        httpd.conf  mods-enabled    sites-available

/etc/apache2$ grep ^Include apache2.conf
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf
Include /etc/apache2/httpd.conf
Include /etc/apache2/ports.conf
Include /etc/apache2/conf.d/
Include /etc/apache2/sites-enabled/ 

/etc/apache2$ ls -l sites-enabled
total 0
lrwxrwxrwx 1 root root 26 Dec 26 12:30 000-default -> ../sites-available/default

So the few configuration settings you are likely to be most interested in are now in /etc/apache2/sites-available/default.

I can see that this is consistent with the Ubuntu documentation for Apache which I recommend you read first. If you have other documentation for older versions of Apache (or other distributions) you can adapt that information to suit the way things are organised in Ubuntu.

share|improve this answer

The Apache in linux can be installed by two types . one is by apt-get and other download tar file and extract .... Thus in apt-get process sites are served out from /etc/apache2/sites-enabled folder as each site serving to outside world is configured in these folder by .conf files example 000-default.conf is a default site enabled to show apache works .

thus by creating any .conf file in sites-enabled and directing it to location of content ..thus site is served .

So in order to add a new static site a new .conf file has to be created in sites-enabled folder with whatso ever name example example.conf . and has to add the below lines in it

ServerAdmin webmaster@localhost DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined

Where as , *:80 indicates "open to world through port 80" DocumentRoot /var/www/html indicates "path of site contents "

share|improve this answer

Your Answer


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.