How to Install XAMPP and Set Up a PHP Development Environment (2026 Guide)

By Lyndon Bermoy

Updated on:

How to Install XAMPP and Set Up a PHP Development Environment (2026 Guide)

Before you can run PHP code on your computer, you need a local server environment — a way to execute PHP files without uploading them to a web host every time you make a change. XAMPP is the most widely used solution for this, and for good reason: it installs PHP, Apache (the web server), and MySQL (the database) in a single package, on any operating system, in under 10 minutes.

This guide walks through installing XAMPP and setting up your first PHP project on Windows and macOS in 2026.

What Is XAMPP?

XAMPP stands for X (cross-platform), Apache, MariaDB, PHP, and Perl. It is a free, open-source package maintained by Apache Friends that bundles all the server software you need for PHP development into a single installer.

When XAMPP is running, your computer acts as a local web server. PHP files you place in the correct folder are processed and displayed in your browser at http://localhost/ — just like a live website, but running entirely on your machine.

Step 1: Download XAMPP

  1. Go to apachefriends.org and click Download
  2. Select your operating system (Windows, macOS, or Linux)
  3. Choose the latest PHP 8.x version (PHP 8.3 as of 2026)
  4. Download the installer — it is approximately 160MB
READ ALSO:   How To Integrate Video Into Your Content Marketing Strategy

Which PHP version should you download? Always choose PHP 8.2 or 8.3 in 2026. PHP 7.x is end-of-life and should not be used for new projects.

Step 2: Install XAMPP on Windows

  1. Run the downloaded .exe installer as Administrator (right-click → Run as administrator)
  2. If Windows User Account Control (UAC) shows a warning, click Yes
  3. The installer will ask which components to install — keep the defaults (Apache, MySQL, PHP, phpMyAdmin)
  4. Choose the installation directory — the default C:\xampp is recommended. Avoid Program Files — XAMPP has known permission issues there
  5. Uncheck the option to learn about Bitnami (optional cloud services you do not need)
  6. Click Install and wait approximately 2–3 minutes for installation to complete
  7. When finished, keep “Do you want to start the Control Panel now?” checked and click Finish

Step 3: Install XAMPP on macOS

  1. Open the downloaded .dmg file
  2. Drag the XAMPP application to your Applications folder
  3. Open XAMPP from Applications — macOS may warn it is from an unidentified developer; go to System Settings → Privacy & Security and click Open Anyway
  4. XAMPP Manager opens — click Manage Servers
  5. Select Apache Web Server and click Start
  6. Select MySQL Database and click Start

Alternative for Mac: Laravel Herd (free from herd.laravel.com) is a modern alternative to XAMPP specifically for PHP/Laravel development on macOS. It installs faster, has no configuration, and switches PHP versions with one click. If you plan to use Laravel, consider Herd instead of XAMPP.

Step 4: Start Apache and MySQL

On Windows, the XAMPP Control Panel opens automatically after installation:

  1. Click Start next to Apache — the row turns green when it is running
  2. Click Start next to MySQL — the row turns green when it is running
  3. Open your browser and navigate to http://localhost/
  4. You should see the XAMPP welcome page — this confirms PHP and Apache are working
READ ALSO:   Best PHP Development Setup in 2026: IDE, Tools, and Extensions

Step 5: Test PHP Is Working

The web root on XAMPP — the folder where your PHP files go — is:

  • Windows: C:\xampp\htdocs\
  • macOS: /Applications/XAMPP/xamppfiles/htdocs/

Create a test file:

  1. Open the htdocs folder
  2. Create a new file named test.php
  3. Add this content:
<?php
echo "<h1>PHP is working!</h1>";
echo "<p>PHP Version: " . PHP_VERSION . "</p>";
phpinfo();
  1. Open your browser and go to http://localhost/test.php
  2. You should see “PHP is working!” followed by a table of PHP configuration details
  3. Delete this file after testing — phpinfo() exposes server configuration and should never be left on a public server

Step 6: Create Your First PHP Project

Create a folder for your project inside htdocs:

C:\xampp\htdocs\
└── myproject\
    ├── index.php
    └── config.php
<!-- index.php -->
<!DOCTYPE html>
<html>
<head><title>My PHP Project</title></head>
<body>
    <?php
    $name = "World";
    echo "<h1>Hello, {$name}!</h1>";
    echo "<p>Running PHP " . PHP_VERSION . "</p>";
    ?>
</body>
</html>

Visit http://localhost/myproject/ in your browser to see the output.

Step 7: Set Up a MySQL Database with phpMyAdmin

XAMPP includes phpMyAdmin — a browser-based MySQL management tool. Access it at http://localhost/phpmyadmin/.

  1. Open http://localhost/phpmyadmin/
  2. Click New in the left sidebar
  3. Enter a database name (e.g., myproject_db) and click Create
  4. Click on your new database, then SQL, and run this to create a test table:
CREATE TABLE users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    email VARCHAR(150) UNIQUE NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

INSERT INTO users (name, email) VALUES ('Lyndon', 'lyndon@example.com');

Connect to this database from PHP:

<?php
$pdo = new PDO('mysql:host=localhost;dbname=myproject_db;charset=utf8mb4', 'root', '');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$stmt = $pdo->query("SELECT * FROM users");
$users = $stmt->fetchAll(PDO::FETCH_ASSOC);

foreach ($users as $user) {
    echo "<p>{$user['name']} — {$user['email']}</p>";
}

Note: XAMPP’s default MySQL root user has no password — that is fine for local development. Never use a passwordless root user in production.

READ ALSO:   How Beginners Can Start Online Earning.

Troubleshooting Common XAMPP Issues

Apache won’t start — Port 80 is already in use

Another application (often Skype or IIS) is using port 80. Solutions:

  • Change XAMPP Apache to port 8080: In XAMPP Control Panel, click Config → httpd.conf → find Listen 80 and change to Listen 8080. Access your site at http://localhost:8080/
  • Or stop the conflicting application and restart Apache

MySQL won’t start — Port 3306 conflict

Another MySQL instance is running. Stop it in Windows Services (Win+R → services.msc → find MySQL → Stop) then restart XAMPP MySQL.

PHP file downloads instead of executing

Apache is not processing PHP files. Ensure Apache is running (not just MySQL). Verify the file is inside the htdocs folder and you are accessing it via http://localhost/ not by opening the file directly in a browser.

Changes to PHP files not appearing

Clear your browser cache (Ctrl+Shift+R / Cmd+Shift+R) or open the URL in a private/incognito window.

Beyond XAMPP: When to Move to a Real Hosting Plan

XAMPP is for local development only. When your project is ready to share with others, you need a live PHP hosting plan. For most PHP projects, a shared hosting plan on Hostinger, SiteGround, or A2 Hosting (starting at $3–6/month) gives you a PHP + MySQL environment similar to your local XAMPP setup.

Recommended Development Tools to Use With XAMPP

  • VS Code (free) — the most popular code editor for PHP, with Intelephense extension
  • Git (free) — version control; install from git-scm.com
  • Composer (free) — PHP package manager; required for Laravel and most modern PHP packages. Install from getcomposer.org
  • TablePlus or DBeaver — better MySQL GUI than phpMyAdmin for complex database work

Conclusion

XAMPP gets a PHP development environment running in under 10 minutes with no server configuration required. For Windows developers learning PHP, it remains the standard starting point in 2026. macOS developers may prefer Laravel Herd for a more modern experience. Once your local setup is running, you have a full PHP + MySQL + Apache environment to build and test your applications before deploying to a live PHP hosting plan.

Next Step for Your Project Journey

Pick your next action to keep building: download complete source code, continue with practical tutorials, or explore more project systems.

Explore Source Code Continue Tutorials Final Year Projects

Leave a Comment