In this guide, I'll walk you through deploying WordPress on AWS using EC2 and RDS. We'll focus on the essential steps to get your WordPress site up and running.
1. Setting Up RDS (Free Tier)
First, let's create our MySQL database:
Go to AWS RDS Console and click "Create Database"
Choose these settings:
- Database creation method: Standard - Engine type: MySQL - Edition: MySQL Community - Version: 8.0.39 - Templates: Free tier - DB instance identifier: wordpress-db - Master username: wordpress_user - Master password: [your-secure-password] - Instance configuration: db.t3.micro - Storage: 20 GB - Public access: No
2. Setting Up EC2 Instance
Now, let's create our web server:
Go to EC2 Console and click "Launch Instance"
Configure:
- Name: WordPressWebsite - AMI: Ubuntu 24.04 LTS - Instance type: t2.micro - Key pair: Create new or select existing - Security group settings: * Allow SSH (22) * Allow HTTP (80) * Allow HTTPS (443)
3. Installing Required Packages
SSH into your EC2 instance and run these commands:
# Update system
sudo apt update && sudo apt upgrade -y
# Install Apache
sudo apt install apache2 -y
sudo systemctl start apache2
sudo systemctl enable apache2
# Install MySQL client
sudo apt install mysql-client -y
# Install PHP and required extensions
sudo apt install php libapache2-mod-php php-mysql php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip -y
4. Verifying Setup
Let's verify PHP and RDS connectivity:
- Create PHP info page:
sudo nano /var/www/html/info.php
- Add this content:
<?php phpinfo(); ?>
- Test RDS connection:
mysql -h your-rds-endpoint -u wordpress_user -p
5. WordPress Database Setup
Set up the WordPress database:
- Connect to RDS:
mysql -h your-rds-endpoint -u wordpress_user -p
- Create database:
CREATE DATABASE wordpress_db;
- Download and configure WordPress:
cd /tmp
wget https://wordpress.org/latest.tar.gz
tar xzf latest.tar.gz
sudo mv /var/www/html/index.html /var/www/html/index.html.backup
sudo cp -r wordpress/* /var/www/html/
# Set permissions
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html
- Configure wp-config.php:
cd /var/www/html
sudo cp wp-config-sample.php wp-config.php
sudo nano wp-config.php
Update these lines:
define('DB_NAME', 'wordpress_db');
define('DB_USER', 'wordpress_user');
define('DB_PASSWORD', 'your-password');
define('DB_HOST', 'your-rds-endpoint');
6. Complete WordPress Installation
Open your browser and visit:
http://your-ec2-public-ip
Complete the setup form:
Site Title
Username
Password
Email
[Screenshot: WordPress installation page]
- After completion, you'll see the WordPress dashboard:
Verification Steps
To verify everything is working:
Log in to WordPress admin:
http://your-ec2-public-ip/wp-admin
Create a test post
Check if you can upload media
Verify database connectivity in the WordPress dashboard
Troubleshooting Common Issues
If you encounter problems:
Database connection issues:
Verify RDS security group allows traffic from EC2
Check credentials in wp-config.php
Confirm database exists
PHP/Apache issues:
Check Apache error logs:
sudo tail -f /var/log/apache2/error.log
Verify PHP modules:
php -m
Permission issues:
Reset permissions if needed:
sudo chown -R www-data:www-data /var/www/html sudo chmod -R 755 /var/www/html
Congratulations! You now have a working WordPress installation on AWS using EC2 and RDS!