5

On Ubuntu 14.04 I've upgraded to Python 2.7.11 using apt-get, and installed mod_wsgi using sudo pip install mod_wsgi. Now, how do I enable mod_wsgi in Apache? The install instructions (https://modwsgi.readthedocs.org/en/develop/user-guides/quick-installation-guide.html) only mention building from source..

I've figured out that mod_wsgi-py27.so is in /usr/local/lib/python2.7/dist-packages/mod_wsgi/server, but not sure if I'm supposed to do the rest of the installation by manually editing apache config files..?

This is going to be a production machine that is managed through Puppet by the ops team (iow, it doesn't sound like mod_wsgi-express would be the way to go, but maybe I'm wrong..?)

Update: I might have gotten it to work by apt-get installing the (old) system version, and then hand-editing /etc/apache2/mods-available/wsgi.load to point to the pip-installed (new) mod_wsgi-py27.so. Not sure if this is copacetic, however everything in wsgi.conf is commented out by default so maybe..?

thebjorn
  • 22,303
  • 7
  • 72
  • 116
  • You need to enable the module in apache. You can see this example with mod_rewrite. http://stackoverflow.com/questions/869092/how-to-enable-mod-rewrite-for-apache-2-2 – alpha1554 Mar 01 '16 at 13:45
  • Yes, `a2enmod mod_wsgi` is the normal way to enable apache modules on Ubuntu/Debian, but that requires the .load and .conf files to be present in /etc/apache2/mods-available first.. – thebjorn Mar 01 '16 at 13:52
  • You could just install mod_wsgi the usual way from the repository `sudo aptitude install libapache2-mod-wsgi`. – alpha1554 Mar 01 '16 at 16:21
  • 1
    @alpha1554 no, can't do that since that module is (a) version 3.4, which is an insecure version, and (b) it is compiled with Python 2.7.6 -- which means it would run a different Python from what I just installed. – thebjorn Mar 01 '16 at 18:18

1 Answers1

1

While mod_wsgi-express might be great and is highly recommended for the simple set-up, it does have a setup-server command:

mod_wsgi-express setup-server ./my_wsgi.py

That creates a config directory with apachectl, etc. Have a look in that directory to see which httpd.conf directives should be necessary.

serv-inc
  • 29,557
  • 9
  • 128
  • 146