Environment Setup
Prerequisites
Before setting up the local environment, ensure you have the following installed on your machine:
- Docker Desktop: Download and Install
- Docker Compose: Usually bundled with Docker Desktop.
- Git: To clone the repository.
Quick Start
Follow these steps to spin up a fully functional WordPress environment for development.
1. Clone the Repository
Start by cloning the repository to your local machine:
git clone https://github.com/UditAkhourii/wordpress.git
cd wordpress
2. Launch the Environment
The environment is containerized using Docker. Run the following command to download the necessary images and start the services:
docker-compose up -d
This command initializes:
- WordPress: Accessible via the web browser.
- MySQL: The database backend.
- phpMyAdmin: (Optional) For visual database management.
3. Access the Site
Once the containers are running, you can access the WordPress installation at:
- URL:
http://localhost:8080 - Admin Dashboard:
http://localhost:8080/wp-admin
Note: Default credentials (if not configured via a .env file) are typically set during the initial WordPress web setup wizard.
Configuration
Environment Variables
You can customize the environment by creating a .env file in the root directory. This allows you to define specific database names, credentials, and ports without modifying the core configuration.
# .env example
WORDPRESS_DB_NAME=wordpress_dev
WORDPRESS_DB_USER=admin
WORDPRESS_DB_PASSWORD=secret_pass
MYSQL_ROOT_PASSWORD=root_pass
Volume Mapping for Development
To develop plugins or themes locally and see changes in real-time, the docker-compose.yml is configured to map local directories to the container.
- Plugin Development: Place your code in the
/pluginsdirectory. - Theme Development: Place your code in the
/themesdirectory.
These folders are synchronized with /var/www/html/wp-content/... inside the container.
Using WP-CLI
The environment includes WP-CLI support for managing your WordPress installation via the command line. To run WP-CLI commands, use the docker compose exec interface:
# Example: List all installed plugins
docker-compose exec wordpress wp plugin list
# Example: Regenerate thumbnails
docker-compose exec wordpress wp media regenerate --yes
Stopping the Environment
To shut down the environment while preserving your database data:
docker-compose stop
To remove the containers entirely (data in volumes will persist unless --volumes is specified):
docker-compose down
Troubleshooting
- Port Conflicts: If port
8080is already in use, modify theportsmapping indocker-compose.ymlto a different host port (e.g.,9000:80). - Permission Issues: On Linux/macOS, ensure your user has write permissions to the
/pluginsand/themesdirectories to allow WordPress to write configuration files if necessary.