Hosting a WordPress blog/website on the AWS EC2 platform can be pretty useful when you know how to maintain Linux servers and want to keep your cost down. (Free for your account first year / then around 10-30 €/month) This is great for a small personal blog where you’ll do the maintenance and scalability yourself. (OS, databases and WordPress upgrades) If you need something more robust and scalable, I usually advise going for an AWS elastic beanstalk application to have the database and EC2 maintained and scaled automatically. (More like 30-60€/month)
In this post, I’ll show you how I like to host WordPress on EC2 with a Let’s Encrypt SSL certificate.
Start by following the, up to date, AWS documentation on how to install WordPress on EC2 and register your domain on Route 53 :
- Register your domain name on AWS Route 53 (or other) :
- Install a clean WordPress blog on EC2 (Free-tier available) :
- Route the traffic from your Route 53 domain to the EC2 instance through an Elastic IP :
- Routing Traffic to an Amazon EC2 Instance
- Once you are routing the Traffic to the WordPress, you may have an issue logging in as it redirects to the old EC2 URL. To fix it, run the following command with your server information on the Linux server :
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
php wp-cli.phar search-replace 'ec2-XXXXXX.compute.amazonaws.com' 'YOURDOMAINNAME.com' --path=/var/www/html --skip-columns=guid
Once this is set up and you have your ssh access run those commands :
Once all of those commands are successful, I usually install the ReallySimpleSSL Plugin to modify all your WordPress files to be SSL compliant.
That’s it your website is automatically redirected to https! (Look for the green lock next to your URL)
Note: If after all those steps you can’t load your site, check your EC2 Security Group Inbound Rules, it needs to allow SSL protocol everywhere.