Console9

How to set up a local development environment with XAMPP and phpMyAdmin

Install XAMPP on Windows, configure Apache virtual hosts, manage MySQL databases with phpMyAdmin, and install WordPress locally.

This guide walks through setting up a complete local PHP development environment using XAMPP and phpMyAdmin. By the end, you will have Apache HTTP Server, MariaDB, and PHP running on your machine with virtual hosts configured for project isolation and phpMyAdmin available for database management.

What You Need Before Starting

  • A Windows 10/11, macOS, or Linux computer
  • Administrator access (required for installing services)
  • At least 1 GB of free disk space
  • A web browser for testing

Estimated time: 20–30 minutes.

Architecture Overview

XAMPP (cross-platform Apache, MariaDB, PHP, and Perl) bundles four components into a single installer that creates a local web server environment.

Apache HTTP Serverserves web pages and processes PHP files on your local machine. Apache listens on port 80 (HTTP) and port 443 (HTTPS) by default.

MariaDB(a MySQL-compatible database server) stores and manages application data. MariaDB listens on port 3306 by default. XAMPP bundles MariaDB rather than MySQL, though the XAMPP Control Panel labels it as "MySQL" for historical reasons.

PHPprocesses server-side scripts. Apache uses the PHP module to interpret .php files and return the generated HTML to the browser.

phpMyAdminprovides a web-based interface for managing MariaDB databases. phpMyAdmin runs as a PHP application within the Apache server and is accessible at http://localhost/phpmyadmin.

Step 1: Install XAMPP on Your System

Download XAMPP from the official Apache Friends website. Choose the installer that matches your operating system and preferred PHP version.

=== "Windows"

Run the XAMPP installer executable. The default installation path is C:\xampp. Accept the default components — Apache, MariaDB, PHP, and phpMyAdmin.

After installation, open the XAMPP Control Panel and start the Apache and MySQL modules by clicking the "Start" buttons next to each service.

For detailed Windows installation steps, see How to install XAMPP on Windows.

=== "macOS"

Mount the XAMPP .dmg file and drag the XAMPP folder to /Applications. Open the XAMPP application from /Applications/XAMPP/ and start Apache and MySQL from the control panel.

=== "Linux"

Make the installer executable and run it:

chmod +x xampp-linux-x64-*-installer.run
sudo ./xampp-linux-x64-*-installer.run

XAMPP installs to /opt/lampp/ on Linux. Start the services with:

sudo /opt/lampp/lampp start

Step 2: Verify XAMPP Is Running by Accessing Localhost

Open a browser and navigate to http://localhost. The XAMPP dashboard page confirms that Apache HTTP Server is running and serving pages from the htdocs directory.

The htdocs directory is the Apache document root where XAMPP serves files from:

  • Windows: C:\xampp\htdocs\
  • macOS: /Applications/XAMPP/htdocs/
  • Linux: /opt/lampp/htdocs/

Create a test PHP file to verify that PHP processing works:

<?php
// Save this file as htdocs/test.php
phpinfo();

Navigate to http://localhost/test.php in your browser. The PHP info page confirms that Apache processes PHP files correctly. Delete this file after testing — the phpinfo() output exposes server configuration details.

For a full walkthrough, see XAMPP tutorial: How to access localhost.

Step 3: Configure Apache Virtual Hosts in XAMPP

Apache virtual hosts allow you to run multiple projects on separate local domains (e.g., project1.local, project2.local) instead of using subdirectories under localhost. Virtual hosts isolate each project's files and configuration.

Edit the System Hosts File

Map your local domain to the loopback IP address. Add this line to your system hosts file:

=== "Windows"

Edit C:\Windows\System32\drivers\etc\hosts as Administrator:

127.0.0.1    project1.local

=== "macOS / Linux"

Edit /etc/hosts with sudo:

127.0.0.1    project1.local

Add a Virtual Host in Apache Configuration

Open the Apache virtual hosts configuration file:

  • Windows: C:\xampp\apache\conf\extra\httpd-vhosts.conf
  • macOS/Linux: /opt/lampp/etc/extra/httpd-vhosts.conf

Add a virtual host block for your project:

<VirtualHost *:80>
    ServerName project1.local
    DocumentRoot "C:/xampp/htdocs/project1"
    <Directory "C:/xampp/htdocs/project1">
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

The AllowOverride All directive enables .htaccess files in the project directory, which many PHP frameworks (Laravel, WordPress, Symfony) require for URL rewriting.

Restart Apache from the XAMPP Control Panel to apply the virtual host configuration. Navigate to http://project1.local to verify the virtual host works.

For detailed instructions, see How to configure Apache virtual hosts in XAMPP.

Step 4: Manage Databases with phpMyAdmin

phpMyAdmin provides a web interface for creating databases, managing tables, running SQL queries, and importing or exporting data. Access phpMyAdmin at http://localhost/phpmyadmin.

Create a Database in phpMyAdmin

  1. Open http://localhost/phpmyadmin in your browser.
  2. Click the "Databases" tab in the top navigation bar.
  3. Enter a database name (e.g., project1_db) in the "Create database" field.
  4. Select utf8mb4_general_ci as the collation — this character set supports full Unicode including emoji.
  5. Click "Create".

phpMyAdmin creates the database and displays it in the left sidebar.

Create Tables and Run SQL Queries

Click the database name in the left sidebar. Use the "Create table" form to define columns, data types, and primary keys. phpMyAdmin generates the SQL CREATE TABLE statement and executes it.

The SQL tab accepts any valid SQL query:

CREATE TABLE users (
    id INT AUTO_INCREMENT PRIMARY KEY,
    name VARCHAR(100) NOT NULL,
    email VARCHAR(255) UNIQUE NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

For a complete phpMyAdmin walkthrough, see the phpMyAdmin article.

Step 5: Install WordPress Locally in XAMPP (Optional)

WordPress is the most common PHP application deployed on XAMPP for local development. The installation demonstrates how XAMPP's components work together.

  1. Create a database named wordpress in phpMyAdmin (follow Step 4).
  2. Download WordPress from wordpress.org and extract it to htdocs/wordpress/.
  3. Navigate to http://localhost/wordpress and follow the installation wizard.
  4. Enter the database connection details:
    • Database name: wordpress
    • Username: root
    • Password: (leave empty — XAMPP's default MariaDB root password is blank)
    • Host: localhost

WordPress connects to the MariaDB database through PHP's MySQLi extension. The wp-config.php file stores the database connection credentials.

For detailed steps, see How to install WordPress on XAMPP.

How to Verify the Complete Setup

Test each component of the local development environment:

  1. Apache: Navigate to http://localhost— the XAMPP dashboard should load.
  2. PHP: Create and load a phpinfo() page to verify PHP version and extensions.
  3. MariaDB: Open phpMyAdmin at http://localhost/phpmyadmin— the dashboard should show server information and the MariaDB version.
  4. Virtual hosts: Navigate to your custom domain (e.g., http://project1.local) — the project files should load.

What to Do Next