【问题标题】:getting apache to run python on a mac让 apache 在 mac 上运行 python
【发布时间】:2011-10-04 21:49:01
【问题描述】:

所以我有一个新的 mac,我正试图让它用 mod_python、mod_wsgi 和 django 运行 apache。我有一个测试 test.py 只包含: #!/usr/bin/python print "Content-type: text/html" print print "<html><head>" print "" print "</head><body>" print "Test Page" print "</body></html>"

我刚刚下载了 xcode4,使用 macports 通过这些网站上提供的步骤安装了 apache、php5 和 mod_wsgi: http://www.phpied.com/installing-php-and-apache-on-mac-osx-that-was-pretty-easy/ http://heisel.org/blog/2009/09/25/mod-wsgi-mac/ 由于某种原因 mod_python 不起作用,所以我从 svn 下载了最新的源代码并执行标准 ./configure --with-apxs=/opt/local/apache2/bin/apxs make sudo make install

然后使用 LoadModule blah modules/blah.so 配置 httpd.conf

当我启动 apache 时

sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper start

并在我的浏览器中导航到 test.py,我以纯文本形式看到了整个文件,我知道这是不对的。 我在 httpd.conf 中打开了 python 调试,当我再次导航到 test.py 时看到了这个:

MOD_PYTHON ERROR

ProcessId:      93626
Interpreter:    'dfelsmanmpx6.blah.blah'

ServerName:     'dfelsmanmpx6.blah.blah'
DocumentRoot:   '/Users/me/folder/workspace/'

URI:            '/test.py'
Location:       None
Directory:      '/'
Filename:       '/Users/me/folder/workspace/test.py'
PathInfo:       ''

Phase:          'PythonHandler'
Handler:        'text'

Traceback (most recent call last):

  File "/Library/Python/2.6/site-packages/mod_python/importer.py", line 1537, in HandlerDispatch
    default=default_handler, arg=req, silent=hlist.silent)

  File "/Library/Python/2.6/site-packages/mod_python/importer.py", line 1202, in _process_target
    module = import_module(module_name, path=path)

  File "/Library/Python/2.6/site-packages/mod_python/importer.py", line 304, in import_module
    return __import__(module_name, {}, {}, ['*'])

ImportError: No module named text

任何人都知道有什么问题或知道如何在带有 xcode 4 的 mac 上执行此操作的教程(是的,在我的研究中这实际上是相关的,因为 xcode 4 取消了一些架构支持,因此使一些模块过时了) ?

【问题讨论】:

  • 如果没有 mod_python,我将如何做到这一点?只是让 test.py 在 apache 中运行。
  • 要么使用 CGI,要么编写 WSGI 脚本。
  • 我使用 gunicorn 有多种 WSGI 选项……

标签: python apache macos macports apache-modules


【解决方案1】:

正如@ignatio-vazquez-abrams 所说,mod_python 已被弃用,但如果您打算使用它,您可能需要查看Homebrew。安装 Homebrew 后,您可以在终端中运行 brew install mod_python。安装后,您会看到一条关于将已编译的 mod 添加到 Apache 配置的说明(以及弃用警告。)

【讨论】:

  • 如果不使用 mod_python 我该怎么做呢?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-07-11
  • 1970-01-01
  • 2012-02-12
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多