Installing python, django and any other stuffs that needed to make it work are beyond the scope of this note since I think that there's no big challenges to make them work perfectly, especially in development environment. Challenges will occur as developers run into production.
My resources:
Windows XP Pro SP3
Apache 2.2.17 (WAMP 2.1)
mod_wsgi
Python 2.7
My apache's document root is located at: c:/wamp/www. I created a directory named 'wsgi', so the full path is: c:/wamp/www/wsgi. I assumed that it would be accessed via http://localhost/wsgi/.
I added a file called dispatcher.py inside the wsgi directory. Here's a piece of code within 'dispatcher.py':
def application(environ, start_response):
status = '200 OK'The next step is to modify apache configuration (httpd.conf) in order to make it recognize python applications. The following lines are appended to httpd.conf and require that mod_wsgi has been installed in c:\wamp\bin\apache\Apache2.2.17\modules\mod_wsgi.so.
output = 'Hello World!'
response_headers = [('Content-type', 'text/plain'), ('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
LoadModule wsgi_module modules/mod_wsgi.so
WSGIScriptAlias /wsgi "c:/wamp/www/wsgi/dispatcher.py"
Allow Override None
Options None
Order deny,allow
Allow from all
</Directory>
</Directory>
Well, It's just a simple code to print 'Hello World' to make sure that mod_wsgi + apache is working seamlessly and we are ready for the next adventures.
thank you so much ;)
ReplyDeleteHi,
ReplyDeleteThanks for the post on this!
I have Wampserver installed and it's working properly. I also have Python and Django both installed.
I downloaded mod_wsgi-win32-ap22py27-3.3.so - Apache 2.2 / Python 2.7, renamed it to mod_wsgi.so and copied it to C:\wamp\bin\apache\Apache2.2.11\modules.
I added dispatcher.py to my wsgi folder located at C:\wamp\www\wsgi, but when I add:
LoadModule wsgi_module modules/mod_wsgi.so
WSGIScriptAlias /wsgi "c:/wamp/www/wsgi/dispatcher.py"
Allow Override None
Options None
Order deny,allow
Allow from all
to apache's httpd.conf file, my Wampserver tray menu goes yellow, and gives me an error message when I try to put it online.
The error I get says:
Aestan Tray Menu
Could not execute menu item (internal error)
[Exception] Could not perform service action: the service has not been started
Wampserver 2.0
Apache 2.2.11
PHP 5.3.0
MySQL 5.1.36
Any ideas?
please check your apache's error.log first to get more detail information about the problems.
ReplyDeleteThanks for this post.
ReplyDeleteIn my case I had to use the following code, just place it at the end of your httpd.conf:
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
ServerAdmin admin@example.com
DocumentRoot c:/wamp/www
<Directory c:/wamp/www>
Order allow,deny
Allow from all
</Directory>
WSGIScriptAlias /wsgi c:/wamp/www/wsgi/dispatcher.py
<Directory c:/wamp/www/wsgi>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
wowlo wolo ti :p
ReplyDeleteI am having the same issue as Matthew Edward. I am running slightly later version of WAMP (v2.2), but issue remains the same. Nothing gets written in error logs as apache fails to start completely unless I comment out #LoadModule wsgi_module modules/mod_wsgi.so
ReplyDeleteAny clues?
I also get the same error as Matthew and Slavko. and nothing is in the error log..
ReplyDelete