XAMPP 2,521 is a free, open-source bundle from Apache Friends that installs a complete PHP development server in one step. The name lists its parts: cross-platform (X), Apache HTTP Server, MariaDB (a community fork of MySQL 524 ), PHP and Perl. The Windows package adds phpMyAdmin 5,104 , a control panel, and FTP and mail servers.
Download XAMPP from apachefriends.org (https://www.apachefriends.org/ 2,521 ). The newest build for Windows and Linux is 8.2.12, which contains PHP 8.2.12.
On Windows, run the installer and keep the default C:\xampp folder; installing under C:\Program Files causes permission problems with User Account Control.
Start C:\xampp\xampp-control.exe and click Start next to Apache and MySQL. On Linux, run the .run installer with sudo, then sudo /opt/lampp/lampp start.
Browse to http://localhost for the welcome page and http://localhost/phpmyadmin for the database.
Everything under C:\xampp\htdocs (or /opt/lampp/htdocs) is served, so htdocs\visits.php answers at http://localhost/visits.php:
<?php
$db = new PDO('mysql:host=127.0.0.1;charset=utf8mb4', 'root', '', [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
]);
$db->exec('CREATE DATABASE IF NOT EXISTS demo');
$db->exec('USE demo');
$db->exec('CREATE TABLE IF NOT EXISTS visits (
id INT AUTO_INCREMENT PRIMARY KEY,
seen_at DATETIME DEFAULT CURRENT_TIMESTAMP)');
$db->exec('INSERT INTO visits () VALUES ()');
$count = $db->query('SELECT COUNT(*) FROM visits')->fetchColumn();
echo "<p>This page has been viewed $count times.</p>";Each reload prints a higher number; XAMPP's database root account has no password by default.
Local HTTPS with a virtual host
localhost already counts as a secure context, but a named test domain with a trusted certificate mirrors production more closely. mkcert 59,701 (https://github.com/FiloSottile/mkcert 59,701 ) (BSD-3-Clause) creates a trusted local certificate authority: run mkcert -install, then mkcert myproject.test to get myproject.test.pem and myproject.test-key.pem. Copy them to C:\xampp\apache\conf\ssl, add 127.0.0.1 myproject.test to C:\Windows\System32\drivers\etc\hosts, and append a virtual host:
<VirtualHost *:443>
ServerName myproject.test
DocumentRoot "C:/xampp/htdocs/myproject/public"
SSLEngine on
SSLCertificateFile "conf/ssl/myproject.test.pem"
SSLCertificateKeyFile "conf/ssl/myproject.test-key.pem"
<Directory "C:/xampp/htdocs/myproject/public">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>Restart Apache from the control panel. AllowOverride All lets the project's .htaccess file add the rewrite rules that frameworks such as Laravel 2,157 expect.