How to Install and Run PHP on Your Localhost (Step-by-Step Guide)
If you want to learn PHP or build a web application with it, the first step is to create a working local environment.
This guide will walk you through the process of installing PHP on your computer and running PHP scripts locally.
Install PHP on Your System
To install PHP on your system, use XAMPP.
It's a free software package that includes PHP, Apache, and MySQL.
Visit the website from the link above and download and install XAMPP for your operating system.
from the Control Panel, Launch Apache and MYSQL.
C:\xampp\xampp-control.exe
Run a PHP File on Localhost
To test our setup, let's create a file 'index.php', open it with your code editor, and add the code below inside.
Once added, run the command:
php -S localhost:8000
You should see the message: Hello World
<?php
echo "Hello World";
?>