macos 如何让 mod_wsgi 在 Mac 上工作?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4341769/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 07:23:47  来源:igfitidea点击:

How can I get mod_wsgi working on Mac?

apachemacosversion-controlmercurial

提问by emurad

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.

几个小时以来,我一直在尝试在 Mac 上安装最新版本的 mod_wsgi (3.3)。我在 Snow Leopard 上,我有系统附带的 Apache (Apache/2.2.15) 和 Python 2.6.1 (r261:67515) 版本。

  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 :(

  1. 我从http://code.google.com/p/modwsgi/downloads/detail?name=mod_wsgi-3.3.tar.gz下载了 mod_wsgi-3.3.tar.gz

  2. 提取文件并通过终端执行以下操作:

    ./configure make sudo make install

  3. 我将 LoadModule wsgi_module modules/mod_wsgi.so 添加到我的 httpd.conf。

  4. 通过从控制面板禁用和启用 Web 共享来重新启动 Apache。

  5. localhost 停止工作,直到我删除添加的行 httpd.conf :(

Please help. Thanks in advance.

请帮忙。提前致谢。

回答by Matthew Schinckel

I use the homebrewinstalled version of mod_wsgi. That gives me a universal version of mod_wsgithat works with the vanilla apache.

我使用自制软件安装的mod_wsgi. 这给了我一个适用mod_wsgi于 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

回答by Paul Whitehurst

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

您遇到的问题是 mod_wsgi.so 的路径。在 OS X 上,适当的行是

LoadModule wsgi_module        libexec/apache2/mod_wsgi.so

回答by ChaitanyaBhatt

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

我必须先运行以下命令才能安装 mod_wsgi

brew tap homebrew/apache

And then run

然后运行

brew install mod_wsgi

回答by Paul C

On OS X 10.8 Mountain Lion, brew install mod_wsgifails. This answer on stackexchangesuggests 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.

在 OS X 10.8 Mountain Lion 上,brew install mod_wsgi失败。stackexchange 上的这个答案表明 XCode 工具链的位置已经改变。它解决了我的问题,并希望能帮助其他在 10.8 上尝试安装 mod_wsgi 的人。

回答by BartoNaz

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

我也遇到了这个错误,但我不想使用 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

在我的情况下,问题的原因是用于 mod_wsgi 的 python 框架配置错误,可以通过
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.

就我而言,它指向 Python 2.7 框架,而我使用的是 Python 3.3,我
python -> /usr/bin/python
也指向了 Python 3.3 版本。

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

为了解决这个问题,我删除了已经安装的/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

然后使用命令重新配置 mod_wsgi:
./configure --with-python=/usr/bin/python --disable-framework
sudo make
sudo make install

This should work fine. But in my case after executing makecommand 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.

这应该可以正常工作。但就我而言,在执行make命令后,我收到了关于不存在的 Python 框架文件夹的警告。所以我检查了我的 Python 框架文件夹的真实路径是什么,并在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

由:
-L/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/config
改为
-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

如果它不起作用,检查 Apache 模块的好方法是:
apachectl -M

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

如果某个模块导致错误,它将打印出来。

回答by Samer s Salib

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

使用最新的 Mac OS 和最新的 HomeBrew,HomeBrew 上不提供该软件包。

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

但是,如果您在 Mac 上安装并配置了 Python3 和 Pip3,则可以使用以下命令加载包:

pip3 install mod_wsgi

回答by user3552549

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

Mac OS X 自带 apache 2,安装 mod_wsgi 只需安装 homebrew 并运行以下命令。

*brew install homebrew/apache/mod_wsgi*

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

转到apache2/modules/
在此之后搜索 mod_wsgi.so转到apache2/conf/并执行

*sudo vim http.conf* 

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

并添加以下行
LoadModule wsgi_module modules/mod_wsgi.so

回答by David Capella

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

即使使用不同人的建议,我也无法让 mod_wsgi 正常工作,但它不起作用,所以我最终使用了这个网站: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)

  1. 下载了 mod_wsgi 4.5.15 文件

  2. 在我喜欢的位置打开文件

  3. 转到终端中的文件夹位置

  4. 做了python3 setup.py install(或 python,如果你使用不同的版本)

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

我有一个 MacBook Pro 版本 10.12.5,以防它对任何人有帮助。

回答by firestoke

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

我写了两篇关于如何在 Mac OS 和 Windows 中安装 Apache + MySQL + Python 的教程。也许你可以看看。

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

【教程】Mac OS 安装Apache + MySQL + Python
http://fstoke.me/blog/?p=3583

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

【教程】Windows下安装Apache + MySQL + Python
http://fstoke.me/blog/?p=3600