Ubuntu: How to Enable or Disable an Apache2 Site / Virtual Host

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.

You might also enjoy:

  • As a web developer I need to juggle a number of projects on my development machine all at once. The simple way to get around accessing these various sites i ...
  • If you've ever tried to do an ASP include using the following sort of input line, , on an IIS web server and you've come up short, the 500.100 error message ...
  • Have you ever wanted to use Google to search within a particular website before?Actually, Google makes this pretty simple thanks to its special site: syntax ...
  • LAMP (Linux, Apache, mySQL and PHP) is a popular open source web development platform that uses Linux as its operating system, Apache as the web server, myS ...
  • Favicons are a great way to personalize one's website, and getting a Joomla 1.5 website to display your custom favicon.ico file turns out to be a pretty sim ...

About Craig Lotter

Craig Lotter is an established web developer and application programmer, with strong creative urges (which keep bursting out at the most inopportune moments) and a seemingly insatiable need to love all things animated. Living in the beautiful coastal town of Gordon's Bay in South Africa, he games, develops, takes in animated fare, trains under the Funakoshi karate style and for the most part, simply enjoys life with his amazing wife and daughter. Oh, and he draws ever now and then too.
This entry was posted in Ubuntu and tagged a2dissite, a2ensite, apache2, virtual host, . Bookmark the permalink.
    blog comments powered by Disqus