Since version 5.4, PHP has a built-in web server feature. But the feature is not intended to be a full-featured web server. We can use it for application development, testing purposes, and application demonstration.

How does it work? Let’s try.

In this tutorial, I use:

  • Ubuntu 16.04
  • PHP 7.0.8
  • /var/www/php/ as document root

Create index.php and write these codes to the file:


Save it to /var/www/php/.

By using terminal, execute this command:

php -S localhost:8080 -t /var/www/php/

Open a web browser application and go to localhost:8080.

 How to Use PHP's Built-in Web Server