如何让 mod_wsgi 在 Mac 上运行?

发布于 2024-10-06 06:33:11 字数 653 浏览 0 评论 0 原文

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

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

  2. 解压文件并通过终端执行以下命令:

    <代码>./配置 制作 sudo make install

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

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

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

请帮忙。提前致谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

卖梦商人 2024-10-13 06:33:11

我使用 自制 安装版本的 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

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
挽梦忆笙歌 2024-10-13 06:33:11

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

LoadModule wsgi_module        libexec/apache2/mod_wsgi.so

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
梦旅人picnic 2024-10-13 06:33:11

对于最新的 Mac OS 和最新的 HomeBrew,该软件包在 HomeBrew 上不可用。

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

pip3 install mod_wsgi

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
好倦 2024-10-13 06:33:11

我必须首先运行以下命令来安装 mod_wsgi

brew tap homebrew/apache

然后运行

brew install mod_wsgi

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

brew tap homebrew/apache

And then run

brew install mod_wsgi
走野 2024-10-13 06:33:11

在 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.

说谎友 2024-10-13 06:33:11

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

云胡 2024-10-13 06:33:11

以下解决方案适用于 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 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

意中人 2024-10-13 06:33:11

我写了两篇关于如何在 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

很糊涂小朋友 2024-10-13 06:33:11

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

*brew install homebrew/apache/mod_wsgi*

转到 apache2/modules/ 并搜索 mod_wsgi.so
之后转到 apache2/conf/

*sudo vim http.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.

*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

多孤肩上扛 2024-10-13 06:33:11

即使使用不同人的建议,我也无法让 mod_wsgi 正常工作,但它不起作用,所以我最终使用了这个网站: https://pypi.python.org/pypi/mod_wsgi

  1. 下载了 mod_wsgi 4.5.15 文件

  2. 在以下位置打开了该文件我喜欢的位置

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

  4. 是否安装了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

  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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文