XAMPP — Local Development
Set up a local web server on your computer to build and test websites offline
XAMPP is a free, open-source local server that lets you run PHP, MySQL, and Apache on your own computer — no internet required. Every serious web developer uses a local environment to build and test websites before going live. XAMPP is the most popular choice for Windows and Mac. This guide gets you from installation to a fully working local WordPress site in under 2 hours.
- Beginners setting up their first development environment
- Students learning PHP and MySQL
- WordPress developers who want to work offline
- Anyone who wants to test changes before going live
Go to apachefriends.org and download XAMPP for your OS (Windows/Mac/Linux). Run the installer. Select components: Apache, MySQL, PHP, phpMyAdmin. Install to C:\xampp (Windows) or /Applications/XAMPP (Mac). Avoid spaces in the path.
Open XAMPP Control Panel. Click Start next to Apache (web server) and MySQL (database). Green status means running. If Apache fails to start, port 80 is blocked — change it to 8080 in httpd.conf, or stop Skype/IIS that uses port 80.
Navigate to C:\xampp\htdocs (Windows) or /Applications/XAMPP/htdocs (Mac). Create a new folder for your project (e.g., mywebsite). All your website files go inside this folder. Access it at http://localhost/mywebsite in your browser.
Open VS Code. Create index.php in your project folder. Write: <?php echo "Hello World!"; ?> Save and open http://localhost/mywebsite in browser. You should see "Hello World!". This confirms PHP is working correctly.
Open http://localhost/phpmyadmin in browser. This is your database manager. Create a new database: click New → enter database name → Create. You can create tables, run SQL queries, import/export databases — all visually.
Download WordPress from wordpress.org. Extract to C:\xampp\htdocs\mywordpress. Create a database in phpMyAdmin (e.g., wp_local). Open http://localhost/mywordpress and follow the 5-minute WordPress install wizard. Enter your database details.
Open C:\xampp\php\php.ini in VS Code. Increase limits for development: upload_max_filesize = 64M, post_max_size = 64M, max_execution_time = 300, memory_limit = 256M. Restart Apache after changes.
In php.ini, set: display_errors = On, error_reporting = E_ALL. This shows PHP errors in the browser during development — essential for debugging. Remember to turn this OFF on live servers.
By default, phpMyAdmin has no password. Set a root password: phpMyAdmin → User Accounts → root → Edit → Change password. Update config.inc.php with the new password. This prevents unauthorized database access.
When ready to go live: export your database from phpMyAdmin (Export → SQL). Upload files to cPanel public_html via FileZilla. Import database in live phpMyAdmin. Update wp-config.php with live database credentials. Done!
Deep Dive Topics
Installing XAMPP on Windows & Mac
Download XAMPP from apachefriends.org. Choose the version matching your PHP needs — PHP 8.2 is recommended for modern WordPress development.
Windows vs Mac differences:
| Aspect | Windows | Mac |
|---|---|---|
| Install path | C:\xampp\ | /Applications/XAMPP/ |
| htdocs path | C:\xampp\htdocs\ | /Applications/XAMPP/htdocs/ |
| php.ini location | C:\xampp\php\php.ini | /Applications/XAMPP/etc/php.ini |
| Control Panel | XAMPP Control Panel.exe | XAMPP Manager app |
Common install errors & fixes:
PHP & MySQL with XAMPP
All PHP files go in C:\xampp\htdocs\yourproject\. Access them at http://localhost/yourproject/. XAMPP includes phpMyAdmin for visual database management at http://localhost/phpmyadmin.
Connect to MySQL with PDO (recommended):
<?php
$host = 'localhost';
$dbname = 'mydb';
$user = 'root';
$pass = ''; // empty by default in XAMPP
try {
$pdo = new PDO(
"mysql:host=$host;dbname=$dbname;charset=utf8mb4",
$user,
$pass,
[PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]
);
echo "Connected successfully!";
} catch (PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}Connect with mysqli (alternative):
<?php
$conn = mysqli_connect('localhost', 'root', '', 'mydb');
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
echo "Connected!";Important php.ini settings for development:
| Setting | Development Value | Production Value |
|---|---|---|
| display_errors | On | Off |
| error_reporting | E_ALL | E_ALL & ~E_DEPRECATED |
| upload_max_filesize | 64M | 8M–32M |
| memory_limit | 256M | 128M–256M |
| max_execution_time | 300 | 60 |
After editing php.ini, always restart Apache in XAMPP Control Panel for changes to take effect.
Installing WordPress on XAMPP (localhost)
Running WordPress locally lets you develop and test without affecting your live site. The entire setup takes under 15 minutes.
Step-by-step:
- Download WordPress from wordpress.org
- Extract to
C:\xampp\htdocs\mysite\ - Open phpMyAdmin → create database
wp_mysite - Visit
http://localhost/mysite→ WordPress install wizard - Enter: DB Name =
wp_mysite, Username =root, Password = (empty), Host =localhost - Complete the 5-minute install → you're done!
wp-config.php for localhost:
define( 'DB_NAME', 'wp_mysite' );
define( 'DB_USER', 'root' );
define( 'DB_PASSWORD', '' );
define( 'DB_HOST', 'localhost' );
define( 'DB_CHARSET', 'utf8mb4' );
// Enable debug mode for development
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', true );Common local WordPress issues:
XAMPP vs Other Local Development Tools
XAMPP is the most popular local server, but it's not always the best choice. Here's how it compares to the alternatives:
| Tool | OS | Best For | WordPress? | Difficulty |
|---|---|---|---|---|
| XAMPP | Win/Mac/Linux | PHP/MySQL general dev | ✅ Yes | Easy |
| Local by Flywheel | Win/Mac | WordPress only | ✅ Best | Very Easy |
| Laragon | Windows only | PHP dev, fast | ✅ Yes | Easy |
| WAMP | Windows only | PHP/MySQL | ✅ Yes | Easy |
| MAMP | Mac/Windows | Mac users | ✅ Yes | Easy |
| Docker | All | Advanced, production-like | ✅ Yes | Hard |
Which to use?
- WordPress-only work → Use Local by Flywheel. One-click WP install, built-in SSL, easy push to live. No configuration needed.
- General PHP development → Use XAMPP (Windows/Mac) or Laragon (Windows — faster, cleaner).
- Mac users → MAMP has a nicer Mac-native interface than XAMPP.
- Advanced / team projects → Docker with a docker-compose.yml gives you a production-identical environment.
Moving Your XAMPP Site to a Live Server
When your local site is ready, follow these exact steps to deploy it to a live cPanel server. This works for both plain PHP sites and WordPress.
Step-by-step deployment:
- Export DB from phpMyAdmin: localhost/phpmyadmin → select DB → Export → SQL → Go → saves as
mydb.sql - Upload files via FileZilla: Connect to live server → navigate to
public_html→ drag your project folder - Create live DB: cPanel → MySQL Databases → create new DB + user with ALL PRIVILEGES
- Import DB on live server: Live phpMyAdmin → select new DB → Import → upload
mydb.sql - Update wp-config.php: Change DB_NAME, DB_USER, DB_PASSWORD to live credentials
- Fix URLs: phpMyAdmin → wp_options → update siteurl and home to
https://yourdomain.com - Test: Visit your domain — check all pages, images, and forms
Quick URL fix via SQL:
-- Run in live phpMyAdmin SQL tab
UPDATE wp_options
SET option_value = REPLACE(option_value, 'http://localhost/mysite', 'https://yourdomain.com')
WHERE option_name IN ('siteurl', 'home');
UPDATE wp_posts
SET guid = REPLACE(guid, 'http://localhost/mysite', 'https://yourdomain.com');
UPDATE wp_posts
SET post_content = REPLACE(post_content, 'http://localhost/mysite', 'https://yourdomain.com');Pro tip: Use the All-in-One WP Migration plugin for a one-click export/import that handles all URL replacements automatically. It's the easiest method for WordPress migrations.