Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 just found this awesome tip in the Apple SE:

Start a quick webserver from any directory:

python -m SimpleHTTPServer 8000

Is there a way to have this parse php scripts, or is this for html-only sites?

share|improve this question
up vote 12 down vote accepted

I just came across this answer from StackOverflow.

Basically, python's webserver is not configured to run php files by default, but instead of trying to reconfigure python's web server, you can simply run php's web server, which works almost exactly like python's simplehttpserver, with

php [options] -S <addr>:<port> [-t docroot]


php -S -t .

or simply

php -S

to use the current working directory.

Edit: Forgot to mention, it appears to be necessary to run this as root if you need to use port 80, but this is not necessary if you specify a higher port number like 8080. Thanks for pointing that out, Mike Houston!

share|improve this answer
Apparently, good things do come to those who wait :) Didn't even realize php had that functionality. Thanks! – eykanal Jul 21 '14 at 19:19
@eykanal It's a new feature in PHP 5.4. :-) – ceejayoz Jul 22 '14 at 21:54
You need to run as root if you want to use port 80, but if you choose a higher port number (e.g. 8080) you should be fine as a standard user. – Mike Houston Dec 25 '14 at 20:06
Didn't know we have php on OSX by default. This is great. – Aero Windwalker Jan 4 '15 at 12:08
It is also worth mentioning that the PHP web server is only for development purposes.. It does not have the extended features of say apache.. So for development yes.. For live sites NO! – Mayhem Jul 30 '15 at 7:01

The SimpleHTTPServer python library, called in that way, will only serve files, and will not interpret PHP (or python, for that matter). However, you can get it to serve whatever you want (including PHP - check out CGIHTTPServer) with some custom python wrapped around it.

share|improve this answer
So, as someone who doesn't know a stitch of python and doesn't really want to learn it right now, the answer is "no"? – eykanal Dec 7 '11 at 3:10
That's a "no", correct. – Bill Weiss Dec 7 '11 at 4:39
Thanks to both of you. – eykanal Dec 7 '11 at 21:20

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.