XAMPP Setup (Windows)
XAMPP bundles Apache, MySQL/MariaDB, PHP, and phpMyAdmin in one installer. This guide walks you through a clean setup on Windows with best-practice configuration for daily PHP development.
1) Download & Install XAMPP (Windows)
- Download the latest XAMPP for Windows (PHP 8.x recommended).
- Run the installer (Allow UAC prompts). Install to
C:\xampp(default). - Launch XAMPP Control Panel and click Start for Apache and MySQL.
- Visit http://localhost/ — you should see the XAMPP dashboard.
2) Create Your Project Folder
- Open
C:\xampp\htdocs. - Create a folder, e.g.,
myapp. - Create
C:\xampp\htdocs\myapp\index.php:
<?php
// file: C:\xampp\htdocs\myapp\index.php
echo "XAMPP is working! ✅";
?>
Open http://localhost/myapp/ — you should see the message.
3) Enable Developer-Friendly php.ini Settings
Open C:\xampp\php\php.ini and set:
; show all errors during development
display_errors = On
error_reporting = E_ALL
; set timezone
date.timezone = Asia/Kolkata
; file upload limits (tune as needed)
upload_max_filesize = 20M
post_max_size = 25M
; memory for dev
memory_limit = 256M
Save and Stop/Start Apache from XAMPP Control Panel.
4) Enable Common PHP Extensions
In the same php.ini, remove the leading ; to enable:
;extension=curl
;extension=mysqli
;extension=openssl
;extension=gd
After enabling, restart Apache and verify via a phpinfo() page:
<?php phpinfo(); ?>
5) Turn On mod_rewrite (Pretty URLs)
- Open
C:\xampp\apache\conf\httpd.conf. - Ensure this line is enabled (no
#at start):
LoadModule rewrite_module modules/mod_rewrite.so
.htaccess overrides in your project.Edit (or create) C:\xampp\apache\conf\extra\httpd-vhosts.conf and add:
<VirtualHost *:80>
ServerName myapp.local
DocumentRoot "C:/xampp/htdocs/myapp/public"
<Directory "C:/xampp/htdocs/myapp/public">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
Add host entry in C:\Windows\System32\drivers\etc\hosts:
127.0.0.1 myapp.local
Restart Apache. Create C:\xampp\htdocs\myapp\public\.htaccess:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]
Create public\index.php to test routing:
<?php
$uri = $_SERVER['REQUEST_URI'];
echo "Routed to index.php — URI: {$uri}";
?>
Open http://myapp.local/test/abc → it should still load index.php and print the URI.
6) MySQL (MariaDB) & phpMyAdmin
Open http://localhost/phpmyadmin/. Default root user has no password in XAMPP.
config.inc.php if needed.Create a Database & User (phpMyAdmin)
- Create DB: myapp_db
- Create user myapp_user with password, grant privileges to myapp_db
Connect from PHP (mysqli)
<?php
$conn = new mysqli("localhost", "myapp_user", "your_password", "myapp_db");
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully! ✅";
?>
7) Composer (PHP Package Manager)
- Download the Composer Windows Installer.
- During install, point it to
C:\xampp\php\php.exe. - Open a new terminal and verify:
C:\> composer -V
Composer version X.Y.Z
8) Run PHP from Command Line (Optional)
Add C:\xampp\php to your Environment Variables → Path. Then:
C:\> php -v
PHP 8.x.x (cli) (built: ...)
C:\> cd C:\xampp\htdocs\myapp
C:\xampp\htdocs\myapp> php -S localhost:8000 -t public
Visit http://localhost:8000 to use PHP’s built-in dev server (handy for quick tests).
9) Optional: HTTPS (Self-Signed for Local)
For basic local HTTPS, you can create a self-signed cert and map it in a vhost (browsers will show a warning). This is optional for beginners.
10) Quick Notes for XAMPP on macOS/Linux
- macOS: XAMPP path:
/Applications/XAMPP/xamppfiles/htdocs. Start/Stop via XAMPP Manager. - Linux: XAMPP path:
/opt/lampp/htdocs. Start withsudo /opt/lampp/lampp start. - Steps for
php.ini,mod_rewrite, vhosts, and phpMyAdmin are similar to Windows (adjust paths).
Troubleshooting
- Apache won’t start (Port 80/443 in use):
- Stop IIS/World Wide Web Publishing Service (Services → stop).
- Quit apps using port 80 (Skype/VMware/Emulators).
- Or change Apache port in
httpd.conf(Listen 8080) and use http://localhost:8080/.
- Blank page / 500 error: Enable errors in
php.ini(display_errors=On,error_reporting=E_ALL), restart Apache, checkapache/logs/error.log. - phpMyAdmin access denied: Ensure MySQL is running. If you set a root password, update phpMyAdmin config or login with your new user.
- .htaccess ignored: Confirm
AllowOverride Allin the vhost directory block andLoadModule rewrite_module ...is enabled. - Composer not recognized: Reopen terminal after install (PATH refresh) or reinstall Composer and select the correct
php.exe.