Local Environment Setup
Prerequisites
Before setting up the local environment, ensure you have the following software installed on your machine:
- Docker Desktop: Required to run the containers for WordPress, MySQL, and the testing environment.
- Node.js (LTS): Required for running the build tools and managing packages.
- NPM: Installed automatically with Node.js.
Initial Installation
Clone the repository and install the project dependencies. This will include the @wordpress/env tool used to manage the local Docker infrastructure.
# Clone the repository
git clone https://github.com/UditAkhourii/wordpress.git
cd wordpress
# Install dependencies
npm install
Running the Development Environment
The project uses wp-env to abstract the Docker configuration. This tool automatically pulls the necessary images, configures the database, and maps the local directories to the WordPress container.
To start the local server, run:
npx wp-env start
Once the command completes, your local environment will be accessible at:
- WordPress Site: http://localhost:8888
- WordPress Admin: http://localhost:8888/wp-admin
Default Access Credentials
For the local development environment, use the following default credentials to log in to the admin dashboard:
| Username | Password |
| :--- | :--- |
| admin | password |
Database Services
The database is managed internally by Docker and wp-env. You do not need to manually create a database or configure a wp-config.php file for local development; wp-env handles this automatically upon startup.
If you need to run CLI commands against the database (via WP-CLI), you can do so through the wp-env wrapper:
# Example: List users in the local database
npx wp-env run cli wp user list
Managing the Environment
Use these commands to control the state of your local containers:
| Command | Description |
| :--- | :--- |
| npx wp-env stop | Stops the running containers without deleting data. |
| npx wp-env clean all | Stops containers and deletes all data (database, uploads). |
| npx wp-env logs | Displays the real-time logs from the Docker containers. |
Custom Configuration (Optional)
If you need to override the default ports, PHP versions, or map additional directories, you can create a .wp-env.override.json file in the root directory.
{
"port": 9000,
"core": "https://wordpress.org/latest.zip",
"phpVersion": "8.1"
}
Note: The .wp-env.json file is considered an internal configuration file for the project's standard environment. Use the override file for local machine-specific adjustments.