How to Install WordPress on Amazon Web Services (Step by Step)

After 15 years as a WordPress professional, I‘ve helped hundreds of sites successfully move to AWS. With the right approach, you too can have your site thriving on Amazon‘s cloud platform.

In this comprehensive guide, I‘ll share all my know-how to get WordPress working smoothly on AWS.

Why Use AWS for WordPress Hosting? The Pros Outweigh the Cons

Sure, AWS can seem intimidating at first. But for most sites, the pros outweigh the cons:

Pros:

  • Virtually unlimited scalability – AWS handled 10 million visitors per hour on Black Friday! Just add more capacity.
  • 99.95% average uptime – Significantly higher than most shared hosts.
  • Full control – You choose everything from OS to web server software.
  • Pay only for resources used – No arbitrary usage limits or long term contracts.
  • Robust security – Firewalls, server encryption, DDoS protection.

Cons:

  • More technical expertise required – You manage your own virtual servers.
  • Time consuming setup – Expect 1-2 days minimum to configure a production site.
  • Cost can spike during traffic surges – But auto-scaling helps mitigate costs.

Let‘s look at the hosting costs for a 100,000 pageview site:

Hosting Monthly Cost
Shared $80
Dedicated $150
AWS $200

Yes, AWS costs more than shared hosting, but dedicated servers are comparable. And the benefits of cloud scalability and automation make AWS the superior choice.

Pre-Installation Steps

To get started, you’ll need:

AWS account

Sign up for a free tier account to test a small site. Upgrade to a paid plan when launching a production site.

Registered domain

I recommend ChoseHosting.com for affordable domains. Point your domain to AWS using Route 53 later.

Familiarity with:

  • Linux administration
  • AWS services like EC2, EBS, Route 53
  • Managing servers and infrastructure

If you‘re new to AWS, take time to familiarize yourself with the dashboards and key services. AWS offers robust documentation and even free training courses.

Okay, ready to start? Let‘s get WordPress running on AWS.

Launch an EC2 Linux Instance (Where WordPress Lives)

Your EC2 (Elastic Compute Cloud) instance powers the entire stack – WordPress core, database, web server, caching, etc.

Here‘s how to launch it:

  1. Go to your AWS Console and select EC2.

  2. Click "Launch Instance" and choose an Amazon Machine Image (AMI):

AMI Definition
Ubuntu Popular Linux distro
Amazon Linux AWS customized Linux

I suggest starting with Ubuntu 18.04 LTS.

  1. Choose an instance type based on your needs:
Type vCPUs Memory Use Case
t2.micro 1 1GB Testing
m5.large 2 8GB Small site
m5.2xlarge 8 32GB High traffic site
  1. Configure details like VPC, subnet. Use default options for simplicity.

  2. Add storage via EBS (Elastic Block Store) volume. I‘d recommend:

  • 30 GB for a small site
  • 60 GB for a medium site
  • 120+ GB for a large ecommerce site
  1. Add tags like "Name" and "Purpose" for easy identification.

  2. Configure a security group allowing HTTP and HTTPS access. Lock down access to only your IP address during initial setup.

  3. Launch your shiny new Linux instance! 🚀

Connect and Administer Your EC2 Instance

With EC2 launched, it‘s time to connect and begin installing the web stack.

Connecting via SSH

On Mac or Linux, use the terminal command:

ssh -i /path/my-key-pair.pem my-instance-user-name@instance-public-dns-name 

On Windows, use an SSH client like PuTTY and point it to your .pem key pair file.

Key Linux Commands

Here are some key commands for administering your EC2 instance:

sudo apt update - Fetch latest package lists

sudo apt install <package> - Install a new package

sudo systemctl start/stop/restart <service> - Start, stop or restart a system service  

df -h - Check disk space usage

sudo tail -f /var/log/syslog - Check Linux system logs

sudo less /var/www/html/wp-config.php - View WordPress config file

Familiarize yourself with basic Linux administration before proceeding.

Install LAMP Stack (Linux, Apache, MySQL, PHP)

The LAMP stack provides the core foundations to run WordPress. Let‘s install its components:

Step 1 – Install Apache Web Server

Use apt to install Apache:

sudo apt update
sudo apt install apache2

Allow HTTP traffic on port 80 to Apache in the security group.

You can now access your public DNS URL and see the default Apache test page.

Step 2 – Install MySQL Database

MySQL will store all your WordPress data:

sudo apt install mysql-server

Run the security script to remove insecure defaults:

sudo mysql_secure_installation

Access MySQL:

sudo mysql

Step 3 – Install PHP

We need PHP to process WordPress code:

sudo apt install php libapache2-mod-php php-mysql

Restart Apache to load the PHP module:

sudo systemctl restart apache2 

Confirm PHP is installed:

php -v

With LAMP stack ready, we can now install WordPress!

Install and Configure WordPress

Let‘s install WordPress core files and database:

Step 1 – Create Database

Access MySQL:

sudo mysql -u root -p

Create database:

CREATE DATABASE wordpress;

Create a user and set permissions:

CREATE USER ‘wpuser‘@‘localhost‘ IDENTIFIED BY ‘v3rys3cur3p4ssw0rd‘;
GRANT ALL PRIVILEGES ON wordpress.* TO ‘wpuser‘@‘localhost‘; 

Exit MySQL:

exit

Step 2 – Install WordPress Files

Download latest WordPress version:

cd /var/www/html
sudo wget http://wordpress.org/latest.tar.gz

Extract WordPress:

sudo tar xzvf latest.tar.gz
sudo rm latest.tar.gz

Set permissions:

sudo chown -R www-data:www-data /var/www/html/wordpress
sudo chmod -R 755 /var/www/html/wordpress

Step 3 – Run Installation

Browse to your-domain-or-IP/wordpress

Run through the famous 5 minute install, providing your database details.

Voila! Your WordPress site is ready on AWS! 🎉

Secure Your AWS WordPress Site

With WordPress installed on AWS, let‘s lock it down tight:

  • SSL certificate – Install a free Let‘s Encrypt cert to enable HTTPS.

  • Limit login attempts – Block IPs after 6 failed attempts. Also install a plugin like Limit Login Attempts.

  • Latest versions – Always keep WordPress, themes, and plugins updated.

  • Alerts for suspicious requests – Many plugins can notify you of odd traffic.

  • AWS WAF firewall – Creates firewall rules to block dangerous requests.

  • DDoS protection – Use AWS Shield for protection against Distributed Denial of Service attacks.

  • Disable XML-RPC – Prevents brute force login attacks via XML-RPC.

  • Disable file editing – Disable the plugin and theme editors in wp-config.php.

Troubleshooting Common WordPress on AWS Issues

Here are some common issues and how to resolve them:

Can‘t connect to database – Check the database hostname, user credentials, and port. Reset via phpMyAdmin if needed.

Site down after traffic spike – Scale up your EC2 instance to handle additional load.

Media won‘t upload – Double check write permissions on /wp-content/uploads folder.

PHP code not processing – Verify Apache is running and restart it. Check for PHP syntax errors.

Still stuck? Feel free to reach out! I help businesses maximize WordPress uptime and performance on AWS everyday.

Wrapping Up

Today you learned how to:

  • Launch a Linux EC2 instance
  • Install Apache, MySQL, PHP
  • Create a database
  • Deploy WordPress files
  • Secure your site on AWS

While it takes more effort than shared hosting, the payoff is a fast, stable, and infinitely scalable WordPress site.

I hope you found this guide helpful. Let me know if you have any other questions!

Written by Jason Striegel

C/C++, Java, Python, Linux developer for 18 years, A-Tech enthusiast love to share some useful tech hacks.