Friday, 2 April 2010

Apache Virtual Hosts

In putting together this online shop, I'm going to integrate a Wordpress Blog, and need SSL in addition to my Django app. The Django development server is not going to cut it.

In order to build out my Dev laptop I'm going to setup Apache with virtual hosts, and setup Django to run in a dev mode but behind Apache. This is a hit in time upfront, but should sharpen a few skills on the sysadmin side, make development testing and deployment more straightforward on an ongoing basis. I should consider future project also, so I need to specify the clients as well as the sub-project in the URL.

So, I'm going to add a few hosts into my laptops host file based name resolver. So using "sudo vi /etc/hosts" I add these as aliases for the IP Apache is listening on. hostname

I test these out with a browser and they all take me to the same default page served by Apache on port 80. Per:

If Apache has no vhosts, it will use the main server's DocumentRoot directory (often set to /var/www/html).
Bingo. Now to change the behaviour of Apache.

Within a vhost block--between  and  tags in httpd.conf--many directives may be given, but only two are typically required: the ServerName and the DocumentRoot directives. As a matter of good form,vhost blocks and related directives should go at the end of the httpd.conf file. 
So using "sudo vi /etc/apache2/apache2.conf", added the following:

No comments:

Post a Comment