How To Use The PHP Built-in Web Server

Date: 9/6/19 About 1 minute to read.

Have you ever tried to open a PHP file locally? You may have noticed your web browser does not process PHP code naturally. You need a web server in order to do that.

Why Use The PHP Built-in Server

The built-in PHP web server can be run on any computer that has PHP installed. (Apple computers already have PHP installed, but if you’re on Windows or Linux you may need to run a PHP installer.)

The PHP built-in server is used to aid in writing PHP scripts without having to run a full stack web server. But it should not be used for local WordPress development or for a production website.

The built-in PHP server lets you quickly and easily test a PHP script for educational or development purposes. For something more advanced, you will want to look into installing a local development environment or purchasing shared hosting.

Using the PHP Built-in Server

In order to use the PHP built-in server you’ll need to open your computer’s terminal app and have a PHP file available to work with.

Using your terminal app, navigate to the folder where your PHP file resides and run this command:

$ php -S localhost:8000

You’ll notice this binds a sort of pop-up web server you can access by going to the localhost:8000 URL in your web browser. And your PHP scripts will execute as needed.

Leave a Reply