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

This part of the PHP documentation says that I should be able to make a small, fake server to serve up some local .php files in a folder using

php -S localhost:8000

. But when I try that I get the following error:

Usage: php [options] [-f] <file> [--] [args...]
       php [options] -r <code> [--] [args...]
       php [options] [-B <begin_code>] -R <code> [-E <end_code>] [--] [args...]
       php [options] [-B <begin_code>] -F <file> [-E <end_code>] [--] [args...]
       php [options] -- [args...]
       php [options] -a

What am I doing wrong?

share|improve this question
Which version are you using php -v? – quanta Sep 26 '12 at 3:28
@quanta PHP 5.3.10-1ubuntu3.4 Thanks, the perfect question. – isomorphismes Sep 26 '12 at 3:32
As of PHP 5.4.0, the CLI SAPI provides a built-in web server. – quanta Sep 26 '12 at 3:33
The very first sentence of the documentation you linked to states: "As of PHP 5.4.0, the CLI SAPI provides a built-in web server". I suggest you read more carefully next time. – John Gardeniers Sep 26 '12 at 3:37
up vote 1 down vote accepted

You need to be using at least PHP 5.4 to do this. If you're using a lower version, it won't work.

share|improve this answer
Thanks! That was definitely my error. – isomorphismes Sep 26 '12 at 3:34

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.