How to Install and Configure WordPress on Localhost (XAMPP / MySQL)
How to Install and Configure WordPress on Localhost (XAMPP / MySQL)
Running WordPress in a local development environment is essential for building custom plugins, testing core updates, and staging configuration changes without risking production availability. This guide details the complete workflow for setting up WordPress on a local Apache and MySQL/MariaDB stack using XAMPP on Windows.
C:xampp), but the directory permissions, MySQL collation choices, and wp-config.php constants apply equally to Linux (LAMP) and macOS (MAMP/Docker) setups.1. System Requirements & Stack Verification
Before downloading WordPress, verify that your local web stack meets the minimum requirements:
| Component | Minimum Version | Recommended Version |
|---|---|---|
| PHP |
7.4+ | 8.1 or 8.2 with curl, mbstring, mysqli, openssl, zip |
| Database | MySQL 5.7+ / MariaDB 10.4+ | MariaDB 10.4+ with utf8mb4_unicode_ci |
| Web Server | Apache 2.4+ / Nginx 1.20+ | Apache 2.4 with mod_rewrite enabled |
| HTTPS | Optional for local dev | Recommended via self-signed OpenSSL cert or mkcert |
To verify that your PHP CLI and MySQL services are active, open PowerShell:
php -v
mysql -u root -e "SELECT VERSION();"
2. Setting Up the Database in MySQL / phpMyAdmin
WordPress requires a dedicated database and user privileges to store tables, metadata, and options.
Option A: Via Command Line (Fastest)
CREATE DATABASE `xyphla_wp_local` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
GRANT ALL PRIVILEGES ON `xyphla_wp_local`.* TO 'root'@'localhost';
FLUSH PRIVILEGES;
Option B: Via phpMyAdmin Web Interface
- Open your browser and navigate to
http://localhost/phpmyadmin/. - Click New in the left sidebar.
- Enter database name:
xyphla_wp_local. - Select collation:
utf8mb4_unicode_ci(critical for full emoji and international UTF-8 support). - Click Create.
utf8mb4_unicode_ci or utf8mb4_520_unicode_ci. Using older utf8_general_ci can cause 4-byte character truncation issues and database query warnings.3. Extracting and Organizing WordPress Core Files
- Download the latest official WordPress zip package from wordpress.org/download.
- Extract the archive into your XAMPP root document directory:
C:xampphtdocsxyphla-wp
```
3. Ensure the folder contains root files directly: `index.php`, `wp-config-sample.php`, `wp-load.php`, and directories `wp-admin`, `wp-includes`, and `wp-content`.
---
## 4. Configuring `wp-config.php`
Copy `wp-config-sample.php` to `wp-config.php` in the site root directory:
powershell
Copy-Item C:xampphtdocsxyphla-wpwp-config-sample.php C:xampphtdocsxyphla-wpwp-config.php
Open `wp-config.php` in your code editor and configure your database parameters:
php
// Database settings – You can get this info from your web host //
/ The name of the database for WordPress /
define(‘DBNAME’, ‘xyphlawplocal’);
/ Database username /
define(‘DBUSER’, ‘root’);
/ Database password (default is empty in XAMPP) /
define(‘DBPASSWORD’, ”);
/ Database hostname /
define(‘DBHOST’, ‘localhost’);
/ Database charset to use in creating database tables. /
define(‘DBCHARSET’, ‘utf8mb4’);
/ The database collate type. Don’t change this if in doubt. /
define(‘DBCOLLATE’, ”);
### Generating Unique Authentication Keys and Salts
Visit [api.wordpress.org/secret-key/1.1/salt/](https://api.wordpress.org/secret-key/1.1/salt/) and paste the generated cryptographic hashes into your `wp-config.php`:
php
define(‘AUTHKEY’, ‘put your unique phrase here’);
define(‘SECUREAUTHKEY’, ‘put your unique phrase here’);
define(‘LOGGEDINKEY’, ‘put your unique phrase here’);
define(‘NONCEKEY’, ‘put your unique phrase here’);
define(‘AUTHSALT’, ‘put your unique phrase here’);
define(‘SECUREAUTHSALT’, ‘put your unique phrase here’);
define(‘LOGGEDINSALT’, ‘put your unique phrase here’);
define(‘NONCESALT’, ‘put your unique phrase here’);
### Enabling Developer Debugging
In local environments, always enable debugging logs to catch notices and deprecated functions early:
php
// Local Development Debug Settings
define(‘WPDEBUG’, true);
define(‘WPDEBUGLOG’, true);
define(‘WPDEBUGDISPLAY’, false);
define(‘SCRIPTDEBUG’, true);
define(‘SAVEQUERIES’, true);
> [!WARNING]
> Never leave `WP_DEBUG_DISPLAY` set to `true` or `WP_DEBUG` active on a production-facing public server, as this could expose sensitive system paths and database credentials to visitors.
---
## 5. Running the 5-Minute Web Installer
1. Open your browser and navigate to:
```text
http://localhost/xyphla-wp/
```
2. Select your preferred system language and click **Continue**.
3. Fill in the installation form:
- **Site Title:** `Xyphla Local Development`
- **Username:** `admin` (or your chosen developer handle)
- **Password:** Choose a secure password and store it in your password manager.
- **Your Email:** Enter your working administrative email address.
- **Search engine visibility:** Check *Discourage search engines from indexing this site* (recommended for local development).
4. Click **Install WordPress**.
5. Once complete, click **Log In** and enter your credentials.
---
## 6. Configuring Clean Permalinks (.htaccess)
To enable human-readable URLs and support WordPress REST API routes (`/wp-json/`):
1. Go to **Settings > Permalinks** in the WordPress admin bar.
2. Select **Post name** (`/%postname%/`).
3. Click **Save Changes**.
Ensure an `.htaccess` file exists in `C:xampphtdocsxyphla-wp.htaccess` with the following rules:
apache
BEGIN WordPress
<IfModule modrewrite.c>
RewriteEngine On
RewriteRule .* – [E=HTTPAUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /xyphla-wp/
RewriteRule ^index.php$ – [L]
RewriteCond %{REQUESTFILENAME} !-f
RewriteCond %{REQUESTFILENAME} !-d
RewriteRule . /xyphla-wp/index.php [L]
END WordPress
“
---
## 7. Verification Checklist
Verify your setup by running through this final checklist:
- [x] WordPress admin dashboard loads at http://localhost/xyphla-wp/wp-admin/http://localhost/xyphla-wp/wp-json/
- [x] REST API endpoint returns valid JSON at wp-content/uploads/
- [x] Media upload directory is writablewp-content/debug.log` when test errors trigger
- [x] Debug log file is created in
Was this technical article helpful?
Help us continuously refine Xyphla documentation.