Run your PHP code using the PHP webserver

You can run PHP scripts on Windows without needing to install WAMP or Apache webserver. This is great if you don’t need all the features that these tools provide. The PHP built-in web server is not intended for production use but is great for developing and testing.

Lets get started!

You will need to download and install PHP to use the built-in PHP web server. Click here to visit the PHP download site.

Step 1 – Open your terminal interface.

Step 2 – Run the built-in PHP web server using:

php -S localhost:8080 -t c:\path-to-my-code\

The -S argument specifies the server name and port you wish to use. Additionally, the -t argument specifies the path to your PHP code. You can, of course, change the value of these arguments to suit your needs.

Finally, you should now be able to browse your PHP script via your browser. The PHP built-in webserver will ensure your PHP script is running on an available port.

Navigate to http://localhost:8080 as per your -S PHP argument.

Frequently asked questions

What is WAMP?

WAMP stands for Window, Apache, MySQL, and PHP. A Complete WAMP stack provides many features that could be useful for a developer. These features include: FastCGI, OpenSSL, phpMyAdmin, ModSecurity, ImageMagick, xDebug, Xcache, ModSecurity, MemCache and much more. Not everyone needs a full WAMP stack.

LAMP vs. WAMP

WAMP stands for Window, Apache, MySQL, and PHP. And WAMP is a variation on LAMP, which stands for Linux, Apache, MySQL, and PHP. So essentially, you would run LAMP on Linux-based platforms and WAMP on Windows-based platforms.

Is WAMP Free?

WAMP is free under the GPML license and is available for 32 and 64-bit versions.

What is XAMPP?

XAMPP stands for cross-platform, Apache, MySQL, PHP, and Perl. Consequently, it means that XAMPP is supported by platforms like Mac OS, Linux, and Windows. Conversely, Windows supports WAMP, and Linux supports LAMP. Just like WAMP and LAMP, XAMPP is a compilation of free software.

What is the PHP built-in webserver?

This is a web server that is designed to aid application development and testing. Therefore you do not need to install NGINX or Apache since the built-in webserver provides a single-threaded process.

Can you use the PHP built-in web server in production?

No. This web server is designed to aid application development and testing. It is not intended to be a full-featured web server as it only supports a single-threaded process. Additionally, it would be best if you did not use it on a public network.

You may also be interested in

About Anto Online

Anto, a seasoned technologist with over two decades of experience, has traversed the tech landscape from Desktop Support Engineer to enterprise application consultant, specializing in AWS serverless technologies. He guides clients in leveraging serverless solutions while passionately exploring cutting-edge cloud concepts beyond his daily work. Anto's dedication to continuous learning, experimentation, and collaboration makes him a true inspiration, igniting others' interest in the transformative power of cloud computing.

View all posts by Anto Online

One Comment on “Run your PHP code using the PHP webserver”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.