如何让 mod_wsgi 在 Mac 上运行?
几个小时以来,我一直在尝试在 Mac 上安装最新版本的 mod_wsgi (3.3)。我使用的是 Snow Leopard,并且拥有系统附带的 Apache (Apache/2.2.15) 和 Python 2.6.1 (r261:67515) 版本。
-
我从 http://code.google.com/p/modwsgi/downloads/detail?name=mod_wsgi-3.3.tar.gz
-
解压文件并通过终端执行以下命令:
<代码>./配置 制作 sudo make install
-
我将 LoadModule wsgi_module module/mod_wsgi.so 添加到我的 httpd.conf。
-
通过从控制面板禁用和启用 Web 共享来重新启动 Apache。
-
localhost 停止工作,直到我删除我添加的 httpd.conf :(
请帮忙。提前致谢。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
我使用 自制 安装版本的
mod_wsgi
。这给了我一个通用版本的mod_wsgi
,它可以与 vanilla apache 一起使用。I use the homebrew installed version of
mod_wsgi
. That gives me a universal version ofmod_wsgi
that works with the vanilla apache.您遇到的问题是 mod_wsgi.so 的路径。在 OS X 上,相应的行是
The problem you had was the path to mod_wsgi.so. On OS X the appropriate line is
对于最新的 Mac OS 和最新的 HomeBrew,该软件包在 HomeBrew 上不可用。
但是,如果您在 Mac 上安装并配置了 Python3 和 Pip3,则可以使用以下命令加载包:
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:
我必须首先运行以下命令来安装 mod_wsgi
然后运行
I had to first run the below command to get mod_wsgi installed
And then run
在 OS X 10.8 Mountain Lion 上,
brew install mod_wsgi
失败。 这个答案on stackexchange 表明 XCode 工具链的位置已更改。它解决了我的问题,并希望能帮助其他在 10.8 上尝试安装 mod_wsgi 的人。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.我也遇到了这个错误,但我不想使用brew。
就我而言,问题的原因是用于 mod_wsgi 的 python 框架配置错误,可以通过
进行检查
otool -L /usr/libexec/apache2/mod_wsgi.so
在我的例子中,它指向 Python 2.7 框架,而我使用的是 Python 3.3 和我的
python-> /usr/bin/python
还指出了 python 3.3 版本。
为了解决这个问题,我删除了已安装的
/usr/libexec/apache2/mod_wsgi.so
。然后使用命令重新配置 mod_wsgi:
./configure --with-python=/usr/bin/python --disable-framework
sudo make
sudo make install
这应该可以正常工作。
但就我而言,执行
make
命令后,我收到了有关不存在的 Python 框架文件夹的警告。因此,我检查了 Python 框架文件夹的真实路径,并将其替换到LDFLAGS
下的 Makefile 中。更改自:
-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
检查 Apache 模块是否不起作用的好方法是:
apachectl -M
如果某个模块导致错误,它将打印它。
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 underLDFLAGS
.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.
以下解决方案适用于 MacOS BigSur 和 Monterey:
从 https://www.macports.org 安装 MacPorts /install.php
sudo port install mod_wsgi
-->安装 apache2、python3安装后 apachectl 位置:
/opt/local/sbin/apachectl
apache2 模块位置:
/opt/local/lib/apache2/modules/
httpd配置位置:
/opt/local/etc/apache2/httpd.conf
将此行添加到 httpd.conf:
LoadModule wsgi_module lib/apache2/modules/mod_wsgi.so
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 thingsapachectl 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
我写了两篇关于如何在 Mac OS 和 Windows 中安装 Apache + MySQL + Python 的教程。
也许你可以看一下。
[教程]在Mac OS上安装Apache + MySQL + Python
http://fstoke.me/blog/?p=3583
【教程】安装 Apache + Windows 上的 MySQL + Python
http://fstoke.me/blog/?p=3600
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
Mac OS X 附带了 apache 2,要安装 mod_wsgi 只需安装 homebrew 并运行以下命令。
转到 apache2/modules/ 并搜索 mod_wsgi.so
之后转到 apache2/conf/ 并
添加以下行
LoadModule wsgi_module 模块/mod_wsgi.so
Mac OS X comes with apache 2, to install mod_wsgi just install homebrew and run the following command.
go to apache2/modules/ and search for mod_wsgi.so
after this goto apache2/conf/ and do
and add the following line
LoadModule wsgi_module modules/mod_wsgi.so
即使使用不同人的建议,我也无法让 mod_wsgi 正常工作,但它不起作用,所以我最终使用了这个网站: https://pypi.python.org/pypi/mod_wsgi
下载了 mod_wsgi 4.5.15 文件
在以下位置打开了该文件我喜欢的位置
转到终端中的文件夹位置
是否安装了python3 setup.py(如果您使用的是不同版本,则为 python)
我有一台 MacBook Pro 版本 10.12。 5 如果这对任何人都有帮助。
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
Downloaded the mod_wsgi 4.5.15 file
Opened the file in a location I liked
Went to folder location in terminal
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.