How can I get mod_wsgi working on Mac?

2020-06-03 06: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.

9条回答
狗以群分
2楼-- · 2020-06-03 06:54

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.

查看更多
你好瞎i
3楼-- · 2020-06-03 06:58

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.

查看更多
走好不送
4楼-- · 2020-06-03 06:59

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
查看更多
做自己的国王
5楼-- · 2020-06-03 07:04

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
查看更多
我命由我不由天
6楼-- · 2020-06-03 07:07

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.

查看更多
爷的心禁止访问
7楼-- · 2020-06-03 07:09

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

查看更多
登录 后发表回答