Developing WordPress websites locally is a game changer. It lets you build and test changes in a safe environment, without affecting the live site or depending on a slow internet connection.
Whether you’re debugging a plugin, developing a custom theme, or experimenting with configurations, a local setup is your best friend.
This guide walks you through how to set up WordPress for local development on Windows, macOS, and Linux, using tools like XAMPP, MAMP, LocalWP, and Docker. We’ll also cover best practices and include helpful code examples to get you started quickly.
What Is Local Development?
Local development means running WordPress on your own computer instead of a remote server. You simulate a web server environment using tools that install:
- PHP: The scripting language WordPress is built on
- MySQL: The database that stores WordPress content
- Apache or Nginx: Web servers to handle requests
This setup is often called a LAMP stack (Linux, Apache, MySQL, PHP) or MAMP (Mac equivalent).
Why It Matters
- Instant feedback while coding
- No downtime risks
- Full control over versions and settings
- Easier debugging and performance testing
Platform-Specific Setup
🪟 Windows
Option 1: XAMPP
- Download XAMPP from apachefriends.org.
- Install and launch Apache and MySQL.
- Place your WordPress files in
C:\xampp\htdocs\your-site-name
. - Access
http://localhost/your-site-name
in your browser. - Create a new database via
http://localhost/phpmyadmin
.
Option 2: LocalWP (Recommended for beginners)
- Download LocalWP from localwp.com.
- Create a new WordPress site with one click.
- Local handles server setup, database, and SSL automatically.
🍎 macOS
Option 1: MAMP
- Download MAMP from mamp.info.
- Move WordPress into
/Applications/MAMP/htdocs/your-site
. - Start servers from the MAMP interface.
- Visit
localhost:8888/your-site
to install WordPress.
Option 2: LocalWP
LocalWP also works seamlessly on macOS, with no need for manual config.
🐧 Linux
Option 1: LAMP Stack (Manual Setup)
sudo apt update
sudo apt install apache2 mysql-server php php-mysql libapache2-mod-php php-cli unzip
- Download WordPress and extract it to
/var/www/html/your-site
. - Set permissions:
sudo chown -R www-data:www-data /var/www/html/your-site
- Create a MySQL database:
sudo mysql -u root
CREATE DATABASE wordpress;
GRANT ALL PRIVILEGES ON wordpress.* TO 'wp_user'@'localhost' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
Option 2: Docker Compose (Cross-platform)
Create a docker-compose.yml
file:
version: '3.8'
services:
wordpress:
image: wordpress
ports:
- "8000:80"
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DB_USER: wp_user
WORDPRESS_DB_PASSWORD: password
db:
image: mysql:5.7
environment:
MYSQL_DATABASE: wordpress
MYSQL_USER: wp_user
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: rootpass
Run with:
docker-compose up -d
Visit http://localhost:8000
to start the install.
WP-CLI: WordPress Command Line Interface
Install WP-CLI to manage WordPress via terminal:
wp core install \
--url=localhost \
--title="Dev Site" \
--admin_user=admin \
--admin_password=adminpass \
[email protected]
Other useful commands:
wp plugin install contact-form-7 --activate
wp theme install astra --activate
wp export > site.xml
Custom wp-config.php
Tweaks
Set debugging only for local:
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);
Managing Multiple Sites Locally
Use LocalWP or separate directories and ports with XAMPP/MAMP. Docker makes it easier to isolate projects.
Simple wp-config.php
Template
define('DB_NAME', 'wordpress');
define('DB_USER', 'wp_user');
define('DB_PASSWORD', 'password');
define('DB_HOST', 'localhost');
define('WP_DEBUG', true);
WP-CLI Theme Install
wp theme install twentytwentyfour --activate
Docker Compose File (Full Setup)
# Save as docker-compose.yml
version: '3.8'
services:
wordpress:
image: wordpress:latest
ports:
- "8080:80"
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: wp_user
WORDPRESS_DB_PASSWORD: password
WORDPRESS_DB_NAME: wp_db
db:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: wp_db
MYSQL_USER: wp_user
MYSQL_PASSWORD: password
Best Practices
- Match PHP/MySQL versions to your production environment.
- Use version control (Git) to track code changes.
- Don’t use real credentials in local setups.
- Back up your database before testing big changes.
- Set WP_DEBUG true only locally to avoid exposing errors in production.
Conclusion
Setting up WordPress for local development gives you more freedom, faster feedback, and a safer space to experiment. Whether you’re on Windows, macOS, or Linux, there’s a local development option that fits your workflow.
🚀 How Sitebox Solves Local Setup Challenges
Sitebox takes the headache out of local WordPress development:
- One-click environments for any OS
- Version-matching with production
- Built-in collaboration and previews
- No server config or Docker needed
It’s perfect for freelancers, agencies, or teams who want reliable local workflows without overhead.
Next Steps:
- Choose a local development tool based on your OS
- Follow the setup steps and build your first local WordPress site
- Try Sitebox for scalable, shareable development environments
Need a Sitebox invite or help installing Docker? Drop a comment below or get in touch!