PHP 5.4 added a built-in web server to the command-line interface (CLI) so developers could run and test PHP applications without first configuring a separate web server. Start it with php -S localhost:8000 from the directory you want to serve. It is a development convenience, not a production server: PHP’s manual warns against using it on a public network, and a blocked request can stall other requests.
What PHP 5.4’s built-in web server does
The server runs through PHP’s CLI SAPI and serves a PHP application locally, making quick development, testing, and controlled demonstrations easier. The PHP 5.4.0 release announcement described the feature as “Built-in webserver in CLI mode to simplify development workflows and testing.” The implementation proposal likewise cited the friction of configuring a traditional web server solely for development and introduced the CLI -S option.
PHP 5.4.0 was released on March 1, 2012. The feature’s intended convenience did not make it a full-featured or production web server. PHP 5.4.0 release announcement · Built-in web server RFC
How to start PHP’s built-in web server
Open a terminal in the project directory and run:
php -S localhost:8000
The server uses the current directory as its document root by default. Visit http://localhost:8000 in a browser. Stop the server with Ctrl+C in the terminal where it is running.
#1 Best Overall
Set a different document root with -t
To serve files from a subdirectory such as public/, use:
php -S localhost:8000 -t public/
Here, -t specifies the document root. Run the command from the project directory, adjusting the path if the directory is elsewhere.
Rank #2
Use a router script for application routes
You can pass a PHP file after the server options to make it a router script. The server invokes it for each request. If the script returns false, PHP falls back to its normal handling of the requested resource; otherwise, the script’s output is returned. This lets an application route requests through PHP while allowing selected files, such as static assets, to be served directly.
php -S localhost:8000 -t public/ router.php
The exact behavior of details such as index lookup and PATH_INFO has changed across PHP versions. The current manual also describes later additions, including multiple workers in PHP 7.4 and a path-lookup change in PHP 8.4; neither should be mistaken for a PHP 5.4 feature. For version-specific behavior and router examples, see the PHP built-in web server manual.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchCan PHP’s built-in server handle multiple requests at once?
In the PHP 5.4-era model, it runs as a single-threaded process. The PHP manual states: “The web server runs only one single-threaded process, so PHP applications will stall if a request is blocked.” A request waiting on slow or stuck work can therefore prevent other requests from progressing until it completes. This is a poor fit for serving concurrent public traffic.
Can you use PHP’s built-in server in production?
No. The PHP manual says the server is intended to aid application development, testing, and demonstrations in controlled environments; it is “not intended to be a full-featured web server” and “should not be used on a public network.” Do not expose it as a public-facing service or treat it as a production deployment setup.
Rank #4
The manual shows php -S 0.0.0.0:8000 as an example of listening on all network interfaces, but that setting does not make the server safe for public use. The same manual warning against public-network use applies.
PHP 5.4 is unsupported
PHP 5.4 reached end of life on September 3, 2015. Its last scheduled release was PHP 5.4.45, announced that day; the PHP development team reported fixing 10 security-related issues in that release. PHP’s unsupported-branches page lists both the end-of-life date and final release. Anyone maintaining a PHP 5.4 installation should plan migration to a supported PHP branch. These PHP project sources do not establish the security status of any particular third-party fork or privately maintained build.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsPHP 5.4.45 release announcement · PHP unsupported branches
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

