How to Host a WordPress Website on AWS EC2 – Step-by-Step Guide for Beginners [2025]

Want to launch your own WordPress website using Amazon EC2 but don’t know where to start?
In this easy guide, I’ll show you exactly how to host a WordPress site on an EC2 instance, even if you’re a complete beginner.

Let’s dive in!

What You’ll Need

  • A free AWS account
  • Basic knowledge of Linux commands
  • Domain name (optional for now)
  • 20 minutes of time

Step 1: Launch an EC2 Instance

  1. Go to your AWS dashboard
  2. Search and click EC2
  3. Click Launch Instance
  4. Choose Ubuntu 22.04 LTS (Free tier)
  5. Select t2.micro instance
  6. Click Next and configure like this:
    • Storage: 10–15 GB
    • Security Group: Allow HTTP (80) and SSH (22)
  7. Launch the instance and download your .pem key file

Step 2: Connect to EC2 via SSH

On your local terminal:

chmod 400 your-key.pem
ssh -i "your-key.pem" ubuntu@your-ec2-ip

Now you’re inside your EC2

Step 3: Install LAMP Stack (Linux, Apache, MySQL, PHP)

sudo apt update
sudo apt install apache2 mysql-server php php-mysql libapache2-mod-php php-cli unzip -y

Test Apache:
Visit http://your-ec2-ip in your browser. You should see Apache2 Ubuntu Default Page.

Step 4: Create a MySQL Database for WordPress

sudo mysql

Then run:

CREATE DATABASE wordpress;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'strongpassword';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Step 5: Download and Set Up WordPress

cd /tmp
curl -O https://wordpress.org/latest.zip
unzip latest.zip
sudo mv wordpress /var/www/html/
sudo chown -R www-data:www-data /var/www/html/wordpress

Step 6: Configure Apache

Create a config file:

sudo nano /etc/apache2/sites-available/wordpress.conf
<VirtualHost *:80>
    ServerAdmin admin@example.com
    DocumentRoot /var/www/html/wordpress
    ServerName yourdomain.com

    <Directory /var/www/html/wordpress>
        AllowOverride All
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Then run:

sudo a2ensite wordpress.conf
sudo a2enmod rewrite
sudo systemctl restart apache2

Step 7: Final WordPress Setup

  • Visit: http://your-ec2-ip/wordpress
  • Choose language → Enter database info → Finish setup
  • Set site title, admin user, and password
  • Done!

Bonus: Point a Domain Name (Optional)

Use your domain registrar’s DNS settings:

  • Point A Record to your EC2 IP

Use services like Cloudflare for free SSL, DNS, and CDN!

How to Monetize This Setup

  • Add Google AdSense to your WordPress site
  • Add affiliate links for hosting, themes, and plugins
  • Offer EC2 setup as a paid service

Final Thoughts

Hosting WordPress on AWS EC2 gives you full control and performance at low cost — even free in the first year. With this setup, you’re not just learning DevOps skills… you’re building your own online empire!

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *