Using the Built-in PHP CLI Server¶
Alternatively — if you are using PHP 5.4 or above — you can use the built-in CLI server (cli-server). To do this, you just start the server in the root directory:
1 |
php -S 0.0.0.0:8080 -t public/ public/index.php
|
This will make the website available on port 8080 on all network interfaces, using public/index.php to handle routing. This means the site is accessible via http://localhost:8080 or http://<your-local-IP>:8080.
If you’ve done it right, you should see the same result as with Apache above.
To test that your routing is working, navigate to http://localhost:8080/1234 and you should see the same error page as with Apache above.