How To Use The PHP Built-in Web Server

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.

If you’re unfamiliar with PHP web hosting, you can check out a free PHP tutorial to brush up on your scripting skills.

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.

Christopher Maiorana Content Writer II

Christopher Maiorana joined the InMotion community team in 2015 and regularly dispenses tips and tricks in the Support Center, Community Q&A, and the InMotion Hosting Blog.

More Articles by Christopher

Was this article helpful? Join the conversation!