Is there a built-in server in php?

2

Sometimes we want to run a simple PHP script for testing, but we do not want to spend time installing wamp , xampp or even installing apache2 followed by PHP.

Is there any way to run the script in PHP, with some simple server, without the need to install any of the applications mentioned above.

    
asked by anonymous 12.09.2015 / 18:58

1 answer

5

Yes, there is a way.

From the 5.4 version, PHP offers a built-in server in the language itself.

Just run the following code from the command line:

php -S localhost:9000

This will make PHP create a small server to run your scripts. The root of your application will be considered the folder in which the command was executed.

If you want to specify the folder where you want to run the script, just use the -t

See:

php -S localhost:9000 -t /var/www/stackoverlow

See more about this at PHP Manual - Embedded Web Server

    
12.09.2015 / 18:58