Unleashing the Power of AWS: Launching Your Own WordPress Site with Docker on EC2!

Rajatrokde
2 min readAug 6, 2023

--

Step 1: Sign in to AWS Console
Visit the AWS Management Console and sign in to your AWS account.

Step 2: Launch EC2 Instance
1. Navigate to the EC2 dashboard.
2. Click on “Launch Instance” to create a new EC2 instance.
3. Choose an Amazon Machine Image (AMI) — Select a suitable Amazon Linux or Ubuntu Server image.
4. Select an Instance Type — Choose the instance size based on your requirements and budget.
5. Configure Instance Details — Optionally, customize settings like instance number, network, etc. For simplicity, you can stick with the default values.
6. Add Storage — Set the storage size for your instance. The default should be enough for a simple WordPress installation.
7. Add Tags (optional) — You can add tags to help organize your instances, but this step is optional.
8. Configure Security Group — Create a new security group or select an existing one to allow access to necessary ports like SSH (22) and HTTP (80).
9. Review — Review all the settings and click “Launch” if everything looks good.

Step 3: Connect to the EC2 Instance

1. Once your instance is launched, select it from the EC2 dashboard.
2. Click on “Connect” to get instructions on how to connect to your instance.

Step 4: Install Docker on EC2 Instance

1. Connect to your EC2 instance using SSH.
2. Update the package index: sudo apt update
3. Install necessary dependencies: sudo apt install apt-transport-https ca-certificates curl software-properties-common
4. Add the Docker repository key: curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg - dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
5. Add the Docker repository: echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
6. Update the package index again: sudo apt update
7. Install Docker: sudo apt install docker-ce
8. Start and enable Docker: sudo systemctl start docker and sudo systemctl enable docker
9. Add the current user to the "docker" group: sudo usermod -aG docker $USER
10. Log out and log back in to apply the group changes.

Step 5: Run WordPress in Docker

Replace <your_database_host>, <your_database_user>, <your_database_password>, and <your_database_name> with your actual database configuration.

Step 6: Access WordPress
Now that WordPress is running in the Docker container, you can access it by opening your EC2 instance’s public IP address in your web browser. The installation and setup for WordPress will begin.

That’s it! You now have an EC2 instance running Docker with WordPress inside the Docker container. Remember to follow AWS best practices for security and manage your resources responsibly.

Originally published at https://rajatrokde.hashnode.dev.

--

--