WordPress on Localhost
Running WordPress locally allows you to develop themes, test plugins, and build websites without a live server. Use tools like XAMPP, MAMP, Local by Flywheel, or Docker to create your local WordPress environment.
Access local WordPress:
http://localhost/wordpress
Admin: /wp-admin | Login: /wp-login.php
Methods to Run WordPress Locally
| Tool | Platform | Best For |
|---|---|---|
| XAMPP | Windows, Mac, Linux | Traditional setup, full control |
| MAMP | Mac, Windows | Mac users, simple setup |
| Local (Flywheel) | Windows, Mac | Easiest, WordPress-specific |
| Docker + wp-env | All platforms | Developers, isolated environments |
| Laragon | Windows | Fast, portable, modern |
Install WordPress with XAMPP
- Install XAMPP — Download from apachefriends.org
- Start Apache & MySQL — From XAMPP Control Panel
- Download WordPress — From wordpress.org
- Extract to htdocs —
C:\xampp\htdocs\wordpress - Create Database — Open phpMyAdmin, create database named
wordpress - Run Install — Visit
http://localhost/wordpress - Enter Details:
- Database:
wordpress - Username:
root - Password: (blank for XAMPP)
- Host:
localhost
- Database:
- Complete Setup — Set site title, admin username/password
Install with Local by Flywheel (Easiest)
- Download Local from localwp.com
- Install and open Local
- Click Create a new site
- Enter site name (e.g., "mysite")
- Choose environment (Preferred is fine)
- Set WordPress username/password
- Click Add Site
- Access at
mysite.local
WordPress wp-config.php for Localhost
// Database settings for XAMPP
define('DB_NAME', 'wordpress');
define('DB_USER', 'root');
define('DB_PASSWORD', '');
define('DB_HOST', 'localhost');
// Enable debug mode for development
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
// Disable auto-updates locally
define('AUTOMATIC_UPDATER_DISABLED', true);
WordPress CLI (WP-CLI)
# Install WordPress via CLI
wp core download
wp config create --dbname=wordpress --dbuser=root --dbpass=
wp db create
wp core install --url=localhost/wordpress --title="My Site" \
--admin_user=admin --admin_password=password --admin_email=admin@local.test
# Common commands
wp plugin install woocommerce --activate
wp theme install flavor flavor2 flavor3
wp user create editor editor@local.test --role=editor
wp db export backup.sql
Common Local URLs
| URL | Purpose |
|---|---|
| /wp-admin | Admin dashboard |
| /wp-login.php | Login page |
| /wp-content/themes/ | Theme files |
| /wp-content/plugins/ | Plugin files |
Troubleshooting
| Problem | Solution |
|---|---|
| Error establishing database connection | Check DB credentials in wp-config.php |
| White screen of death | Enable WP_DEBUG to see errors |
| Permalinks not working | Enable mod_rewrite, check .htaccess |
| Can't upload media | Check folder permissions on wp-content/uploads |