I need help setting up a local Apache2 to run Python. Got it to work just fine with html, php and mysql on my Mac running Mountain Lion.
Python running. Installed mod_wsgi through MacPorts and checked that it got loaded by Apache after adding the following to the httpd.conf:
LoadModule wsgi_module modules/mod_wsgi.so
<Directory /opt/local/apache2/htdocs>
AddHandler wsgi-script .py
Options +ExecCGI
Order deny,allow
Allow from all
</Directory>
Put my index.py file into htdocs:
def application(environ, start_response):
status = '200 OK'
output = 'Hello World!'
response_headers = [('Content-type', 'text/plain'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
Gave chmod 777 permission to whole path /opt/local/apache2/htdocs/index.py
No matter what I do, I keep getting the "Forbidden. You don't have permission to access /index.py on this server." when going to localhost/index.py.
The Apache error-log says:
[Thu Aug 30 17:46:46 2012] [error] [client 127.0.0.1] Options ExecCGI is off in this directory: /opt/local/apache2/htdocs/index.py, referer: http://localhost/
How can I resolve this permission issue? What is Options ExecCGI?