Local Environment Setup
Prerequisites
Before setting up the project locally, ensure your environment meets the following minimum requirements:
- PHP: version 7.4 or higher (8.1+ recommended).
- Database: MySQL 5.7+ or MariaDB 10.3+.
- Web Server: Apache (with
mod_rewriteenabled) or Nginx. - Composer: For managing PHP dependencies.
Quick Start with Docker (Recommended)
The fastest way to get the environment running is using Docker. This ensures all services (PHP, MySQL, and Web Server) are pre-configured.
-
Clone the repository:
git clone https://github.com/UditAkhourii/wordpress.git cd wordpress -
Start the containers:
docker-compose up -d -
Access the site: Open
http://localhost:8080in your browser to complete the WordPress installation wizard.
Manual Installation
If you prefer to use a local stack (like Herd, Valet, XAMPP, or manual LEMP/LAMP), follow these steps:
1. Database Setup
Create a new MySQL database and a user with full privileges:
CREATE DATABASE wordpress_db;
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wp_user'@'localhost';
FLUSH PRIVILEGES;
2. Configure WordPress
Copy the sample configuration file and update the database credentials:
cp wp-config-sample.php wp-config.php
Edit wp-config.php with your local details:
// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress_db' );
/** Database username */
define( 'DB_USER', 'wp_user' );
/** Database password */
define( 'DB_PASSWORD', 'your_password' );
/** Database hostname */
define( 'DB_HOST', 'localhost' );
3. Install Dependencies
If the project includes custom themes or plugins managed by Composer, run:
composer install
Web Server Configuration
Apache (.htaccess)
Ensure your .htaccess file is present in the root directory to handle WordPress permalinks. The standard configuration is:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Nginx
Add the following directive to your server block configuration:
location / {
try_files $uri $uri/ /index.php?$args;
}
Environment Verification
Once the setup is complete, you can verify the installation by accessing the WordPress dashboard:
- URL:
http://localhost/wp-admin - Health Check: Navigate to Tools > Site Health in the dashboard to ensure all PHP extensions and server configurations are optimal for development.