PHP server on local machine?


Question

I'm trying to build a PHP site and I'm wanting to test my PHP files without uploading them to my host. Basically testing them on my own machine before I upload them. How do I do that?

1
131
1/16/2018 7:49:30 AM

Accepted Answer

53
11/5/2009 2:52:41 AM

PHP 5.4 and later have a built-in web server these days.

You simply run the command from the terminal:

cd path/to/your/app
php -S localhost:8000

Then in your browser go to http://localhost:8000 and boom, your system should be up and running. (There must be an index.php or index.html file for this to work.)


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon