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)

  1. Download the latest XAMPP for Windows (PHP 8.x recommended).
  2. Run the installer (Allow UAC prompts). Install to C:\xampp (default).
  3. Launch XAMPP Control Panel and click Start for Apache and MySQL.
  4. Visit http://localhost/ — you should see the XAMPP dashboard.
If Apache won’t start: Ports 80/443 may be occupied (IIS/Skype/VMs). See Troubleshooting at the end.

2) Create Your Project Folder

  1. Open C:\xampp\htdocs.
  2. Create a folder, e.g., myapp.
  3. 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)

  1. Open C:\xampp\apache\conf\httpd.conf.
  2. Ensure this line is enabled (no # at start):
LoadModule rewrite_module modules/mod_rewrite.so
Optional but recommended: allow .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.

Security Tip: Set a root password for local dev (optional) and update config.inc.php if needed.

Create a Database & User (phpMyAdmin)

  1. Create DB: myapp_db
  2. 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)

  1. Download the Composer Windows Installer.
  2. During install, point it to C:\xampp\php\php.exe.
  3. 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 with sudo /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, check apache/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 All in the vhost directory block and LoadModule rewrite_module ... is enabled.
  • Composer not recognized: Reopen terminal after install (PATH refresh) or reinstall Composer and select the correct php.exe.
Next step: Start learning the language → PHP Syntax & Comments