Spin up a local PHP server


Sat Oct 10 2020 12:00:14 GMT+0000 (UTC)

Saved by @eneki


// Where PORT_NUMBER is an integer from 1024 to 49151
// Well-known ports reserved for priviledged services range from 0 through 1023.
// Registered ports are 1024 to 49151.
// Dynamic ports (also called private ports) are 49152 to 65535.

// -S means "Run with built-in web server

// If you use localhost (the host name for IP address which is the loopback address to your computer) rather than you may hit a connection refused error. 
// Loopback addresses range from ~ but using is common practice.
// Listening on means listening from anywhere that has network access to "this" computer (all interfaces) including the loopback address. To make the web server accessible to any interface, use as opposed to (localhost).
// means all IPv4 addresses on the local machine. If a host has two IP addresses, and, and a server running on the host listens on, it will be reachable at both of those IPs.

// Run the command from a folder containing either an index.php or index.html otherwise specify a file in the URI request. E.g.:

php -S router.php

// then navigate in your browser to http://localhost:8000/