EC2 WordPress

Setting Up WordPress on Amazon EC2

This is part 2 in our series on running WordPress on the cloud. In this page, we briefly review how to install and manage WordPress on Amazon EC2. See Part 1: What it Means to Move WordPress to the Public Cloud.

Source: Flickr, Robert Scoble

EC2 is Amazon Web Services’ compute cloud—a service that allows you to “rent” computing power on demand and pay per use. You can start from just one basic machine instance, which is offered on Amazon free for one year, and scale up to hundreds or even thousands of machines on demand.

However, setting up WordPress on Amazon, making it production ready and scaling up requires technical expertise and can be prohibitively complex. In this page we'll discuss the complexities you can expect when taking your WordPress site to EC2, and how Pantheon's cloud-based enterprise WordPress hosting can help you get many of the same benefits without the complexity.

Installing WordPress on an Amazon EC2 Linux Machine Instance

This method involves starting an Amazon EC2 machine instance running Linux, and manually installing WordPress and the dependencies needed to make it work.

The general steps are:

  1. Create a Free Tier Linux machine instance, and getting the key pair that will allow you to log in using SSH.
  2. Connect via SSH—this involves identifying the Public DNS address of your Amazon instance, connecting using the console, and switching to root user.
  3. Install Apache Web Server using the command yum install httpd
  4. Run the Apache Web Server and test your site via a web browser.
  5. Install PHP using the command yum install php php-mysql
  6. Restart Apache Web Server and verify that PHP works by creating a test PHP file.
  7. Install MySQL using the command yum install mysql-server
  8. Start the MySQL server and create your database using the command mysqladmin -uroot create blog
  9. Secure your database using the command mysql_secure_Installation
  10. Switch to the /var/www/html directory, download WordPress using the command wget, and uncompress it.
  11. Create the wp-config.php file and set the database connection parameters.
  12. Associate an IP to your machine instance using the AWS Management Console, Elastic IPs option.
  13. Map your domain name to the IP using your domain registration service.

For the full process and more details, see the detailed blog post by Christophe Coenraets (Christophe promises you can do the above in 5 minutes—we don’t believe it :)

Next Steps after Setting Up a WordPress Instance

After you get your first WordPress instance up on Amazon EC2, you will have to do the following:

Secure your instance: Lock down unnecessary ports, set up SSH access, start a regular process of patching your instance and monitor for security issues using a system like Amazon CloudWatch. See Amazon’s basic security tutorial and details on using Amazon CloudWatch (or see how to do it with a third party monitoring tool—Nagios).

Set up caching: For optimal performance we recommend setting up Varnish as your reverse-proxy cache and Redis as an object cache. Here is a blog post by David Jensen explaining how to set up Varnish on an Amazon Web Services instance, and another by Redis Labs with best practices for setting up Redis on Amazon Web Services.

Set up your backup strategy: Amazon offers a variety of backup and recovery options. You will probably opt to save your WordPress static files to Amazon S3 and ensure high availability for your database by using Amazon’s Relational Database Service. Another option is to back up your entire WordPress instance using Amazon’s Glacier service—see this post by Delicious Brains on how to do that.

Define a load balancer and set up auto-scaling: To enable your Amazon EC2 application to scale automatically based on different conditions, you first need to set up Amazon Elastic Load Balancing. This involves configuring a listener and network info for load balancing, assigning security groups to the load balancer, configuring security settings, configuring health checks for Amazon EC2 instances, registering your Amazon EC2 instances with the load balancer, and verifying the load balancer (see Amazon’s Elastic Load Balancing tutorial). Afterwards you need to define auto-scaling in Amazon by defining a “launch configuration” for new instances, creating an auto-scaling group, and verifying that the auto scaling group is launched by the load balancer (see the Amazon application auto scaling tutorial).

Set up failover on top of Amazon load balancing: If an Amazon EC2 machine instance fails for any reason, that means your site is down for those users interacting with that machine instance (if there is more than one instance, the site is still active for some users). You can use the Elastic Load Balancer to perform failover of traffic from a failing instance to another live instance and then heal the instance that experienced problems. Amazon also allows you to do this across Availability Zones so that if an entire Amazon data center goes down, your site visitors can be shifted to another data center. Here is a blog post from GoSquared explaining how to define failover on Amazon EC2.

These are the basic items, and there are more things you will need to take care of as you grow on the cloud, including automated provisioning of dev, test and production environments, site access strategy using Amazon’s IAM service, setting up continuous integration, gaining visibility as to how your site is currently deployed and performing on Amazon, and more.

WordPress on the Cloud—How Pantheon Can Help

Pantheon is an enterprise-grade WordPress hosting service that runs on the public cloud. Using the power of the cloud, Pantheon can scale you from a tiny site with no traffic to “internet famous” in seconds. We do it with an automated container-based platform that runs on “bare metal” cloud infrastructure, and is an order of magnitude faster than the traditional virtualized cloud machine instances, like the ones you get on Amazon EC2.

Instead of having to work hard to setup WordPress on a machine instance and set up security, monitoring, caching, backup, scalability, and high availability on Amazon EC2 as we described above, on Pantheon you can get all these built in. Pantheon provides security, automatic scaling, high performance and high availability—tested and working out of the box at the click of a button.

Also, you’ll get immediate access to advanced DevOps and workflow automation features, so you can develop like the pros, as if you were on your own local server. You can do all this on Amazon but you’re on your own—you need to build your infrastructure from the ground up.



Try Pantheon for free to experience the power of auto-scaling on the cloud, unmatched performance, security and other enterprise features, including a modern, collaborative development workflow.

Next Up in this Series

Learn how to set up WordPress on more public clouds: