Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

im getting a bit stuck regarding options for running python scripts on my server. From the research ive done so far, i can see i need to modify apache slightly to run python scripts, by using either mod_wsgi or mod_python. Two issues i have:

mod_python doesnt appear to be maintained anymore (last release, 2007) mod_wsgi appears to require modification of my httpd.conf file on a per application basis.

What im wanting to know, is there a way of getting python scripts to run in the same way as php, i.e. just by going to index.py etc... or is it more involved than that?

At present im just trying to set it up on my xampp install.

Any help would be appreciated.

share|improve this question

migrated from stackoverflow.com Apr 28 '10 at 15:41

This question came from our site for professional and enthusiast programmers.

4 Answers 4

up vote 3 down vote accepted

I would stick with mod_wsgi. It seems more actively maintained. There are good docs for it on the project page. If you want mod_wsgi to handle your .py scripts, you can add something like:

AddHandler wsgi-script .py

In the appropriate context in Apache. There are configuration instructions and installation instructions that should really help.

share|improve this answer

You can simply run Python scripts as CGI, if you really want - just add .py as a CGI handler in your Apache conf:

AddHandler cgi-script .cgi

Note that this is a very bad idea other than for very low-usage applications, as it is slow and inefficient. You really are much better off going with mod_wsgi.

share|improve this answer

One can do a once off configuration of mod_wsgi which then allows you to add applications without needing to go back and modify the configuration again. As someone else mentioned, this revolves around using AddHandler instead of WSGIScriptAlias. See:

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

BTW, you probably want to look at a higher level framework or library of WSGI components rather than work with raw WSGI. For example, see:

http://werkzeug.pocoo.org/

http://flask.pocoo.org/

There are lots of others referenced at:

http://www.wsgi.org/wsgi/Frameworks

share|improve this answer

I posted simple tutorial of how to install python for XAMPP on my blog. Let me know if you found it useful.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.