April 01, 2012

How to use PHP Built-in webserver

PHP 5.4 supports a built-in web server which can be used for testing purpose which is good because we can test scripts quickly without having to install Apache.
This post aims to explain how to start, use and stop this web server.

1. Download and extract PHP 5.4.0 on your system. Follow this guide if you are an XAMPP user.

2. Open console ( Start -> Run -> cmd on Windows ) and navigate to PHP's current directory.


3. Now execute following command to start the build-in server:
php -S localhost:5555

Here we are telling PHP to start local server on port 5555

If everything works fine you'll see a message saying "PHP development server has started".
PHP will also output errors and warnings. ( In my case DLL for zip extension if missing )

Now lets see if our server is listening and responding to requests.

4. Create a simple index.php in Document Root. ( F:\Installs\Xampp\php\ in my case )

5. Open your favorite browser. I use Firefox.

6. Go to this URL: http://localhost:5555/index.php

7. You should see something like this.

Congratulations! The Built-in webserver is working properly and responding to requests and we can now test our script even without installing Apache on our Systems. Note that this built-in PHP server should not be used in production but only for testing.

1 comment:

  1. I've been exploring for a little bit for any high-quality articles or blog posts in this sort of space . Exploring in Yahoo I eventually stumbled upon this site. Reading this info So i am satisfied to exhibit that I have a very excellent uncanny feeling I found out exactly what I needed. I such a lot no doubt will make certain to do not omit this website and give it a look on a relentless basis.

    Feel free to surf to my web-site ... payday loans bad credit
    My website > payday loans bad credit