আগামী ১৫ ডিসেম্বর -২০১৭ তারিখ থেকে শুরু হচ্ছে পাঁচ মাস ব্যাপী Professional Web Design and Development with HTML, CSS PHP,MySQL,JavaScript, AJAX, JQUERY, Bootstrap and Live Project কোর্সের ৮৭ তম ব্যাচ এবং ২৬ ডিসেম্বর-২০১৭ তারিখ থেকে শুরু হচ্ছে চার মাস ব্যাপী Zend PHP-7 Certified PHP Engineering (Advance PHP) কোর্সের ৩৫ তম ব্যাচ। প্রত্যেকটি কোর্স এর ফী নির্ধারণ করা হয়েছে ৩০,০০০/= আগ্রহীদেরকে অতিসত্বর মাসুদ আলম স্যার এর সাথে যোগাযোগ করতে অনুরোধ করা যাচ্ছে। স্যার এর মোবাইল: 01722 81 75 91

Run PHP in PHP built-in web server

1. Introduction

Hey everybody you may probably know starting from PHP 5.4, PHP has a built-in web server. In this tutorial, we will learn how to use PHP built-in web server. And we’ll see how we can actually take advantage of this simple web server to do some fun stuff.

The first you can ask why do we need a PHP built-in server when we already have Apache/Nginx? And we also have some nicely packaged tools such as WAMP and XAMPP. The answer is as stated in PHP official page. This web server was designed to aid application development. It is not a full-featured web server, so we should not use it for production.
However, as it comes with PHP, it is super handy when we need to spin up a web server to do some testing or development. It saves us from installing any real server or other third party tools.

2. Download PHP

First we need to download php from http://windows.php.net/download/ for windows user

PHP for windows user

PHP for windows user

And if you use Linux, you need to download from http://php.net/downloads.php

php for linux user

php for linux user

2. Usage

First extract your php in your any drive and run below command in your terminal or cmd .

php -S localhost:8000

Setup PHP Built-in web server

Setup PHP Built-in web server

It will treat current directory as the document root directory and if a request does not specify a file, then either index.php or index.html in the given directory are served. You will be able to visit the site via URL localhost:8000 as the 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 example above, request will be served from foo directory.

Specifying a document root directory

Specifying a document root directory

Now you can create and run any .php or .html file from foo directory

You can also Write just in your index.php then you will see below output

output

output

Run PHP in PHP built-in web server

Hi, My name is Masud Alam, love to work with Open Source Technologies, living in Dhaka, Bangladesh. I’m a Certified Engineer on ZEND PHP 5.3, I served my first five years a number of leadership positions at Winux Soft Ltd, SSL Wireless Ltd, Canadian International Development Agency (CIDA), World Vision, Care Bangladesh, Helen Keller, US AID and MAX Group where I worked on ERP software and web development., but now i’m a founder and CEO of TechBeeo Software Company Ltd. I’m also a Course Instructor of ZCPE PHP 7 Certification and professional web development course at w3programmers Training Institute – a leading Training Institute in the country.

Leave a Reply

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