How can I get mod_wsgi working on Mac?

前端 未结 9 1942
眼角桃花
眼角桃花 2021-02-08 15:53

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

相关标签:
9条回答
  • 2021-02-08 16:23

    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.

    0 讨论(0)
  • 2021-02-08 16:25

    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 讨论(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

    0 讨论(0)
  • 2021-02-08 16:26

    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 讨论(0)
  • 2021-02-08 16:35

    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
    
    0 讨论(0)
  • 2021-02-08 16:36

    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
    
    0 讨论(0)
提交回复
热议问题