10
votes

I have been trying to install the latest version of mod_wsgi (3.3) since hours on my Mac. I'm on Snow Leopard and I have the versions of Apache (Apache/2.2.15) and Python 2.6.1 (r261:67515) that come with the system.

  1. I downloaded mod_wsgi-3.3.tar.gz from http://code.google.com/p/modwsgi/downloads/detail?name=mod_wsgi-3.3.tar.gz

  2. Extracted the file and executed the following through terminal:

    ./configure make sudo make install

  3. I added LoadModule wsgi_module modules/mod_wsgi.so to my httpd.conf.

  4. Restarted Apache by disabling and enabling Web Sharing from the control panel.

  5. localhost stops working until I remove the line I added httpd.conf :(

Please help. Thanks in advance.

9

9 Answers

11
votes

I use the homebrew installed version of mod_wsgi. That gives me a universal version of mod_wsgi that works with the vanilla apache.

➔  file `brew list mod_wsgi`
/usr/local/Cellar/mod_wsgi/3.2/libexec/mod_wsgi.so: Mach-O universal binary with 2 architectures
/usr/local/Cellar/mod_wsgi/3.2/libexec/mod_wsgi.so (for architecture x86_64):   Mach-O 64-bit bundle x86_64
/usr/local/Cellar/mod_wsgi/3.2/libexec/mod_wsgi.so (for architecture i386): Mach-O bundle i386
7
votes

The problem you had was the path to mod_wsgi.so. On OS X the appropriate line is

LoadModule wsgi_module        libexec/apache2/mod_wsgi.so
5
votes

I had to first run the below command to get mod_wsgi installed

brew tap homebrew/apache

And then run

brew install mod_wsgi
5
votes

With the latest Mac OS and most recent HomeBrew, the package isn't available on HomeBrew.

However, if you have Python3 and Pip3 installed and configured on your Mac, you can load the package using:

pip3 install mod_wsgi
4
votes

On OS X 10.8 Mountain Lion, brew install mod_wsgi fails. This answer on stackexchange suggests the location of the XCode toolchain has changed. It fixed my problem and hopefully helps other people who end up here on 10.8 trying to install mod_wsgi.

3
votes

I also encountered this error but I didn't want to use brew.

In my case the cause of the problem was in misconfiguration of python framework used for mod_wsgi that can be checked by
otool -L /usr/libexec/apache2/mod_wsgi.so

In my case it pointed to Python 2.7 framework while I was using Python 3.3 and my
python -> /usr/bin/python
also pointed to python 3.3 version.

In order to fix this, I removed already installed /usr/libexec/apache2/mod_wsgi.so .

Then reconfigured mod_wsgi with command:
./configure --with-python=/usr/bin/python --disable-framework
sudo make
sudo make install

This should work fine. But in my case after executing make command I've got a warning about non existing Python framework folder. So I checked what was the real path of my Python framework folder and replaced it in the Makefile under LDFLAGS.

Changed from:
-L/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/config
to
-L/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/config-3.3m

Good way to check the Apache modules if it doesn't work, is:
apachectl -M

If some module causes the error, it will print it.

0
votes

I wrote two tutorials about how to install Apache + MySQL + Python in Mac OS and Windows. Maybe you can take a look.

[Tutorial] install Apache + MySQL + Python on Mac OS
http://fstoke.me/blog/?p=3583

[Tutorial] install Apache + MySQL + Python on Windows
http://fstoke.me/blog/?p=3600

0
votes

Mac OS X comes with apache 2, to install mod_wsgi just install homebrew and run the following command.

*brew install homebrew/apache/mod_wsgi*

go to apache2/modules/ and search for mod_wsgi.so
after this goto apache2/conf/ and do

*sudo vim http.conf* 

and add the following line
LoadModule wsgi_module modules/mod_wsgi.so

0
votes

I was having trouble getting mod_wsgi to work as well even using different peoples advice and it wasn't working, so I finally used this website: https://pypi.python.org/pypi/mod_wsgi

  1. Downloaded the mod_wsgi 4.5.15 file

  2. Opened the file in a location I liked

  3. Went to folder location in terminal

  4. Did python3 setup.py install (or python if you're using a different version)

I have a MacBook Pro Version 10.12.5 in case this helps anyone.