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)?
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.)
精彩评论