PHP 5.4 introduced many of the new features, and one of the best features is PHP built-in web server. Now, you can take the benefit of a built-in web server for development as well as testing of your PHP application. That mean you don't need to configure Apache to run your PHP application.
There is no need to worry, if you already installed LAMP, WAMP, XAMPP on your system.
You need PHP 5.4 or higher version, if you want to use build-in web server. So, first of all, check which is the current version installed in your system. To check it go to terminal and type php -v.
php -v
PHP 5.5.9-1+sury.org~precise+1 (cli)(built: Feb 13 2014 15:53:53)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
To start webserver.
php -S localhost:8000
After inserting above command, you will get a start Web server listen to port 8000. It will show error if specified port is used by some other process.
[Sat Oct 25 10:43:00 2014] Failed to listen on localhost:8080 (reason: Address already in use)
Check out the output below, if your web sserver is successfully started.
PHP 5.5.9-1+sury.org~precise+1 Development Server started at Fri Oct 24 23:37:53 2014
Listening on http://localhost:8000
Document root is /var/www
When a web server is started, by default your current directory is your web root and you request whatever file is there. If you want to change the document root, you can specify them with -t flag.
php -S localhost:8000 -t /var/www/laravel
In above, Laravel ois a document toot.
This is the great feature for testing as well as development.
There is no need to worry, if you already installed LAMP, WAMP, XAMPP on your system.
You need PHP 5.4 or higher version, if you want to use build-in web server. So, first of all, check which is the current version installed in your system. To check it go to terminal and type php -v.
php -v
PHP 5.5.9-1+sury.org~precise+1 (cli)(built: Feb 13 2014 15:53:53)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies
with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans
To start webserver.
php -S localhost:8000
After inserting above command, you will get a start Web server listen to port 8000. It will show error if specified port is used by some other process.
[Sat Oct 25 10:43:00 2014] Failed to listen on localhost:8080 (reason: Address already in use)
Check out the output below, if your web sserver is successfully started.
PHP 5.5.9-1+sury.org~precise+1 Development Server started at Fri Oct 24 23:37:53 2014
Listening on http://localhost:8000
Document root is /var/www
When a web server is started, by default your current directory is your web root and you request whatever file is there. If you want to change the document root, you can specify them with -t flag.
php -S localhost:8000 -t /var/www/laravel
In above, Laravel ois a document toot.
This is the great feature for testing as well as development.
0 comments:
Post a Comment