Setting Up Local WordPress Development
Learning Objectives
- Understand the importance of local development environments
- Install and configure Local by Flywheel
- Set up WordPress with XAMPP/MAMP
- Get introduced to Docker for WordPress development
- Compare different local development options
- Create your first local WordPress site
Introduction
Local development is essential for WordPress developers. It allows you to build, test, and experiment with WordPress sites on your own computer without needing web hosting or affecting live sites.
Local Development Options
Comparison of Local Development Tools
Local by Flywheel (Recommended for Beginners)
What is Local?
Local (formerly Local by Flywheel) is a free, WordPress-specific local development application. It's the easiest way to get WordPress running on your computer.
Key Features
- One-click WordPress installation
- SSL supportfor https:// testing
- Live Linkto share local sites temporarily
- Multiple PHP versions(5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1)
- Multiple sitesmanagement
- MailHogfor email testing
- Database managementwith Adminer
- Blueprintfor site templates
Installation Steps
Step-by-Step Installation
-
Download Local
# Visit the official website https://localwp.com/ # Choose your operating system: - Windows (64-bit) - macOS (Intel or Apple Silicon) - Linux (Ubuntu/Debian) -
Install the Application
- Run the downloaded installer
- Follow installation wizard
- Accept terms and choose installation directory
-
Create Your First Site
# Site Setup Site Name: my-first-wordpress Local Site Domain: my-first-wordpress.local Local Site Path: ~/Local Sites/my-first-wordpress # Environment Setup PHP Version: 8.0.22 Web Server: nginx Database: MySQL 8.0.16 # WordPress Setup WordPress Username: admin WordPress Password: admin WordPress Email: admin@example.com
XAMPP Setup
What is XAMPP?
XAMPP is a free, open-source cross-platform web server solution stack containing Apache, MySQL, PHP, and Perl. It requires manual WordPress installation but offers more flexibility.
XAMPP Components
Installing WordPress on XAMPP
-
Download and Install XAMPP
# Download from https://www.apachefriends.org/ # Default installation paths: Windows: C:\xampp macOS: /Applications/XAMPP Linux: /opt/lampp -
Start Apache and MySQL
# Open XAMPP Control Panel # Click "Start" for: - Apache (Web Server) - MySQL (Database Server) # Verify at: http://localhost/ -
Create Database
# Access phpMyAdmin http://localhost/phpmyadmin/ # Create new database Database name: wordpress_local Collation: utf8mb4_general_ci -
Download and Extract WordPress
# Download WordPress https://wordpress.org/download/ # Extract to: Windows: C:\xampp\htdocs\wordpress macOS: /Applications/XAMPP/htdocs/wordpress Linux: /opt/lampp/htdocs/wordpress -
Run WordPress Installation
# Navigate to http://localhost/wordpress/ # Database Configuration Database Name: wordpress_local Username: root Password: (leave blank for XAMPP) Database Host: localhost Table Prefix: wp_
MAMP Setup
What is MAMP?
MAMP (Mac, Apache, MySQL, PHP) is similar to XAMPP but originally designed for macOS. It now supports Windows too. MAMP provides both free and Pro versions.
MAMP vs MAMP Pro
| Feature | MAMP (Free) | MAMP Pro |
|---|---|---|
| Virtual Hosts | Limited | Unlimited |
| Mobile Testing | ❌ | ✅ |
| Email Testing | ❌ | ✅ (Mailhog) |
| Dynamic DNS | ❌ | ✅ |
| Snapshot Backups | ❌ | ✅ |
| Price | Free | $59 |
Docker Introduction
What is Docker?
Docker uses containerization to create isolated development environments. It's more advanced but offers the most flexibility and closest match to production environments.
Basic Docker WordPress Setup
# docker-compose.yml
version: '3.8'
services:
wordpress:
image: wordpress:latest
ports:
- "8080:80"
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
volumes:
- ./wordpress:/var/www/html
db:
image: mysql:5.7
environment:
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
MYSQL_ROOT_PASSWORD: somewordpress
volumes:
- db_data:/var/lib/mysql
phpmyadmin:
image: phpmyadmin
ports:
- "8081:80"
environment:
PMA_HOST: db
volumes:
db_data:
# Run with:
# docker-compose up -d
Choosing the Right Tool
Decision Matrix
Local Development Best Practices
- Use Version Control:Initialize Git in your local WordPress projects
- Match PHP Versions:Use the same PHP version as your production server
- Regular Backups:Export your local databases regularly
- Consistent URLs:Use .local or .test domains for local sites
- Security:Use strong passwords even in local development
- Documentation:Document your local setup and configurations
- Testing:Test with debugging enabled (WP_DEBUG = true)
Common Local Development Workflow
1. Set Up Local Environment
└── Install Local by Flywheel
└── Create new WordPress site
└── Configure PHP version and database
2. Development Process
└── Clone or create theme/plugin
└── Enable debugging in wp-config.php
└── Install development plugins (Debug Bar, Query Monitor)
└── Make changes and test locally
3. Version Control
└── Initialize Git repository
└── Create .gitignore for WordPress
└── Commit changes regularly
└── Push to GitHub/GitLab/Bitbucket
4. Database Management
└── Export local database
└── Search/replace local URLs
└── Import to staging server
└── Test on staging
5. Deployment
└── Push code to production
└── Migrate database if needed
└── Clear caches
└── Verify functionality
Troubleshooting Common Issues
Port Conflicts
# Check if port 80 is in use (Apache)
Windows: netstat -ano | findstr :80
Mac/Linux: sudo lsof -i :80
# Check if port 3306 is in use (MySQL)
Windows: netstat -ano | findstr :3306
Mac/Linux: sudo lsof -i :3306
# Solutions:
1. Stop conflicting services (Skype, IIS, etc.)
2. Change ports in configuration
3. Use Local (handles ports automatically)
Database Connection Errors
# Common wp-config.php settings
define('DB_NAME', 'wordpress');
define('DB_USER', 'root'); // XAMPP/MAMP default
define('DB_PASSWORD', ''); // Empty for XAMPP
define('DB_HOST', 'localhost'); // or 127.0.0.1
# For MAMP on Mac:
define('DB_HOST', 'localhost:8889');
File Permission Issues
# WordPress recommended permissions
Directories: 755
Files: 644
wp-config.php: 600
# Fix permissions (Mac/Linux)
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
Practice Exercise
Set up your first local WordPress development environment:
Practice Assignment
Complete the following tasks to master local WordPress development:
-
Environment Setup:
- Install Local by Flywheel
- Create 3 different WordPress sites
- Try different PHP versions
-
XAMPP Alternative:
- Install XAMPP
- Manually install WordPress
- Document the process
-
Site Configuration:
- Change permalink structure
- Install and activate 5 plugins
- Switch between 3 themes
- Create sample content (5 posts, 3 pages)
-
Database Practice:
- Export your database
- Create a database backup
- Explore database structure
-
Documentation:
- Write a setup guide for your environment
- List any issues you encountered and solutions
- Create a local development checklist