How Do I Set Up Local WordPress Development Using XAMPP?
WordPress websites do not always have to be built directly on a live web server. You can install WordPress on your own computer and create a complete private development environment.
One of the easiest ways to do this is with XAMPP.
XAMPP provides the main server components WordPress needs, including Apache, PHP, and MariaDB. Once XAMPP is running, your computer can behave like a small web server. You can then install WordPress, create pages, test themes, install plugins, write code, and experiment without affecting a public website.
This guide explains how to set up a local WordPress development environment using XAMPP, from downloading the software to troubleshooting common problems.
What Is Local WordPress Development?
Local WordPress development means running a WordPress website directly on your own computer instead of hosting it on an internet-connected web server.
For example, a normal live WordPress website may be available at:
A locally installed WordPress site might instead be available at:
http://localhost/mywebsite/
The local website normally cannot be accessed by ordinary internet visitors. It exists primarily on your computer.
This makes local development useful for:
- Learning WordPress
- Designing a new website
- Developing WordPress themes
- Developing and testing plugins
- Testing PHP, CSS, JavaScript, and HTML
- Experimenting with WordPress settings
- Troubleshooting problems
- Testing updates
- Creating a staging copy of a website
- Practicing website development without buying hosting
It is especially useful when you do not want experiments to affect your live website.
What Is XAMPP?
XAMPP is a free, open-source local server environment maintained by Apache Friends.
The name historically represents several technologies included in the package.
| Letter | Meaning |
|---|---|
| X | Cross-platform |
| A | Apache |
| M | MariaDB |
| P | PHP |
| P | Perl |
For WordPress development, the most important components are Apache, MariaDB, and PHP.
Apache
Apache is the web server.
When you enter a local URL such as:
http://localhost/
Apache processes the web request and serves the appropriate files.
MariaDB
WordPress requires a database to store most of the site’s structured information.
This includes things such as:
- Posts
- Pages
- Comments
- User accounts
- WordPress settings
- Plugin settings
- Theme-related options
- Taxonomies
- Metadata
XAMPP provides MariaDB for this purpose.
PHP
WordPress is primarily written in PHP.
PHP processes WordPress code on the server before the resulting page is delivered to the browser.
How WordPress and XAMPP Work Together
The basic structure looks like this:
Browser → Apache → PHP → WordPress → MariaDB
When you visit your local WordPress site, Apache receives the request. PHP executes the necessary WordPress code. WordPress retrieves information from the MariaDB database when necessary and generates the page that appears in your browser.
XAMPP therefore provides the environment in which WordPress can operate locally.
What You Need Before Starting
You generally need:
- A Windows, macOS, or Linux computer
- XAMPP
- A WordPress installation package
- A modern web browser
- Enough free disk space for your projects
- Internet access for the initial downloads
After WordPress and the required resources are installed, much of your local development can be performed without a constant internet connection. However, features that depend on external services will still require internet access.
Step 1: Download XAMPP
Download XAMPP from the official Apache Friends website.
Choose the version designed for your operating system.
XAMPP is available for major desktop platforms, including Windows, Linux, and macOS.
Before choosing a version, it is worth checking the PHP requirements of the WordPress version, theme, or plugin you intend to test.
Using an appropriate PHP version can prevent compatibility problems later.
Step 2: Install XAMPP
Open the downloaded XAMPP installer.
Depending on your operating system, you may need administrator permission.
During installation, XAMPP may allow you to select components.
For basic WordPress development, the important components include:
- Apache
- MySQL/MariaDB
- PHP
- phpMyAdmin
You can normally leave the default components selected if you are unsure.
XAMPP Installation Directory on Windows
A common installation directory is:
C:\xampp
Using a simple directory such as this can make local development easier.
After installation finishes, open the XAMPP Control Panel.
Step 3: Start Apache and MySQL
In the XAMPP Control Panel, locate:
- Apache
- MySQL
Click Start beside both services.
When they are running successfully, the XAMPP Control Panel should indicate that the modules are active.
Apache provides the web server, while MySQL/MariaDB provides the database service required by WordPress.
Now open your browser and visit:
http://localhost/
If the XAMPP dashboard or welcome page appears, Apache is working.
Step 4: Understand the htdocs Folder
On a typical Windows XAMPP installation, website files are stored inside:
C:\xampp\htdocs\
The htdocs directory is Apache’s default web document directory in XAMPP.
For example, suppose you create:
C:\xampp\htdocs\mywebsite\
You can usually access it through:
http://localhost/mywebsite/
Each local project can have its own folder.
For example:
htdocs/├── blog/├── business-site/├── portfolio/└── wordpress-test/
These could correspond to:
http://localhost/blog/http://localhost/business-site/http://localhost/portfolio/http://localhost/wordpress-test/
This makes it easy to maintain multiple WordPress installations on one computer.
Step 5: Download WordPress
Download the latest appropriate WordPress package from the official WordPress website.
WordPress normally arrives as a compressed ZIP archive.
Extract the archive.
Inside it, you will find the main WordPress files and directories, including items such as:
wp-adminwp-contentwp-includesindex.phpwp-config-sample.phpwp-login.php
These files form the core WordPress installation.
Step 6: Create Your Local WordPress Project Folder
Navigate to the XAMPP htdocs directory.
On Windows, this will commonly be:
C:\xampp\htdocs\
Create a new directory for your project.
For example:
C:\xampp\htdocs\mywebsite
Copy the extracted WordPress files into this directory.
Your project may now look similar to:
C:\xampp\htdocs\mywebsite\ wp-admin\ wp-content\ wp-includes\ index.php wp-config-sample.php wp-login.php
Your local site URL will then normally be:
http://localhost/mywebsite/
But before WordPress can complete its installation, it needs a database.
Step 7: Open phpMyAdmin
XAMPP normally includes phpMyAdmin, a browser-based database administration interface.
With Apache and MySQL running, open:
http://localhost/phpmyadmin/
You can also usually open phpMyAdmin using the Admin button beside MySQL in the XAMPP Control Panel.
phpMyAdmin allows you to:
- Create databases
- View database tables
- Import databases
- Export databases
- Run SQL queries
- Manage database users
- Modify database data
For a basic WordPress installation, you first need to create a database.
Step 8: Create a WordPress Database
Inside phpMyAdmin, choose the option to create a new database.
Give the database a simple name.
For example:
mywebsite_db
Avoid unnecessary spaces and unusual characters.
Create the database.
At this stage, you normally do not need to manually create WordPress tables. The WordPress installer creates the required tables automatically.
Remember the database name because you will need it during installation.
Step 9: Start the WordPress Installation
Open:
http://localhost/mywebsite/
WordPress should detect that it has not yet been configured and launch the installation process.
Select your preferred language.
WordPress will then request database information.
For a common default XAMPP development installation, the values may look like this:
| Setting | Typical Local Value |
|---|---|
| Database Name | mywebsite_db |
| Username | root |
| Password | Empty by default in many XAMPP setups |
| Database Host | localhost |
| Table Prefix | wp_ |
Your configuration may be different if you have changed the database account or XAMPP settings.
Database Name
Enter the database you created:
mywebsite_db
Username
A common default local XAMPP database username is:
root
Password
Some default local XAMPP configurations use the root account without a password.
If you configured a password yourself, enter that password instead.
Database Host
Usually:
localhost
Table Prefix
The standard WordPress table prefix is:
wp_
For isolated local development, leaving the default prefix is usually fine.
WordPress then creates or prepares its configuration and connects to the database.
Step 10: Configure Your WordPress Website
Once the database connection succeeds, WordPress will ask for basic site information.
You will normally provide:
- Site title
- Administrator username
- Administrator password
- Administrator email address
Use a password you can remember for local development, but avoid developing a habit of using weak credentials. If the site is later moved online, strong unique credentials are essential.
Complete the installation.
You should then have a working local WordPress website.
Step 11: Log In to the WordPress Dashboard
Your local administration URL will normally be:
http://localhost/mywebsite/wp-admin/
Enter the username and password you created during installation.
You now have access to the standard WordPress administration dashboard.
From here, you can work with:
- Posts
- Pages
- Media
- Comments
- Themes
- Plugins
- Users
- Settings
- Menus and site design features, depending on the theme
The experience is largely similar to managing a hosted WordPress installation.
Important WordPress Folders for Developers
Understanding the directory structure is useful when you begin development.
wp-admin
The wp-admin directory contains files used by the WordPress administration area.
You generally should not modify WordPress core files here.
wp-includes
This contains many of WordPress’s core libraries and functions.
Again, direct modification is generally discouraged because WordPress updates can overwrite core changes.
wp-content
This is the most important directory for many WordPress developers.
It normally contains:
wp-content/├── plugins/├── themes/└── uploads/
Custom development usually happens inside wp-content.
Installing a Theme Locally
You can install a theme from the WordPress dashboard through the theme management interface.
For custom theme development, you can also create a directory such as:
C:\xampp\htdocs\mywebsite\wp-content\themes\mytheme
A traditional custom theme may contain files such as:
mytheme/├── style.css├── functions.php├── index.php├── header.php├── footer.php└── screenshot.png
The exact structure depends on whether you are developing a classic theme or a modern block theme.
Local development allows you to modify files and immediately test the results.
Installing Plugins Locally
Plugins can be installed through the WordPress dashboard or placed directly in:
wp-content/plugins/
For example:
wp-content/plugins/my-custom-plugin/
This makes XAMPP useful for plugin development because you can modify PHP, JavaScript, CSS, and other plugin files without touching a production website.
Using wp-config.php
wp-config.php is one of the most important files in a WordPress installation.
It contains important configuration information, including database credentials.
A simplified portion might resemble:
define( 'DB_NAME', 'mywebsite_db' );define( 'DB_USER', 'root' );define( 'DB_PASSWORD', '' );define( 'DB_HOST', 'localhost' );
Do not copy these values blindly to a live server. Production hosting providers normally use different database names, usernames, passwords, and sometimes database hosts.
Enable WordPress Debugging for Development
One major advantage of a local environment is the ability to debug problems without exposing errors to visitors.
WordPress provides a debugging system through wp-config.php.
For development, you can configure settings such as:
define( 'WP_DEBUG', true );define( 'WP_DEBUG_LOG', true );define( 'WP_DEBUG_DISPLAY', false );
With this type of configuration, WordPress can log debugging information while avoiding displaying it directly on the page.
The debug log is commonly written to:
wp-content/debug.log
This can help identify:
- PHP warnings
- Deprecated functions
- Plugin errors
- Theme problems
- Coding mistakes
Remember that debugging settings suitable for development may not be appropriate for production.
Setting WordPress Permalinks Locally
After installation, go to:
Settings → Permalinks
Choose the permalink structure appropriate for your project and save it.
For example, many content websites use a structure similar to:
/%postname%/
If pretty permalinks do not work in XAMPP, Apache rewrite configuration may need attention.
WordPress commonly uses an .htaccess file on Apache installations to manage rewrite rules.
Common Problem: Apache Will Not Start
One of the most common XAMPP problems is Apache failing to start.
A frequent cause is a port conflict.
Apache commonly uses ports such as:
- Port 80 for HTTP
- Port 443 for HTTPS
Another application may already be using one of these ports.
Possible conflicting software or services can include:
- Another web server
- IIS
- Other Apache installations
- Development tools
- Some background services
Check the XAMPP logs and port information before changing configuration.
If necessary, Apache can be configured to use another port.
For example, if Apache is configured to listen on port 8080, your local site might be accessed through:
http://localhost:8080/mywebsite/
Do not randomly change ports without also updating the relevant Apache configuration.
Common Problem: MySQL Will Not Start
If MySQL/MariaDB does not start, possible causes include:
- Port conflicts
- Another MySQL service already running
- Incorrect configuration
- Improper shutdown
- Damaged database files
- Permission problems
The standard MySQL port is commonly:
3306
Check XAMPP’s logs before deleting, replacing, or modifying database files.
Database recovery should be approached carefully because deleting the wrong files can destroy local databases.
Error Establishing a Database Connection
If WordPress displays:
Error establishing a database connection
check the database configuration in wp-config.php.
Verify:
DB_NAMEDB_USERDB_PASSWORDDB_HOST
Also confirm that MySQL/MariaDB is running in XAMPP.
For example:
define( 'DB_NAME', 'mywebsite_db' );define( 'DB_USER', 'root' );define( 'DB_PASSWORD', '' );define( 'DB_HOST', 'localhost' );
The values must match your actual local database configuration.
localhost Is Not Loading
If localhost does not load, first check whether Apache is running.
Try:
http://localhost/
If Apache is using a custom port, include it:
http://localhost:8080/
Also check:
- Apache status
- Firewall settings
- Port conflicts
- XAMPP error logs
- Project directory name
- Apache configuration
phpMyAdmin Is Not Opening
Make sure both Apache and MySQL are running.
Then try:
http://localhost/phpmyadmin/
If you changed Apache’s port, you may need something similar to:
http://localhost:8080/phpmyadmin/
If an error appears, read the error message and inspect the XAMPP logs before modifying configuration files.
WordPress Cannot Upload Large Files
Local PHP settings can limit file uploads.
The relevant settings are generally found in php.ini.
Important directives include:
upload_max_filesizepost_max_sizememory_limitmax_execution_time
For example, a development environment might require larger limits when importing a large website backup.
After modifying php.ini, restart Apache so that the new PHP configuration is loaded.
Choose values appropriate for your project rather than setting unnecessarily extreme limits.
How to Create Multiple Local WordPress Websites
You can run several WordPress websites from one XAMPP installation.
For example:
C:\xampp\htdocs\site1C:\xampp\htdocs\site2C:\xampp\htdocs\site3
Create a separate database for each site:
site1_dbsite2_dbsite3_db
You can then access them through:
http://localhost/site1/http://localhost/site2/http://localhost/site3/
Keeping separate databases reduces confusion and makes individual projects easier to manage.
Localhost vs Live WordPress Hosting
| Feature | Local WordPress | Live WordPress |
|---|---|---|
| Runs on | Your computer | Hosting server |
| Publicly accessible | Usually no | Yes |
| Internet required for site itself | Usually no | Yes |
| Hosting cost | No separate hosting required | Usually required |
| Best for experimentation | Excellent | Riskier |
| Suitable for public visitors | No | Yes |
| Theme development | Excellent | Possible |
| Plugin development | Excellent | Possible |
| Safe place to test updates | Yes | Not ideal directly on production |
A local environment is primarily for development and testing. A production hosting environment is designed to make the site publicly available.
How to Move a Local WordPress Site to a Live Server
Once development is complete, you can migrate the website to hosting.
A typical migration involves two major components:
- WordPress files
- WordPress database
You may migrate manually or use a WordPress migration or backup tool.
For a manual migration, the general process involves:
- Backing up the local website
- Exporting the local database
- Uploading WordPress files to the live server
- Creating a production database
- Importing the database
- Updating
wp-config.php - Replacing local URLs with the production domain where required
- Checking permalinks
- Testing media
- Testing plugins
- Testing forms
- Checking internal links
- Configuring HTTPS
- Reviewing security settings
For example:
Local:
http://localhost/mywebsite
Production:
WordPress stores URLs in the database, including some data that may be serialized. Therefore, a simple text replacement performed carelessly in a database export can damage data.
Use a WordPress-aware search-and-replace method or a reliable migration process.
How to Back Up a Local WordPress Website
Even though the website is local, backups are important.
Your local site consists primarily of the website files and database.
Back Up the Files
Copy your project directory:
C:\xampp\htdocs\mywebsite\
to a safe backup location.
Back Up the Database
Open phpMyAdmin.
Select your WordPress database and use the Export feature to create an SQL backup.
For a complete recoverable copy, preserve both the WordPress files and database.
Using XAMPP for WordPress Theme Development
XAMPP provides a convenient environment for learning and building themes.
You can work with:
- PHP
- HTML
- CSS
- JavaScript
- WordPress template functions
- Hooks
- Template hierarchy
- Block development
- Responsive design
You can modify a file, refresh the browser, and immediately examine the result.
For serious development, consider adding tools such as:
- Git
- A code editor or IDE
- Browser developer tools
- Composer when required
- Node.js/npm for projects that use modern build tooling
- WP-CLI
These tools are not required for a basic WordPress installation, but they can make professional development more efficient.
Using XAMPP for Plugin Development
A custom plugin can be developed inside:
wp-content/plugins/
For example:
wp-content/└── plugins/ └── my-plugin/ └── my-plugin.php
A minimal plugin file could begin with:
/** * Plugin Name: My Local Plugin * Description: A simple plugin for local development. * Version: 1.0.0 */
After creating it, go to the WordPress Plugins screen and activate it.
You can then continue developing and debugging it locally.
Local WordPress Security
A local WordPress installation is generally less exposed than a public site, but security still matters.
Good practices include:
- Download XAMPP from its official source.
- Download WordPress from its official source.
- Keep backups of important projects.
- Avoid exposing local development services directly to the internet.
- Use strong credentials when an environment may be reachable by other devices or users.
- Keep WordPress, themes, and plugins reasonably current.
- Do not assume local database credentials are suitable for production.
- Protect your computer with normal operating-system security measures.
XAMPP is primarily designed as a development environment. Its convenient defaults should not automatically be treated as production-server security settings.
Advantages of Using XAMPP for WordPress
XAMPP offers several advantages.
Free development environment: You can begin learning WordPress without purchasing hosting.
Offline development: Much of your site can be developed without a continuously available internet connection.
Fast experimentation: Files and databases are stored locally, making many development operations quick.
Safe testing: A broken theme or plugin does not have to affect a public website.
Easy access to files: You can edit project files directly with your preferred code editor.
Multiple projects: One XAMPP installation can support numerous local websites.
Useful for learning: You can experiment with PHP, databases, WordPress internals, themes, and plugins.
Limitations of XAMPP
XAMPP is useful, but local development is not identical to production hosting.
Possible differences include:
- PHP version
- Database version
- Apache configuration
- PHP extensions
- Operating system
- File permissions
- Email configuration
- HTTPS configuration
- Caching
- Server resources
- Domain configuration
- Security policies
A site working perfectly on localhost may therefore behave differently after migration.
Try to keep your local environment reasonably similar to the production environment when compatibility is important.
XAMPP vs Web Hosting
XAMPP should not normally be considered a replacement for ordinary public web hosting.
XAMPP creates a development server on your computer.
Web hosting provides infrastructure intended to keep your website publicly available.
Think of the difference this way:
XAMPP = development workshop
Web hosting = public website environment
You build and test locally, then deploy the finished project to an appropriately configured production server.
Recommended Local WordPress Development Workflow
A practical workflow can be:
1. Install XAMPP
Set up Apache, PHP, and MariaDB.
2. Create a project directory
For example:
htdocs/mywebsite
3. Create a database
For example:
mywebsite_db
4. Install WordPress
Connect WordPress to your local database.
5. Configure development settings
Enable appropriate debugging and development tools.
6. Build the website
Develop your theme, plugins, content, and functionality.
7. Test thoroughly
Check:
- Desktop layout
- Mobile layout
- Forms
- Navigation
- Plugins
- Permalinks
- Images
- PHP errors
- JavaScript errors
- Accessibility
- Performance
8. Create a backup
Back up both files and database.
9. Migrate to production
Transfer the finished website to the live hosting environment.
10. Test the production site again
Do not assume that a successful localhost test guarantees identical behavior on a live server.
Frequently Asked Questions
Is XAMPP free?
Yes. XAMPP is a free and open-source development environment provided by Apache Friends.
Can I install WordPress on XAMPP?
Yes. XAMPP provides the web server, PHP, and database environment needed to run WordPress locally.
Do I need hosting to use WordPress with XAMPP?
No. You can develop WordPress locally without purchasing hosting. Hosting is generally required when you want to make the website publicly accessible on the internet.
Do I need a domain name for localhost?
No. A basic local installation can use an address such as:
http://localhost/mywebsite/
Can I install WordPress plugins on localhost?
Yes. Most ordinary WordPress plugins can be installed and tested locally. Plugins that rely on external APIs, payment services, incoming webhooks, licensing servers, or other internet-based functionality may require additional configuration.
Can I install themes on local WordPress?
Yes. You can install existing themes or develop your own themes locally.
Where are WordPress files stored in XAMPP?
On a typical Windows installation, they are stored inside a project directory under:
C:\xampp\htdocs\
For example:
C:\xampp\htdocs\mywebsite\
Where is the WordPress database stored?
The database is managed by MySQL/MariaDB through XAMPP. phpMyAdmin provides a convenient interface for viewing and managing it.
Why does WordPress say “Error establishing a database connection”?
Usually WordPress cannot connect to its database. Check the database name, username, password, host, and whether MySQL/MariaDB is actually running.
Can I run multiple WordPress sites using XAMPP?
Yes. Create a different project folder and preferably a separate database for each website.
Is XAMPP suitable for a live WordPress website?
XAMPP is primarily intended for development and testing. A properly configured production hosting environment is the better choice for a public WordPress website.
Can I move my XAMPP WordPress site online later?
Yes. You can migrate the site’s files and database to a live server. Make sure URLs, database credentials, HTTPS, permalinks, and production configuration are updated correctly.
Final Thoughts
Setting up WordPress locally with XAMPP is an excellent way to learn, develop, and test WordPress without immediately purchasing hosting or making experimental changes to a live website.
The basic process is straightforward:
Install XAMPP → Start Apache and MySQL → Download WordPress → Put WordPress in htdocs → Create a database → Run the WordPress installer → Start developing.
Once the installation is complete, your computer becomes a practical WordPress development environment. You can create themes, test plugins, troubleshoot errors, experiment with code, and prepare complete websites before deploying them to a production server.
For beginners, XAMPP also provides valuable experience with the technologies behind WordPress. Instead of seeing WordPress only through its dashboard, you begin to understand how Apache, PHP, databases, WordPress files, configuration settings, and browser requests work together.
That understanding can make WordPress development and troubleshooting much easier as your projects become more advanced.