Friday, 16 April 2010

Toggle NERDTree

Putty Colours Config

Just pop this here - for setup on Windows machine:

Don't forget to save this as your "default settings".

Another nice touch is turning font anti-aliasing on and selecting a funkier font.

Friday, 2 April 2010

Apache SSL configuration and Django

Using mod_wsgi to support Django development via Apache

I'm building a Django shop which integrates PHP components in the form of a blog (Wordpress) and needs testing with SSL. As discussed in the last blog entry- that means I can't well test holistically using only the Django dev server. On production I am using mod_python at the moment, which is inappropriate for development as I would need to restart the server each time I make a change.

I'm looking to follow a recipe, using mod_wsgi for two purposes:
  • To have a dev server running via apache, to integrate PHP and SSL components, as well as having "hot code replacement" to support development.
  • To evaluate mod_wsgi on the basis of the claim: "for hosting WSGI applications in conjunction with Apache it has a lower memory overhead and performs better than mod_python".

Step 1 will be to deploying using mod_wsgi on my dev laptop per the mod_wsgi docs.
  • sudo apt-get install libapache2-mod-wsgi [ubuntu]
  • restart apache
Step 2 is a standard integration with Apache. Per
  • create appropriate .wsgi file
  • edit apache.conf with directive (see below)
Step 3 is getting it to then run in daemon mode. This is a little like what mod_jk or ruby passenger / mod_rails does. It brokers requests off to a separate sub process which forks and brokers off to individual Python Django scripts.

Step 4, finally per:, is to add a (the source of which is here) and reference it in the .wsgi file.

Here are example apache / httpd.conf:

And dev.wsgi (based of putting a in the root of the django app):

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: