Django In Production using Apache Server and mod_wsgi.

So what is wsgi? wsgi is short for web server gateway interface, in another way, it is not a library, not an API, nothing but an interface, i.e., a specification that you can find more detail from PEP3333.

I am planning to set up the environment properly on the VM that I installed. Since I have already installed Apache server, the next step is to install mod_wsgi. The interesting thing about the documentation is that it used to be hosted on Google Code but then the author Graham Dumpleton hosted on Github. To make sure I am using the most up to date mod_wsgi, I decided to build it from source and here are the two things you might need to pay attention:

  1. wget doesn’t comes with default on minimal install but curl is available. I had to do curl -LO to follow the redirect and meanwhile download the file locally instead of printing to standard output.
  2. configure, make won’t work out of the box and you have to “yum groupinstall ‘Development Tools'”.
  3. yum install httpd-devel will solve the apxs problem.
  4. yum install epel-release will add the epel

After all the effort, yum install -y mod_wsgi actually will do the work, some how pip install mod_wsgi and build from source failed me so bad.

Again, working with Python from a brand new CentOS is not as easy as you imagine, a few pitfalls that you might need to watch out. First, install zlib-devel zlib zlib-static if possible and then install Python2.7 from source, then install the corresponding pip version which is 2.7 by using the Then install virtualenv…etc.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s