Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I started python -m SimpleHTTPServer on one computer on lan and used wget to download php files from it to another. As far as i see, they seem to be downloaded correctly - i got php sources instead of html layout. Why? Is this because this server doesn't execute php? When i was downloading i was worried that i'll download just html layout results instead of php source...

share|improve this question
up vote 4 down vote accepted

Yep, a simple server like Python's doesn't execute PHP. Even something like Apache wouldn't execute PHP either, unless you specifically told it to (which involves installing mod_php).

Technically, as far as the web server is concerned, everything is just a downloadable file unless you (the configurator) tell it otherwise.

share|improve this answer

SimpleHTTPServer module just serves files. To parse the php files you need one of the "big" http servers, for example apache or lighttpd, with the proper module (mod_php) or cgi to parse the php code and give you the html output of it

share|improve this answer

This may work :)

#!/usr/bin/env python
from BaseHTTPServer import HTTPServer
from CGIHTTPServer import CGIHTTPRequestHandler
serve = HTTPServer(("",8080),CGIHTTPRequestHandler)

php file:

<? phpinfo(); ?>

dont forget to chmod +x on the php script.

share|improve this answer
that's for making php script execute? very interesting, +1... – Phil Aug 27 '09 at 19:00
Didn't get it. Where do I write this script? I've done a lot of PHP CGI, but no python CGI, so please tell me how to do it. Thanks. – 0fnt Aug 25 '10 at 4:55
It is possible to instantiate CGIHTTPServer directly, it will execute CGI scripts from the cgi-bin subdirectory by default. – halp Oct 22 '10 at 8:51

Your Answer


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.