By the end of this lesson, you will:
WordPress is one of the most popular platforms for building websites, from blogs to e-commerce stores. Deploying WordPress on AWS using EC2 and RDS provides scalability, reliability, and performance.
In this chapter, we’ll guide you step-by-step to deploy WordPress, with EC2 hosting the application and RDS managing the database.
WordPressDB
.admin
.MySecurePassword123
.wordpressdb.xxxxxxx.us-east-1.rds.amazonaws.com
).t2.micro
.
ssh -i “your-key.pem” ec2-user@your-ec2-public-ip
sudo yum update -y
sudo yum install httpd -y
sudo systemctl start httpd
sudo systemctl enable httpd
sudo amazon-linux-extras enable php8.0
sudo yum install php php-mysqlnd -y
cd /var/www/html
wget https://wordpress.org/latest.tar.gz
tar -xvzf latest.tar.gz
mv wordpress/* .
rm -rf wordpress latest.tar.gz
sudo chown -R apache:apache /var/www/html
sudo chmod -R 775 /var/www/html
mv wp-config-sample.php wp-config.php
nano wp-config.php
define(‘DB_NAME’, ‘MyAppDB’);
define(‘DB_USER’, ‘admin’);
define(‘DB_PASSWORD’, ‘MySecurePassword123’);
define(‘DB_HOST’, ‘wordpressdb.xxxxxxx.us-east-1.rds.amazonaws.com’);
define(‘DB_CHARSET’, ‘utf8’);
define(‘DB_COLLATE’, ”);
Ctrl + O
, Enter
, and Ctrl + X
to save and exit.http://your-ec2-public-ip
).By separating the web server (EC2) and database (RDS), you create a more modular, scalable, and secure architecture.
In the next chapter, we’ll explore Hosting a Static Website with S3 and CloudFront, introducing you to serverless hosting.
Your WordPress deployment is complete—let’s build more applications!