How to Run PHP Built-in Webserver on Windows?
Today we will discuss on how to run PHP built-in webserver on windows and let you run your PHP script without using xampp or apache, although PHP built in webserver it’s not that robust but it’s great to handle some development, so let’s get started.
The PHP built-in webserver installation instruction
Note: you may skip this part if you have installed already PHP 5.4 or (PHP 5.4.8 as what I used for this example)
-
1. Go to Windows for PHP download site http://windows.php.net/download
- Go ahead and download first the Visual C++ runtime

For x86:
http://www.microsoft.com/downloads/details.aspx?FamilyID=9B2DA534-3E03-4391-8A4D-074B9F2BC1BF- once your download is done, install it.
- 2. Download PHP 5.4.8 VC9 x86 Thread Safe
- 3. Extract it to C:\PHP5.4
- 4. There is two(2) ini settings available on the package php.ini-development and php.ini-production for this tutorial we will use php.ini-development, all you need to do is rename it from php.ini-development to php.ini.
Now check that we properly installed PHP on our local machine run ‘cmd’ go to the folder using windows command line ‘cd C:\PHP5.4′ (without quote) and type ‘php –version’ (without quote), If you successfully installed the PHP on your machine you’ll see version of it.

Create a folder inside PHP directory name ‘public_html’

Back to command line type ‘cd public_html’ and ‘C:\PHP5.4/php -S localhost:8080′ (Actually you can use any port you like. But for this testing purposes we will use 8080)

Once you go to http://localhost:8080/ you’ll end up 404 Not Found so we need to create index.php and routes.php (for routing purposes)
index.php
<?php
echo 'It is Working. Great!'
?>
routes.php
<?php
if(file_exists(__DIR__.'/'.$_SERVER['REQUEST_URI'])) {
return false;
} else {
include 'index.php';
}
?>
If the PHP webserver is running hit ‘Ctrl+C’ and type again ‘C:\PHP5.4/php -S localhost:8080 routes.php’ Just to ensure that if the requested file is not exist it will automatically redirect to index.php
AND VOILA!…

You just have learned how to run a PHP built-in webserver, Have fun!