Tag Archives: a2ensite

How to Solve: a2ensite “Error, Site does not exist!” Tips, Tricks and Tutorials 04 JUL 2015

To enable a virtual vhost website on your Ubuntu Server running Apache, you need to first create a vhost configuration file (just copy 000-defaul.conf as a quick way to start), and then run the a2ensite command to enable it so that Apache knows about it.

However, nowadays attempting to run a2ensite might just pop up with this particular error message:

ERROR: Site [YOURSITE] does not exist!

This is not a problem that used to occur, but in newer versions of Ubuntu it does – the reason for this is simple – your configuration file is probably missing a .conf extension, and the a2ensite perl script now only works with filenames ending in .conf!

So to fix, simply add the .conf your site vhost configuration file and run a2ensite again.

sudo a2ensite YOURSITE.conf

This time around you should be all good, and can jump straight into the next step of reloading Apache’s configuration with:

sudo service apache2 reload

Nifty.

Apache attack helicopter

Ubuntu: How to set up an Apache Virtual Host (vhost) CodeUnit 28 SEP 2011

To set up a virtual host (vhost) under Apache on your Ubuntu server is relatively simple. First you need to create a config file under the /etc/apache2/sites-available directory. A good practice is to name this file the same as the folder you want to use to hold this virtual host’s web pages.

For this example we want to serve up traffic coming in for www.mydomain.com, so we create a file called mydomain:

sudo nano /etc/apache2/sites-available/mydomain

The contents of which looks like this:

<VirtualHost *:80>
DocumentRoot /home/www/mydomain
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/www/mydomain>
Options FollowSymLinks
AllowOverride None
Order allow,deny
allow from all
</Directory>
ServerName mydomain.com
ServerAlias www.mydomain.com

ErrorLog /var/log/apache2/mydomain-error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/mydomain-access.log combined

ErrorDocument 404 /error_documents/404.php
ErrorDocument 403 /error_documents/403.php

</VirtualHost>

With the file saved, next we enable the site by running:

sudo a2ensite mydomain

Finally, reload the Apache configuration with:

sudo /etc/init.d/apache2 reload

Done.

(And if you are in the process of looking for a hosting server, you may want to check out different web hosting companies first to help you compare and find the most appropriate hosting account for you.)

Ubuntu: How to Enable or Disable an Apache2 Site / Virtual Host CodeUnit 07 JAN 2011

Sites or virtual hosts are extremely useful when you are hosting more than one website on a box. I’ve already shown you how to set up virtual hosts under Apache 2, but I thought I would quickly just give a little more insight into what the a2ensite and converse a2dissite function calls do.

All that a2ensite is, is a script that enables specified sites (which contain a
block) within the apache2 configuration.

It achieves this by creating symlinks within /etc/apache2/sites-enabled. The opposite of doing this is a2dissite which disables the site by removing that symlink.

Funnily enough, you can enable or disable a site multiple times without getting an error, simply because all these scripts are doing is manipulating symlinks. Lastly, the default site is handled specially, with a resulting symlink called 000-default in order to be loaded first.

And now you know.