- Download and install XAMPP (apachefriends.org). It bundles Apache (web server), PHP, MariaDB/MySQL and phpMyAdmin.
- Open the XAMPP Control Panel and Start Apache and MySQL (green).
- Your web root is the
htdocsfolder (e.g.C:\xampp\htdocs). Create a foldermyappinside it. - Create
myapp/hello.php:
PHP
<!DOCTYPE html>
<html>
<body>
<h1>Hello from PHP</h1>
<?php
echo 'Today is ' . date('Y-m-d H:i') . '<br>';
echo 'Your IP: ' . $_SERVER['REMOTE_ADDR'];
?>
</body>
</html>- Open
http://localhost/myapp/hello.phpin the browser. (Never double-click the file: it must be served throughhttp://localhost.) - phpMyAdmin is at
http://localhost/phpmyadmin.
Troubleshooting: port 80 in use (stop Skype/IIS or change Apache port to 8080 and use localhost:8080); blank page (turn on errors: ini_set('display_errors', 1); error_reporting(E_ALL); while developing, and read xampp/apache/logs/error.log); "file download instead of run" (you opened the wrong URL or Apache is off). Alternative: php -S localhost:8000 in a folder if PHP is installed.