WordPress on Localhost
Running WordPress locally means you can develop themes, test plugins, break things, and experiment without affecting a live website — and without paying for hosting. You need three things: a web server (Apache), PHP, and a MySQL database. Local server stacks like XAMPP, WAMP, MAMP, and Laragon bundle all three.
The process is the same regardless of which stack you use: create a database, download WordPress, configure the database connection, run the installer.
Step 1: Create a Database
- Make sure your local server (XAMPP/WAMP/MAMP) is running — both Apache and MySQL
- Open phpMyAdmin at
localhost/phpmyadmin(orlocalhost:8888/phpMyAdminon MAMP) - Click New (left sidebar) → type a database name (e.g.,
wordpress) → click Create
That's it for the database. WordPress creates its own tables during installation. You don't need to create any tables manually.
Step 2: Download and Place WordPress
- Download WordPress from wordpress.org
- Extract the ZIP file
- Copy the
wordpressfolder into your web root:- XAMPP:
C:\xampp\htdocs\wordpress\ - WAMP:
C:\wamp64\www\wordpress\ - MAMP:
/Applications/MAMP/htdocs/wordpress/ - Laragon:
C:\laragon\www\wordpress\
- XAMPP:
Step 3: Run the Installer
- Open
localhost/wordpressin your browser (orlocalhost:8888/wordpresson MAMP) - Select your language
- Enter database details:
- Database Name: wordpress (or whatever you named it)
- Username: root
- Password: (blank for XAMPP/WAMP,
rootfor MAMP) - Database Host: localhost
- Table Prefix: wp_ (keep default)
- Click "Run the installation" → set your site title, admin username, and password
- You're done — login at localhost/wordpress/wp-admin
The Database Credentials by Stack
| Stack | MySQL User | MySQL Password | Host |
|---|---|---|---|
| XAMPP | root | (blank) | localhost |
| WAMP | root | (blank) | localhost |
| MAMP | root | root | localhost |
| MAMP (socket) | root | root | localhost:/Applications/MAMP/tmp/mysql/mysql.sock |
| Laragon | root | (blank) | localhost |
MAMP on macOS sometimes requires the socket path instead of just "localhost" for the database host. If the installer can't connect with "localhost," try the socket path above.
The Faster Way: Laragon or Local
Laragon has a one-click WordPress installer: Menu → Quick App → WordPress. It downloads WordPress, creates the database, configures wp-config.php, and sets up a virtual host — all automatically. You get a clean URL like wordpress.test instead of localhost/wordpress.
Local by Flywheel (now called "Local") is another option — it's a dedicated WordPress development tool that creates isolated environments for each WordPress site with its own PHP version and database. No XAMPP/WAMP needed. It's free and excellent for WordPress-only development.
Useful wp-config.php Settings for Development
// Enable debug mode (show errors in browser)
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true); // Also log to wp-content/debug.log
define('WP_DEBUG_DISPLAY', true); // Show errors on screen
// Disable automatic updates (no need locally)
define('AUTOMATIC_UPDATER_DISABLED', true);
// Disable the cron system (faster page loads)
define('DISABLE_WP_CRON', true);
// Increase memory limit
define('WP_MEMORY_LIMIT', '256M');
Common Problems
"Error establishing a database connection": The database credentials in wp-config.php don't match. Check username, password, database name, and host. Most commonly: MAMP users forgetting the password is "root" not blank, or the database name being misspelled.
White screen of death: A PHP error is crashing WordPress. Add define('WP_DEBUG', true); to wp-config.php to see the actual error. Usually a plugin or theme conflict.
Permalink 404s (pages work but posts show "Not Found"): Apache's mod_rewrite isn't enabled. On XAMPP, open httpd.conf and uncomment LoadModule rewrite_module modules/mod_rewrite.so, then restart Apache. Also make sure AllowOverride All is set for the htdocs directory.