让 apache 在 mac 上运行 python
所以我有一台新的 mac,我试图让它用 mod_python、mod_wsgi 和 django 运行 apache。我有一个测试 test.py 仅包含: #!/usr/bin/python print "内容类型:text/html" 打印 打印“” 打印 ”” print "" 打印“测试页” print ""
我刚刚下载了 xcode4,使用 macports 通过这些网站上提供的步骤安装 apache、php5 和 mod_wsgi: http://www.phpied.com/installing-php-and-apache-on-mac-osx-that-was-pretty-easy/" 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 制作 sudo make install
然后使用 LoadModule blah module/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
任何人都知道出了什么问题,或者知道如何在 Mac 上使用 xcode 4 执行此操作的教程(是的,在我的自 xcode 4 取消了一些架构支持并因此使某些模块过时以来,实际上相关的研究?
So i have a new mac and i'm trying to get it to run apache with mod_python, mod_wsgi, and django. I have a test test.py that simply contains:#!/usr/bin/python
print "Content-type: text/html"
print
print "<html><head>"
print ""
print "</head><body>"
print "Test Page"
print "</body></html>"
I've just downloaded xcode4, used macports to install apache, php5, and mod_wsgi via the step provided on these sites:
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/
for some reason mod_python wouldn't work so i downloaded the latest source code from the svn and doing the standard ./configure --with-apxs=/opt/local/apache2/bin/apxs
make
sudo make install
and then configuring httpd.conf with the LoadModule blah modules/blah.so
when i started up apache with
sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper start
and navigated to test.py in my browser and I saw the entire file in plain text with i know that isn't right.
I turned on python debug in httpd.conf and saw this when i navigated to test.py again this popped out:
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
anyone know what is wrong or know of a tutorial on how to do this on a mac with xcode 4(yes, in my research that is actually relevant since xcode 4 did away with some architecture support and thus rendered some modules outdated)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如 @ignatio-vazquez-abrams 所指出的,mod_python 已被弃用,但如果您打算使用它,您可能需要查看 自制。安装 Homebrew 后,您可以在终端中运行
brew install mod_python
。安装后,您将看到一条有关将已编译的 mod 添加到 Apache 配置的注释(以及弃用警告)。As @ignatio-vazquez-abrams noted, mod_python is deprecated, but if you're set on using it, you may want to check out Homebrew. Once Homebrew is installed, you can run
brew install mod_python
in Terminal. After installation, you'll see a note about adding the compiled mod to your Apache config (as well as a deprecation warning.)