Open Laboratory for Technocrats

Grab the developer role, learn concepts & prepare with senior software engineers to get solutions for problems in a software job. Coding and Programming Solutions crafted for you.

PHP - Run In Built Web Server

Since PHP 5.4 we can run web server for the testing purpose under the web development.

We have this option under CLI SAPI.

Lets now have a look how we can create/run the web server in php.
cd ~/public_html
php -S localhost:8000
Now the web server is running on port 8000, we can change it as per our requirement as something is already running on this server port then we can change the port and make it available.

Output will be like this:
PHP 5.4.0 Development Server started at Thu Jul 21 10:43:28 2011
Listening on localhost:8000
Document root is /home/me/public_html
Press Ctrl-C to quit
So the php command leading with -S holds the key to run the server via CLI.

Top #3 Articles