0 points

Spin up a local PHP server


dashboard

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

Posted by @eneki

php -S 0.0.0.0:<PORT_NUMBER>

// 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 121.0.0.1 which is the loopback address to your computer) rather than 0.0.0.0 you may hit a connection refused error. 
// Loopback addresses range from 127.0.0.1 ~ 127.255.255.254 but using 121.0.0.1 is common practice.
// Listening on 0.0.0.0 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 0.0.0.0 as opposed to 121.0.0.1 (localhost).
// 0.0.0.0 means all IPv4 addresses on the local machine. If a host has two IP addresses, 192.168.1.1 and 10.1.2.1, and a server running on the host listens on 0.0.0.0, 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 0.0.0.0:8000 router.php

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

https://stackoverflow.com/questions/1678010/php-server-on-local-machine