PHP Built-in Web Server

Starting from PHP 5.4 , PHP incorporates a feature of a built-in web server. You can take the advantage of  PHP built-in web server for development and testing of your PHP applications. It means you don’t need to configure Apache virtual host to run your PHP applications.

If you have already installed LAMP, WAMP, XAMPP on your system, still you can try and use this feature.

How to install LAMP on Ubuntu

To use PHP built-in web server you need to install PHP 5.4 or higher version. If you are not sure which PHP version you have installed on your machine, just open the terminal and type a simple command (php -v).

Top ten Linux terminal commands 

I have already installed PHP version 5.5.

To check some of the options by typing PHP -h (PHP help command) on a terminal.

Look at the line marked in bold (-S, -t) this is the option for running PHP built-in web server.

Subscribe Our Tutorials

Get Latest Updates on Facebook

How to Start a PHP Built-in Web Server

To use a PHP built-in web server, go to the root directory of your project and run this simple command on a terminal.

Using this command a simple Web Server will run and listen to a port 8000. You can specify any port. If specified port is used by some other process, it will throw an error.

When a web server is running successfully then the following output will be displayed on a terminal.

When a web server is started, by default your current directory is your document root. If you want to change the document root, you can specify them with -t flag.

PHP Composer

Here, /var/www/laravel is my document root and I can request all the files present in a laravel directory.

PHP online video tutorials 

How to install PHP 7 on Ubuntu

As per PHP Manual:

Warning: This web server was designed to aid application development. It may also be useful for testing purposes or for application demonstrations that are run in controlled environments. It is not intended to be a full-featured web server. It should not be used on a public network.


Remember this is a great feature for testing your PHP applications but it’s not a full-featured web server.

I have written this post based on my experience with PHP built-in web server. If you are using this feature and you want to add something, you can let us know through your comment.

About WebRewrite

I am technology lover who loves to keep updated with latest technology. My interest field is Web Development.
Tagged , , . Bookmark the permalink.