sites-available

Inside sites-available will be files containing the configurations for each site you want to serve - these are known as vhosts or virtual hosts.

Have a look now and see that there is one site (default) available:

# ls sites-available/
...
default default-ssl

The apache install has a 'default' and a 'default-ssl' vhost available - when we navigated to the Cloud Server IP and got the 'It works!" message, it was the 'default' file that told Apache what to do and where the files where located.

We'll look at vhosts in more detail and create our own in a later article.

Do note that a file in sites-available does not mean they are active. They are simply available for serving if you enable them. Which brings us to...

sites-enabled

This folder contains symlinks to the sites you actually want to serve.

For example, you could have two vhosts configured and ready to use in the sites-available folder, but only one of them enabled. Only the one symlinked from the sites-enabled folder would be served.

This means that the 'default' site has been enabled - the symlink named '000-default' links to the 'default' file in the sites-available folder.

Without the symlink in this folder it would remain available (in the sites-available folder) but not active.

The other thing to note is the naming. It's possible for a domain to point to your Cloud Server IP but have no site configuration file. In these cases, the first enabled site (alphabetically) will be displayed, i.e. 000-default's config will be used.

mods-available

Well, I guess you get the idea already but this folder holds the modules that are available to be loaded.

Have a look:

# ls mods-available

A fair list is available from our base install but remember that they are not all enabled, merely available for use.

Just as with the vhosts files, any modules that we want to use must be enabled.

mods-enabled

This folder contains symlinks to the modules that we want enabled. Have a look and compare it to the list of modules available:

# ls mods-enabled

This list is a lot shorter than the list of available modules (meaning not all the available modules are enabled) and includes php5.conf - which is handy as we installed PHP5 earlier.

a2en and a2dis

Being good sysadmins, we like to get hands on and create our vhosts, and now that we know how the symlinks work we could go ahead and 'ln -s' until all our sites are enabled.

However, there are some commands that make this process much easier.

They are a2dissite, a2ensite, a2dismod and a2enmod.

a2dissite

This will delete the symlink to a site you have previously enabled.

For example, let's disable the default site:

# sudo a2dissite default

The symlink in sites-enabled has been deleted and the output is as follows:

Site default disabled.
Run '/etc/init.d/apache2 reload' to activate new configuration!

Reload Apache as indicated to ensure the site is fully disabled:

# sudo /etc/init.d/apache2 reload

When you now visit your Cloud Server IP, instead of the nice 'It Works!' page, you will get a 404 Not Found message:

Note the main vhosts file in sites-available is still there - all the a2dissite command did was remove the symlink in the sites-enabled folder.

a2ensite

Let's enable the default site again:

# sudo a2ensite default

The output:

Enabling site default.
Run '/etc/init.d/apache2 reload' to activate new configuration!