Last Updated:

PHP :  Starting the built-in web server

Starting with version 5.4.0 - PHP contains a built-in web server that can be launched with a single command.

This ver server was created to help in development, when you need to quickly check, develop or demonstrate something.
Therefore, it is not recommended to use it for a full-fledged web server or on real, public projects.
You may also need it when you really need to run the project, but you do not want to install apache web servers, nginx or built-in server assemblies, such as: xamppopenservermamplampvartigo, etc.

To start the built-in web server, you need to go to the folder with the application you are developing:

And execute the command:

Where localhost is the host of the server being launched.
8000 - Port of the server to be started.

Also, the server can be launched from any directory. To do this, just specify the path of the root directory.


Example for Windows:
cd /var/www/test
php -S localhost:8000
php -S localhost:8000 -t /var/www/test

  • An index file has been created in the directory - C:/test/.php
  • The index.php file contains the code:
    <?php
    phpinfo();
  • Go to this directory:
    cd C:/test
  • To start the server:
    php -S localhost:8000
  • Open the URL in the browser:
    http://localhost:8000