How to make "php -S" to work on local network?

0

Issue

In OS X Mavericks (and newer), start a PHP server from the command line:

cd to/your/directory
php -S localhost:8888

It works, but the server only available on that computer only. Is there a way to test it on other devices within the same LAN?

Solution

EDIT:

You will want to launch the server with the command

php -S 0.0.0.0:8888

This will allow you to access the server remotely (see docs http://php.net/manual/en/features.commandline.webserver.php)

After this is done there are 2 ways to view the site on your local network

http://192.168.1.2:8888 where 192.168.1.2 is the IP address of your computer which you can find in your System Preferences under Network.

http://myMac.local:8888 where myMac is your local computer name which you can find in your System Preferences under Sharing.

REMEMBER: Both of these options may require your firewall to allow incoming traffic to port 8888 (or whatever port your script is listening on), if you have that running.

Answered By – cmorrissey

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More