How can I get mod_wsgi working on Mac?
Asked Answered
C

10

12

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.

Carlina answered 3/12, 2010 at 1:45 Comment(0)
D
11

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
Discommode answered 3/12, 2010 at 3:22 Comment(3)
This is out of date.Erythroblastosis
Quite possibly.Discommode
Yeah, here is a possible most current solution: https://mcmap.net/q/892080/-how-can-i-get-mod_wsgi-working-on-macErythroblastosis
A
7

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
All answered 8/12, 2010 at 15:47 Comment(0)
E
7

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
Erythroblastosis answered 3/4, 2019 at 20:23 Comment(0)
R
5

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

brew tap homebrew/apache

And then run

brew install mod_wsgi
Rime answered 9/9, 2015 at 17:6 Comment(1)
This is now out of date: "Warning: homebrew/apache was deprecated. This tap is now empty as all its formulae were migrated."Mintz
W
4

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.

Willenewillet answered 28/1, 2013 at 20:42 Comment(0)
C
3

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.

Cleaning answered 14/5, 2013 at 16:59 Comment(1)
Can't you use the WSGIPythonPath directive to tell the module which Python to use?Ruperto
C
1

The below solution works for me for MacOS BigSur and Monterey:

Install MacPorts from https://www.macports.org/install.php

sudo port install mod_wsgi --> installs apache2, python3 among other things

apachectl location after install: /opt/local/sbin/apachectl

apache2 modules location: /opt/local/lib/apache2/modules/

httpd config location: /opt/local/etc/apache2/httpd.conf

Add this line to httpd.conf: LoadModule wsgi_module lib/apache2/modules/mod_wsgi.so

Candleberry answered 17/7, 2022 at 3:18 Comment(0)
M
0

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

Magdalen answered 28/6, 2014 at 3:13 Comment(0)
E
0

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

Elspeth answered 9/4, 2016 at 15:22 Comment(0)
B
0

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.

Beneficiary answered 19/6, 2017 at 9:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.