开发者

Portable Python - getting Django to work on Apache?

I am using Windows 7, Apache 2.28 and Web Developer Server Suite for my server.

All files are stored under C:/www/vhosts

I downloaded Portable Python 2.7 from http://www.portablepython.com/ and have installed it to

C:/www/portablepython

I'm trying to find mod_wsgi to get it to work with 2.7 - but how can I do this?

The reason I'm doing all this is to get a basic site running that uses Python coding, with a view to using Django, in the same way that http://www.heart.co.uk/westmids/ or http://www.capitalfm.com/birmingham do. Obviously my site won't be as advanced as theirs, but you get the gist of it; I'm using Python/Django as a sort of CMS for a news/articles website.

In any case, here's my code from C:/www/vhosts/localhost/testing.py:

#!/www/portablepython
print "Content-type: text/html"
print
print "<html><head>"
print ""
print "</head><body>"
print "Hello."
print "</body></html>"

This generates a 403 Forbidden error, i.e.:

You don't have permission to access /testing.py on this server.

I followed http://code.google.com/p/modwsgi/wiki/InstallationOnWindows but renamed modwsgi-version-number-datedownload开发者_如何学C.so to modwsgi.so so did that cause the error?

What do I need to do to prevent this re-occurring?

I used the Portable version for testing purposes, thinking that I can just delete the folder, and I can install again if necessary without adding to environment variables (I think portable ones do this, correct me if I'm wrong)?

What, if any changes do I need to make? Do I need to make them to the vhosts in httpd-vhosts.conf [my virtual hosts] or elsewhere?

Any help is appreciated; I'll post more as this situation develops.


The script you have at C:/www/vhosts/localhost/testing.py is a CGI script and not a WSGI script. Follow the instructions for configuring mod_wsgi and what a WSGI script file for hello world should look like at:

http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide


also, you should look into using a system install of python from python.org and pip+distribute+virtualenv to keep contained python environments for your different sites. This will give you maximum portability.


Here is a sample - PortableWinPy - how to get Django work with Apache and mod_wsgi, in portale way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜