WP AI Agent
Features Pricing Blog Contact Download Plugin Manage Subscription Get Free Key →

How to Install WordPress Locally with XAMPP: Complete Guide

· · 8 min read

Installing WordPress locally with XAMPP is one of the most effective ways to build, test, and develop WordPress sites without needing a live server or paying for hosting. Whether you are a developer, designer, or blogger, a local WordPress environment gives you complete freedom to experiment safely. In this guide, you will learn exactly how to download, configure, and run WordPress on your own computer using XAMPP as the local server stack.

What Is XAMPP and Why Use It for WordPress?

XAMPP is a free, open-source local server package developed by Apache Friends. The name stands for X (cross-platform), Apache, MariaDB, PHP, and Perl. It bundles everything WordPress needs to run — a web server, a database engine, and PHP — into a single easy installer available for Windows, macOS, and Linux.

Key Benefits of Using XAMPP

  • Free and open-source: No licensing costs or subscriptions required.
  • Cross-platform: Works on Windows, macOS, and Linux with identical workflows.
  • All-in-one: Apache, MariaDB, PHP, and phpMyAdmin are installed together.
  • Safe testing environment: Experiment with plugins, themes, and code without risking a live site.
  • Offline development: Build and test sites without an internet connection.

When Should You Use a Local WordPress Environment?

A local environment is ideal when you want to develop a new theme from scratch, test plugin compatibility before updating a live site, learn WordPress development, or demonstrate a site to a client before going live. It is also significantly faster than working directly on a remote server because all file transfers happen locally.

Step 1: Download and Install XAMPP

The first major step is getting XAMPP installed on your machine. The process is straightforward regardless of your operating system.

  1. Visit the official XAMPP website at https://www.apachefriends.org and click the download button for your operating system (Windows, Linux, or macOS).
  2. Choose the latest stable version of XAMPP that includes PHP 8.0 or higher for best WordPress compatibility.
  3. Run the downloaded installer. On Windows, this will be an .exe file. On macOS it will be a .dmg file, and on Linux a .run file.
  4. During installation, make sure the components Apache, MySQL/MariaDB, and phpMyAdmin are selected. These are required for WordPress.
  5. Accept the default installation directory. On Windows this is typically C:\xampp. Do not install XAMPP inside the Program Files folder as this can cause permission issues.
  6. Complete the installer and launch the XAMPP Control Panel when prompted.

Starting Apache and MySQL in XAMPP

  1. Open the XAMPP Control Panel from your desktop shortcut or Start Menu.
  2. Click the Start button next to Apache. The status indicator should turn green.
  3. Click the Start button next to MySQL. It should also turn green.
  4. Open your browser and navigate to http://localhost. You should see the XAMPP welcome dashboard, confirming Apache is running correctly.

If either Apache or MySQL fails to start, it is usually because another application is using port 80 (Apache) or port 3306 (MySQL). You can change these ports in the XAMPP Control Panel under Config.

Step 2: Download WordPress and Add It to XAMPP

With XAMPP running, the next step is to download the WordPress core files and place them in the correct directory so XAMPP can serve them.

  1. Go to https://wordpress.org/download and click Download WordPress to get the latest .zip file.
  2. Locate the XAMPP htdocs folder. On Windows this is C:\xampp\htdocs. On macOS it is typically /Applications/XAMPP/htdocs.
  3. Inside htdocs, create a new folder for your site. For example, name it mywordpresssite. This folder name will become part of your local URL.
  4. Extract the contents of the WordPress .zip file. Open the extracted folder and copy all files inside the wordpress sub-folder directly into your newly created mywordpresssite folder.
  5. Verify the structure. You should see files like wp-config-sample.php, wp-login.php, and folders like wp-admin and wp-content directly inside C:\xampp\htdocs\mywordpresssite.

Understanding the htdocs Directory

The htdocs folder is XAMPP's web root. Any folder you place inside it becomes accessible via http://localhost/folder-name in your browser. You can host multiple WordPress installations simultaneously by creating separate sub-folders, for example htdocs\site1 and htdocs\site2.

Step 3: Create a MySQL Database with phpMyAdmin

WordPress requires a MySQL or MariaDB database. XAMPP includes phpMyAdmin, a web-based interface that makes database management easy without writing SQL manually.

  1. Open your browser and navigate to http://localhost/phpmyadmin.
  2. Click the Databases tab at the top of the screen.
  3. In the Create database field, type a name for your database such as wordpress_local. Avoid spaces and use underscores instead.
  4. Set the collation to utf8mb4_unicode_ci. This is the recommended collation for WordPress and supports a full range of characters including emoji.
  5. Click the Create button. You will see your new database appear in the left-hand panel.

Database Credentials to Remember

By default, XAMPP uses the following database credentials. Note these down as you will need them in the next step:

  • Database Host: localhost
  • Username: root
  • Password: (empty — no password by default)

For a production server you would always set a strong password, but for local development the default empty password is acceptable.

Step 4: Configure WordPress and Run the Installer

Now that your database is ready, you need to connect WordPress to it. This involves editing the WordPress configuration file and then running the famous five-minute installation wizard.

Creating the wp-config.php File

  1. Navigate to your site folder: C:\xampp\htdocs\mywordpresssite.
  2. Find the file wp-config-sample.php and make a copy of it. Rename the copy to wp-config.php.
  3. Open wp-config.php in a text editor such as Notepad++, VS Code, or Sublime Text.
  4. Find the following lines and update them with your database details:
// ** Database settings ** //
define( 'DB_NAME', 'wordpress_local' );
define( 'DB_USER', 'root' );
define( 'DB_PASSWORD', '' );
define( 'DB_HOST', 'localhost' );
define( 'DB_CHARSET', 'utf8mb4' );
define( 'DB_COLLATE', '' );
  1. Scroll down to the Authentication Keys and Salts section. Visit https://api.wordpress.org/secret-key/1.1/salt/ to generate unique keys, then replace the placeholder lines in wp-config.php with the generated values.
  2. Save and close the file.

Running the WordPress Installation Wizard

  1. Open your browser and go to http://localhost/mywordpresssite.
  2. Select your preferred language and click Continue.
  3. On the next screen, click Let's go! if WordPress detects your database connection successfully. If you see an error, double-check the credentials in wp-config.php.
  4. Fill in the site details: Site Title, Username, Password, and Email. Choose a strong username and password even for local sites to build good habits.
  5. Click Install WordPress. The installation completes in seconds.
  6. Click Log In and enter your credentials. You will be taken to the WordPress dashboard at http://localhost/mywordpresssite/wp-admin.

Step 5: Configure WordPress for Local Development

After installing WordPress, a few additional configuration steps will make your local development environment more comfortable and functional.

Enable Debugging Mode

For development, it is highly recommended to enable WordPress debugging. Open wp-config.php and add or update the following constants:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
@ini_set( 'display_errors', 0 );

With these settings, errors are written to wp-content/debug.log without being displayed to the browser, which keeps the front end clean while capturing useful diagnostic information.

Install Useful Development Plugins

  • Query Monitor: Provides detailed information about database queries, hooks, conditionals, and HTTP requests.
  • WP Mail SMTP (with log only mode): Prevents WordPress from sending real emails during development, logging them instead.
  • Theme Check: Validates your custom theme against WordPress coding standards.
  • User Switching: Allows you to switch between user roles instantly for testing purposes.

Using WP-CLI with XAMPP (Optional)

WP-CLI is a command-line interface for WordPress that dramatically speeds up development tasks. Once installed, you can run commands like the following from inside your site directory to install plugins without using the browser:

# Install and activate a plugin via WP-CLI
wp plugin install contact-form-7 --activate

# Create a new admin user
wp user create devuser [email protected] --role=administrator --user_pass=securepassword

# Export the database
wp db export backup.sql

To use WP-CLI with XAMPP on Windows, add the XAMPP PHP binary path (C:\xampp\php) to your system's PATH environment variable, then download wp-cli.phar from https://wp-cli.org and follow the installation instructions.

Setting Up Pretty Permalinks

  1. In the WordPress dashboard, go to Settings > Permalinks.
  2. Select Post name or any structure other than Plain.
  3. Click Save Changes.
  4. If permalinks return 404 errors, you need to enable the Apache mod_rewrite module. Open the XAMPP Control Panel, click Config next to Apache, open httpd.conf, find the line LoadModule rewrite_module modules/mod_rewrite.so, and make sure it is not commented out (no # at the start).

Frequently Asked Questions

Is XAMPP safe to use for WordPress development?

Yes, XAMPP is safe for local development. It runs only on your own machine and is not accessible to the internet by default. However, you should never use XAMPP's default configuration (empty root password, no firewall) on a public-facing server. Always use a properly secured hosting environment for live WordPress sites.

How do I move my local WordPress site to a live server?

To migrate your local WordPress site to a live server, export your database from phpMyAdmin as a .sql file, upload your WordPress files via FTP or SFTP, import the database on the live server using the host's phpMyAdmin or a migration plugin like All-in-One WP Migration or Duplicator, and then update the site URL in wp-config.php and the WordPress settings. Search and replace tools like WP-CLI's wp search-replace command help update all localhost URLs in the database.

Why is Apache not starting in XAMPP?

The most common reason Apache fails to start is a port conflict. On Windows, Skype, IIS, or another application may already be using port 80 or port 443. Open the XAMPP Control Panel, click Config next to Apache, open httpd.conf, and change the Listen 80 line to a different port such as Listen 8080. Then access your site at http://localhost:8080 instead. Alternatively, stop the conflicting application and restart Apache.

Can I run multiple WordPress sites in XAMPP at the same time?

Yes. Simply create a separate sub-folder inside htdocs for each site (for example htdocs\site-a and htdocs\site-b), install WordPress in each folder, and create a separate database for each site in phpMyAdmin. Access them at http://localhost/site-a and http://localhost/site-b respectively. There is no limit to the number of sites you can run simultaneously as long as your computer has sufficient RAM and storage.

Setting up WordPress locally with XAMPP is a reliable skill that every WordPress developer and enthusiast should have in their toolkit. By following the steps in this guide, you now have a fully functional local WordPress environment ready for theme development, plugin testing, and learning. If you want to go even further and manage your WordPress sites without manually editing files or remembering commands, WP AI Agent is a powerful tool that lets you handle complex WordPress tasks — from plugin management to content creation and configuration changes — simply by chatting in plain English with an AI assistant.

Ready to manage WordPress with AI?

Get 100,000 tokens free every month. No credit card required.

Get Your Free License Key →

More from the blog