New: Complete Beginner's Guide to Coding is now available in Premium
Updated: Indian Govt Exam roadmaps now include salary breakdowns & timelines
Tip: Use the Career Hub to explore all career paths in one place
Local Dev

XAMPP — Local Development

Set up a local web server on your computer to build and test websites offline

1-2 hours Beginner Essential Skill 10 Steps
XAMPP — Local Development
Complete Guide
About This Guide

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.

Who Is This For?
  • 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
What You Will Learn
Install and configure XAMPP on Windows or Mac
Run PHP files and MySQL databases locally
Install WordPress on localhost
Move your local site to a live server
Progress: 0 / 10 steps completed
1
Download & Install XAMPP Step 1

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.

apachefriends.org Windows/Mac/Linux
2
Start Apache & MySQL Step 2

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.

XAMPP Control Panel httpd.conf
3
Create Your Project Folder Step 3

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.

File Explorer VS Code htdocs folder
4
Create Your First PHP File Step 4

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.

VS Code Browser PHP
5
Set Up phpMyAdmin Step 5

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.

phpMyAdmin http://localhost/phpmyadmin
6
Install WordPress Locally Step 6

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.

WordPress.org phpMyAdmin Browser
7
Configure php.ini Settings Step 7

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.

php.ini VS Code XAMPP Control Panel
8
Enable Error Reporting Step 8

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.

php.ini Chrome DevTools Xdebug
9
Secure phpMyAdmin Step 9

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.

phpMyAdmin config.inc.php
10
Move Local Site to Live Step 10

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!

phpMyAdmin Export FileZilla cPanel

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:

AspectWindowsMac
Install pathC:\xampp\/Applications/XAMPP/
htdocs pathC:\xampp\htdocs\/Applications/XAMPP/htdocs/
php.ini locationC:\xampp\php\php.ini/Applications/XAMPP/etc/php.ini
Control PanelXAMPP Control Panel.exeXAMPP Manager app

Common install errors & fixes:

Port 80 conflict (Apache won't start)
Skype, IIS, or another app is using port 80. Fix: Stop Skype → Tools → Options → Advanced → uncheck "Use port 80". Or change Apache to port 8080: XAMPP → Config → httpd.conf → change Listen 80 to Listen 8080.
Antivirus blocking XAMPP
Windows Defender or antivirus may block Apache/MySQL. Fix: Add C:\xampp\ to antivirus exclusions. Run XAMPP Control Panel as Administrator.
MySQL port 3306 conflict
Another MySQL instance is running. Fix: Stop the other MySQL service in Windows Services (services.msc). Or change XAMPP MySQL port in my.ini.

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:

SettingDevelopment ValueProduction Value
display_errorsOnOff
error_reportingE_ALLE_ALL & ~E_DEPRECATED
upload_max_filesize64M8M–32M
memory_limit256M128M–256M
max_execution_time30060

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:

  1. Download WordPress from wordpress.org
  2. Extract to C:\xampp\htdocs\mysite\
  3. Open phpMyAdmin → create database wp_mysite
  4. Visit http://localhost/mysite → WordPress install wizard
  5. Enter: DB Name = wp_mysite, Username = root, Password = (empty), Host = localhost
  6. 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:

Permalinks not working (404 on posts)
Apache mod_rewrite is not enabled. Fix: Open C:\xampp\apache\conf\httpd.conf → find AllowOverride None → change to AllowOverride All. Restart Apache. Then go to WP Admin → Settings → Permalinks → Save Changes.
Emails not sending from localhost
XAMPP doesn't have a mail server. Fix: Install WP Mail SMTP plugin and use Gmail SMTP or Mailtrap.io for testing email functionality locally.

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:

ToolOSBest ForWordPress?Difficulty
XAMPPWin/Mac/LinuxPHP/MySQL general dev✅ YesEasy
Local by FlywheelWin/MacWordPress only✅ BestVery Easy
LaragonWindows onlyPHP dev, fast✅ YesEasy
WAMPWindows onlyPHP/MySQL✅ YesEasy
MAMPMac/WindowsMac users✅ YesEasy
DockerAllAdvanced, production-like✅ YesHard

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 usersMAMP has a nicer Mac-native interface than XAMPP.
  • Advanced / team projectsDocker 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:

  1. Export DB from phpMyAdmin: localhost/phpmyadmin → select DB → Export → SQL → Go → saves as mydb.sql
  2. Upload files via FileZilla: Connect to live server → navigate to public_html → drag your project folder
  3. Create live DB: cPanel → MySQL Databases → create new DB + user with ALL PRIVILEGES
  4. Import DB on live server: Live phpMyAdmin → select new DB → Import → upload mydb.sql
  5. Update wp-config.php: Change DB_NAME, DB_USER, DB_PASSWORD to live credentials
  6. Fix URLs: phpMyAdmin → wp_options → update siteurl and home to https://yourdomain.com
  7. 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.

Tools You Need
XAMPP
Local server stack
Free
VS Code
Code editor
Free
phpMyAdmin
Database GUI
Free
FileZilla
FTP for deployment
Free
Xdebug
PHP debugger
Free
Git
Version control
Free
Salary Guide
Web Developer ₹3-15 LPA
PHP Developer ₹4-20 LPA
Full Stack Dev ₹8-35 LPA
Pro Tips
Use Local by Flywheel instead of XAMPP for WordPress-only development — easier setup
Keep XAMPP updated — old PHP versions have security vulnerabilities
Use Git from Day 1 — version control saves you from disasters
Bookmark http://localhost/phpmyadmin — you'll use it constantly