PHP Development Server on OS X

php development server

On OS X, you can easily test PHP web development scripts while offline by starting PHP as a server on you Mac. Here we show you how simple it is, for example, when developing a website.

Steps to start your php development server:

1. Start a Terminal window

2. Go to the folder that contains your files (typically where you would place your index.html file). In the Terminal window, type: cd ~/Documents/mywebproject/ ⏎

3. Then type: php -S localhost:8000 ⏎

4. In your web browser, enter the URL: http://localhost:8000

Note: means press the Enter key.

That’s it!

If you are connected to a local network, for example, via WiFi, you can access the PHP server from another computer by going through the following steps:

1. Start a Terminal window

2. Type: ifconfig ⏎

3. Find your ip address, typically written similar to: inet 10.0.1.9. 10.0.1.9 is your ip address.

4. Go to the folder that contains your files (typically where you would place your index.html file). In the Terminal window, type: cd ~/Documents/mywebproject/ ⏎

5. Then type: php -S youripaddress:8000 ⏎ (
As an example, our ip address was 10.0.1.9 so we typed: php -S 10.0.1.9:8000 ⏎)

6. If you get a pop-up window asking: “Do you want the application “php” to accept incoming network connections?”, click Allow. This tells your firewall to allow other computers access to the PHP server.

7. In your web browser, enter the URL: http://youripadress:8000 (
In our example, our URL was: http://10.0.1.9:8000)

8. Now you are able to access the server from another computer on the same local network by entering in the same URL on that computer (http://youripaddress:8000).

Remember that after you are done with development, you may want to change back the PHP firewall settings you changed in step 6: Go to System Preferences -> Security & Privacy -> Firewall -> Firewall Options and change the setting for php to “Block incoming connections”.