PHP Install & XAMPP Setup
To run PHP, you need a web server with PHP installed, plus usually a database like MySQL. The easiest way to get started on your own computer is to install an all-in-one package such as XAMPP, which bundles Apache, MySQL/MariaDB, and PHP together.
XAMPP is free, available for Windows, macOS and Linux, and lets you test PHP scripts locally before deploying them to a real web host. Alternatively, many web hosting providers already have PHP installed and ready to use.
http://localhost/yourfile.phpInstalling XAMPP
Download XAMPP from the Apache Friends website, run the installer, and start the Apache and MySQL modules from the XAMPP Control Panel. Place your .php files inside the htdocs folder.
Running your first script
After starting Apache, open a browser and go to http://localhost/yourfile.php to see your script's output. Any syntax errors will typically be shown directly in the browser.
php -vPHP 8.3.0 (cli)Running php -v in a terminal confirms PHP is installed and shows its version.
<?php
echo "XAMPP is working!";
?>XAMPP is working!Saving this as test.php in htdocs and visiting localhost/test.php shows this message.
Key points
- XAMPP bundles Apache, MySQL and PHP for local development.
- PHP files are placed in the htdocs folder when using XAMPP.
- php -v checks the installed PHP version from the command line.
- Many hosting providers already have PHP preinstalled.
