A Beginner’s Journey Deploying WordPress with Elastic Beanstalk
As preparation for taking the AWS Solutions Architect – Associate exam, I am doing a few easy projects using the AWS console. My experience with WordPress is not foreign, as this site is built on WordPress through Softaculous in cPanel. So I thought deploying WordPress with Elastic Beanstalk would be an easy beginner project, one that many talked about, and decided to follow this guide by AWS.
Amazon Elastic Beanstalk is a platform as a service (PaaS), a fully managed service for deploying and scaling web apps developed with Java, .NET, Python, Docker and a few others on servers such as Apache and Nginx to name a few. All that’s needed choosing the right platform, configuring options for capacity, access, traffic and monitoring to create an environment to upload your code.
With the AWS free tier, I explored deploying an app with Elastic Beanstalk. I was surprised by how long it took to follow the guide, which may have been outdated. I ended up completing the deployment but had to skip a few steps.
A quick rundown of Deploying WordPress with Elastic Beanstalk
- Create RDS MySQL database (free tier eligible), filling in a master username and password, and initial database name. These details will be used in the Environment Properties when configuring Elastic Beanstalk.
- Configure Elastic Beanstalk environment:
- Choose Sample application
- PHP 8.2 version 4.0.1 at the time of writing
- Single instance (free tier eligible)
- Create a new service role, along with a (pre-configured) EC2 key pair and a new instance profile with the permissions it shows.
- Choose your VPC and specify subnet(s).
- Add Environment Properties as per the guide: RDS_HOSTNAME, RDS_PORT, RDS_DB_NAME, RDS_USERNAME, RDS_PASSWORD
- Submit to begin creating an environment
- Download WordPress from https://wordpress.org/download/releases/. I used version 6.3
- Once the Elastic Beanstalk environment has been built, upload and deploy the downloaded WordPress ZIP file.
Once the deployment is completed, visit the Elastic Beanstalk domain to check if it is working.
Error in deployment
I had an Nginx server error and had to follow additional steps on a separate guide. For some reason, the deployment created a WordPress folder in the EC2’s /var/www/html/ folder. The additional step was to move the contents of that WordPress folder into /var/www/html/.
This can be accomplished by SSH-ing into the EC2 instance with CloudShell using the key pair and then navigating to cd /var/www/html/
after sudo su
. Using the commands mv wordpress/* / var/www/html/
to move contents of the wordpress folder into var/www/html, followed by deleting the now empty wordpress folder with rm -rf wordpress
.
Learnings
Overall, this was a good exercise where I gained a deeper understanding of Elastic Beanstalk. During this process, I also had to overcome a few hurdles for a successful deployment which helped me learn a lot. These hurdles include:
- Rebuilding my messed-up default VPC and subnets, while understanding a bit more about CIDRs.
- SSH-ing into the EC2 instance using a Key Pair on CloudShell, and locally via Terminal.
- A deeper understanding of service roles and permissions with IAM.
This deployment is far from production-grade and won’t be able to handle loads. But this quick project enabled me to navigate around and learn more about the AWS Console, for free.