Tutorial

Installing mod_wsgi on Ubuntu 12.04

Published on July 18, 2012
Installing mod_wsgi on Ubuntu 12.04

Status: Deprecated

This article covers a version of Ubuntu that is no longer supported. If you are currently operate a server running Ubuntu 12.04, we highly recommend upgrading or migrating to a supported version of Ubuntu:

Reason: Ubuntu 12.04 reached end of life (EOL) on April 28, 2017 and no longer receives security patches or updates. This guide is no longer maintained.

See Instead:
This guide might still be useful as a reference, but may not work on other Ubuntu releases. If available, we strongly recommend using a guide written for the version of Ubuntu you are using. You can use the search functionality at the top of the page to find a more recent version.

About mod_wsgi

mod_wsgi is a simple and easy to setup tool that serves python web apps from Apache server. It is also one of the recommended ways of getting Django into production. In this article, we will be discussing the installation and set up of mod_wsgi with the Apache server.

Prerequisites:

This article is the second in a series of 3. The previous article covers installing Django on the server. I recommend looking over the previous article before starting this one.

Since we are focusing on mod_wsgi for installing Apache module so first of all we need an installed Apache server. Use below command for installing required Apache components.

sudo aptitude install apache2 apache2.2-common apache2-mpm-prefork apache2-utils libexpat1 ssl-cert

Once all of the components of apache have installed, access your droplet IP in the browser and make sure that you see the default Apache page that says ‘It Works’. If you don’t get this page , it may be for one of several reasons

  1. Apache is not installed correctly
  2. There is an existing installation of Apache
  3. Iptables are blocking the port number 80

Check the issue and make sure that Apache is working properly before moving to the next step.

Installing mod_wsgi From Aptitude:

It is very easy to install mod_wsgi with the help of aptitude.

 sudo aptitude install libapache2-mod-wsgi

Restart Apache to get mod_wsgi to work.

 sudo service apache2 restart

How to Install mod_wsgi from Source

Since the code is constantly changing, we can ensure that we install the latest version of mod_wsgi by installing it from the source.

mkdir ~/sources
cd ~/sources
wget http://modwsgi.googlecode.com/files/mod_wsgi-3.3.tar.gz 
tar xvfz mod_wsgi-3.3.tar.gz

Before continuing further, we will grab two different packages from aptitude.

 sudo aptitude install python-dev apache2-prefork-dev

If you are using worker MPM with Apache then replace apache2-prefork-dev with apache2-threaded-dev.

After that process has completed, you can go ahead and configure and install mod_wsgi.

 cd mod_wsgi-3.3
./configure
make
sudo make install

See More

Once you have mod_wsgi installed, you can see how to use it to serve applications in the next article.

By Etel Sverdlov

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the authors

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
2 Comments


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

This comment has been deleted

    This comment has been deleted

      Try DigitalOcean for free

      Click below to sign up and get $200 of credit to try our products over 60 days!

      Sign up

      Join the Tech Talk
      Success! Thank you! Please check your email for further details.

      Please complete your information!

      Featured on Community

      Get our biweekly newsletter

      Sign up for Infrastructure as a Newsletter.

      Hollie's Hub for Good

      Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

      Become a contributor

      Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

      Welcome to the developer cloud

      DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

      Learn more