Built in Web Server in PHP

Author - Webner
8.08.2018
|
0 Comments
||

Built in Web Server in PHP and How to Use it

What is Built in Web Server?

Built-in web server is used for development and testing the PHP application without using LAMP, just launch the built-in server from the command line, test your code and close when you’re done.

Examples

First you have to install php in any of your drive and after that you can run below command in your terminal or cmd.

1. php -S localhost:8000
 Web Server in PHP
Php built in webserver

This will use the current directory as a root directory and if a request does not specify a file, either index.php or index.html is provided in the specified directory. You will be able to visit the site via URL localhost: 8000 as URL from any browser

2. Specifying a document root directory

php -S localhost:8000 -t f:\php\foo

The -t option allows us to specify a document root directory. In the above example, a request will be sent from the test directory.
 Web Server in PHP

You can create and execute any php and html file from “root” directory.

Open Any browser

http://localhost:8080/

 Web Server in PHP

3. Using router file

php -S localhost:8000 router.php

In some cases, you may want to use some third party router to complete the request. You can do this with the router file as easy as possible.

4. Pchart in Web Services

This is the server-side charting library which means it needs to run the server.

You must first download this library.

curl -LOk http://www.pchart.net/release/pChart2.1.4.tar
Or
http://www.pchart.net/download

Extract zip file.

tar -xzf pChart2.1.4.tar ( Terminal) 

Start the server

cd pChart2.1.4/examples/
php -S localhost:8080

 Web Server in PHP

Now it is completed. Open a browser and type in http://localhost:8080/.

 Web Server in PHP

Webner Solutions is a Software Development company focused on developing Insurance Agency Management Systems, Learning Management Systems and Salesforce apps. Contact us at dev@webners.com for your Insurance, eLearning and Salesforce applications.

Leave a Reply

Your email address will not be published. Required fields are marked *