{"id":161138,"date":"2017-01-24T13:00:06","date_gmt":"2017-01-24T13:00:06","guid":{"rendered":"https:\/\/premium.wpmudev.org\/blog\/?p=161138"},"modified":"2017-08-09T08:57:47","modified_gmt":"2017-08-09T08:57:47","slug":"host-wordpress-multiple-aws-server-instances","status":"publish","type":"post","link":"https:\/\/wpmudev.com\/blog\/host-wordpress-multiple-aws-server-instances\/","title":{"rendered":"How to Host Your WordPress Site on Multiple AWS Server Instances"},"content":{"rendered":"<p>You&#8217;ve almost definitely heard about Amazon Web Services. And, given that you&#8217;re on this site, I&#8217;m going to make the obvious assumption that you&#8217;ve heard about WordPress, too. But what you might not have heard about is combining WordPress with <a href=\"https:\/\/aws.amazon.com\" rel=\"noopener\" target=\"_blank\">Amazon Web Services<\/a> (AWS) for web hosting.<\/p>\n<p>Articles about <a href=\"https:\/\/wpmudev.com\/blog\/shared-vps-dedicated-or-cloud-wordpress-hosting\/\" target=\"_blank\" rel=\"noopener\">hosting WordPress on shared hosting, CPanel hosting, managed hosting<\/a> and what have you are a dime a dozen. Yet AWS is yet another infrastructure that can be used to host your WordPress site. Not only that, but given that an AWS infrastructure is elastic, it&#8217;s a great place to set up a WordPress installation that can be autoscaled to meet demand.<\/p>\n<p>So in this article, let&#8217;s get down to the business of setting up a WordPress site on multiple instances of AWS servers.<\/p>\n<p><strong>Note:<\/strong> Here&#8217;s a quick guide on how to <a href=\"https:\/\/wpmudev.com\/blog\/how-to-install-wordpress-on-aws\/\" target=\"_blank\" rel=\"noopener\">install WordPress on a single AWS instance<\/a> (like the one that comes with its Free Tier account). Once you know how to set up a WordPress installation on AWS, check out our articles on setting up WordPress for autoscaling to multiple instances to be able to handle spikes in traffic.<\/p>\n<h3>Step 1: Registering an AWS Account<\/h3>\n<p>First things first: If you still haven&#8217;t ever tried Amazon Web Services, head to <a href=\"https:\/\/aws.amazon.com\" rel=\"noopener\" target=\"_blank\">https:\/\/aws.amazon.com<\/a> and click on <strong>Create an AWS account<\/strong>.<\/p>\n<p>You can use your regular Amazon account to log in, but following the normal login you&#8217;re going to have to go through a process for verifying that there is an actual human behind the person registering the account. You&#8217;ll go through the process of filling in your details, actually verifying the account through a phone call, setting up a credit card for billing purposes and a whole host of other standard registration stuff.<\/p>\n<p>Once you get through the registration process, you should finally get access to the AWS Services Dashboard, which looks a little bit similar to this:<\/p>\n<figure class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-1364x1364 size-1364x1364\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2017\/01\/aws-servers.png\" alt=\"Wow \u2013 which server do I choose?\" width=\"1364\" height=\"742\" \/><figcaption class=\"wp-caption-text\">Wow \u2013 which server do I choose?<\/figcaption><\/figure>\n<p>If it&#8217;s the first time you&#8217;re getting access to this it&#8217;s a little overwhelming. There&#8217;s so much stuff to choose that you&#8217;ll actually get pretty confused if you&#8217;re not used to this.<\/p>\n<p>Let me run you through a few quick explanations of the most common instances you can use. Truth be told, I don&#8217;t even know what half of the services mean, but doesn&#8217;t have to worry me (or you) much!<\/p>\n<h4>EC2 &#8211; the Amazon Workhorse<\/h4>\n<p>Amazon Elastic Compute Cloud (Amazon EC2) is a web service that provides resizable compute capacity in the cloud. It is designed to make web-scale\u00a0<a href=\"https:\/\/aws.amazon.com\/what-is-cloud-computing\/\" target=\"_blank\">cloud computing<\/a>\u00a0easier for developers. In more simple terms, this is computing power on tap. You can simply start instances of virtual machines here which can be used for whatever you need to\u00a0run.<\/p>\n<h4>S3 &#8211; Storage on Demand<\/h4>\n<p>Amazon Simple Storage Service\u00a0(Amazon S3) is object storage (or disk space) with a simple web service interface to store and retrieve any amount of data from anywhere on the web. It is designed to deliver 99.999999999% durability, and scale past trillions of objects worldwide. Simply put, it is very reliable and can get very very big (should you need to). Services such as DropBox are powered by S3.<\/p>\n<h4>RDS &#8211; Relational Database in the Cloud<\/h4>\n<p>Amazon Relational Database Service (Amazon RDS) makes it easy to set up, operate, and scale a\u00a0<a href=\"https:\/\/aws.amazon.com\/relational-database\/\" rel=\"noopener\" target=\"_blank\">relational database<\/a>\u00a0in the cloud.\u00a0Amazon RDS provides you six familiar database engines to choose from, including\u00a0<a href=\"https:\/\/aws.amazon.com\/rds\/aurora\/\" target=\"_blank\">Amazon Aurora<\/a>,\u00a0<a href=\"https:\/\/aws.amazon.com\/rds\/postgresql\/\" target=\"_blank\">PostgreSQL<\/a>,\u00a0<a href=\"https:\/\/aws.amazon.com\/rds\/mysql\/\" target=\"_blank\">MySQL<\/a>,\u00a0<a href=\"https:\/\/aws.amazon.com\/rds\/mariadb\/\" target=\"_blank\">MariaDB<\/a>,\u00a0<a href=\"https:\/\/aws.amazon.com\/rds\/oracle\/\" target=\"_blank\">Oracle<\/a>, and\u00a0<a href=\"https:\/\/aws.amazon.com\/rds\/sqlserver\/\" target=\"_blank\">Microsoft SQL Server<\/a>.<\/p>\n<h4>CloudFront &#8211; Amazon&#8217;s Content Delivery Network<\/h4>\n<p>Amazon CloudFront is a global content delivery network (CDN) service that accelerates delivery of your websites, APIs, video content or other web assets. It integrates with other Amazon Web Services products to give developers and businesses an easy way to accelerate content to end users with no minimum usage commitments.<\/p>\n<h4>SES &#8211; Simple Email Service<\/h4>\n<p>Amazon Simple Email Service (Amazon SES) is a cost-effective email service built on the reliable and scalable infrastructure that Amazon.com developed to serve its own customer base. With Amazon SES, you can send and receive email with no required minimum commitments \u2013 you pay as you go, and you only pay for what you use.<\/p>\n<h3>Step 2: Designing Your AWS WordPress Infrastructure<\/h3>\n<h4>How do these servers relate to our AWS WordPress setup?<\/h4>\n<p><strong>EC2<\/strong><\/p>\n<p>We will be using EC2 to create a web server instance to power our AWS WordPress installation. We can also use this to install a MySQL database to power our WordPress database.<\/p>\n<p><strong>RDS<\/strong><\/p>\n<p>RDS services are optimized database instances for running database-based applications. We will be using one of these instances for our database since these are highly optimized for performance and scaling.<\/p>\n<p><strong>CloudFront<\/strong><\/p>\n<p>A CDN goes hand-in-hand with WordPress performance, so using CloudFront will give us a CDN powered by Amazon Web Services for our WordPress site.<\/p>\n<p><strong>S3<\/strong><\/p>\n<p>Our media will be stored on S3 instances and distributed via the CloudFront CDN.<\/p>\n<p><strong>SES<\/strong><\/p>\n<p>Whilst you may choose to use your EC2 instance for sending mail, we typically opt to use Simple Email Service instances because, once again, since these are optimized for sending email, we won&#8217;t run into such issues as bad neighborhoods and other mail delivery issues. This is particularly relevant if you plan to send mass\u00a0mailings.<\/p>\n<h3>Designing Your Infrastructure: Scaling Out vs Scaling Up<\/h3>\n<p>There are hundreds of ways you can set up your WordPress infrastructure. If you want a small instance to host your small site, we&#8217;re going to discuss LightSail later on, which is Light VPS which Amazon has launched very recently. You can also set up all of your WordPress instance including <a href=\"http:\/\/coenraets.org\/blog\/2012\/01\/setting-up-wordpress-on-amazon-ec2-in-5-minutes\/\" rel=\"noopener\" target=\"_blank\">server, PHP and MySQL database on a single EC2 instance<\/a>. However, this is not going to take your performance\u00a0very far \u2013 once you hit the physical server limit, you&#8217;re done.<\/p>\n<p>So what&#8217;s this scaling out vs scaling up jargon? There are two primary ways of increasing the throughput\/performance of your website.<\/p>\n<ol>\n<li><strong>Scaling up aka scaling vertically<\/strong> &#8211; this means increasing the actual hardware\/memory resources used to power your website. Essentially, you increase the RAM, CPUs and other hardware allocated to your website. If you&#8217;re on a shared server, you go to a VPS. If you&#8217;re on a VPS, you increase the RAM and\/or CPUs allocated to your server. If you&#8217;ve reached the maximum hardware on shared hosting, you buy a dedicated server. When you&#8217;ve exhausted the dedicated server, you switch to a more powerful server with better hardware.<\/li>\n<li><strong>Scaling out aka scaling horizontally<\/strong> &#8211; as I&#8217;ve hinted slowly in the previous paragraph, you might notice that scaling up has an actual physical limit &#8211; the hardware running your website. If your website is exhausting the physical hardware its hosted on, you&#8217;ve run into a problem. Scaling out, rather than throwing more hardware at the server, throws <strong>more servers<\/strong> at the website. Essentially, we farm out each component of the website to a different server. That, of course, allows our website to handle a much heavier load\u00a0because we have multiple servers handling the load.<\/li>\n<\/ol>\n<p>Our setup is designed with scaling out\u00a0in mind. For this reason, we&#8217;re going to use different instances for each component of WordPress. This will allow us to scale up (increase the computing power) and scale out (increasing the number of instances doing the work) as part of our infrastructure\u00a0to handle additional load.<\/p>\n<p>In particular, we&#8217;re going to use multiple web servers to be able to handle large amounts of traffic. We will also be setting up a load balancer, which will determine which server to send requests to.<\/p>\n<p>This means we&#8217;re going to be creating at the very least the following difference instances:<\/p>\n<ol>\n<li>A database component using RDS<\/li>\n<li>(Multiple)\u00a0WordPress installation component(s) using EC2<\/li>\n<li>A mailing service component using SES<\/li>\n<li>(Optional) A CDN component using S3 and CloudFront<\/li>\n<\/ol>\n<p>There are also multiple ways of actually designing this infrastructure. AWS also has pre-defined Application Containers. The idea is that certain specific common applications development environments have pre-defined instances that can be activated at the click of a button.<\/p>\n<p>A word of warning: Amazon has so many possible configurations and setups possible, that it is quite difficult to understand them without lots of experience, let alone explain them in a single blog. For this reason, we&#8217;ll be taking some shortcuts and not explain everything in detail. For further reading, refer to the <a href=\"http:\/\/docs.aws.amazon.com\" rel=\"noopener\" target=\"_blank\">AWS documentation<\/a>.<\/p>\n<h4>Scaling Out a Database<\/h4>\n<p>Scaling out a database to multiple instances is possible, however, the complexities of performing such a configuration are way beyond such a blog.<\/p>\n<p>We&#8217;re thus going to restrict our infrastructure to a single instance of the database. Now, although this may seem like a limitation, in reality, having a server instance dedicated solely to the database means that the website would be able to handle significant amounts of traffic.<\/p>\n<p>We will also be using Aurora DB, Amazon&#8217;s own build of MySQL which is optimized for performance and for the cloud.<\/p>\n<p>This, coupled with the fact that our database instance can get pretty high-specked in terms of performance should ensure that the database would never become a real bottleneck.<\/p>\n<p>To ease the load of the database components further, one would also enable WordPress caching to ensure that database hits are kept to a minimum.<\/p>\n<p>All-in-all, our decision to keep a single instance of the database should be sufficient for most website loads unless your website will be handling tens of thousands of hits per second. In that case, you can probably afford to hire an expert to configure your website!<\/p>\n<h3>Step 3: Setting up Your WordPress Database Instance<\/h3>\n<p>To set up a WordPress installation on Amazon Web Services, you&#8217;re going to need a few components. The first you&#8217;re going to need is a database service, so go to RDS and launch a MySQL instance.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"attachment-670x670 size-670x670 aligncenter\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2016\/12\/AWS_MySQL_Instance.png\" alt=\"Create a MySQL AWS Instance\" width=\"670\" height=\"599\" \/><\/p>\n<p>If you&#8217;re just testing out stuff, you can choose to create a DEV\/Test environment. On the other hand, if this is your production environment, you have two choices:<\/p>\n<h4>Option 1: MySQL<\/h4>\n<p>This uses a multiple Availability Zone (i.e. you will have a Primary instance and a secondary instance on standby in case of failure of the primary instance). The creation and failover to the secondary standby instance is completely transport &#8211; it is of course designed for High Availability\u00a0and\u00a0<a href=\"http:\/\/docs.aws.amazon.com\/AmazonRDS\/latest\/UserGuide\/Overview.ProvisionedIOPS.html\" rel=\"noopener\" target=\"_blank\">Provisioned IOPS Storage<\/a>\u00a0for fast, consistent performance.<\/p>\n<h4>Option 2: Aurora DB<\/h4>\n<p>This is the <strong>recommended<\/strong> configuration. Whilst this is not strictly MySQL, Aurora DB is a custom build created by Amazon, specifically optimized for higher performance and better reliability. Tests have shown that instances of <a href=\"https:\/\/pagely.com\/blog\/benchmarked-amazons-new-aurora-database-use-wordpress-results-within\/\" rel=\"noopener\" target=\"_blank\">WordPress on Aurora DB run up to 3 times faster<\/a>. This is also classified as Enterprise level performance, so if you want absolutely top-notch performance, you should go for this option.<\/p>\n<figure class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-1364x1364\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2016\/12\/Amazon_Aurora_DB.png\" alt=\"Use Aurora DB for top-notch performance.\" width=\"1364\" height=\"429\" \/><figcaption class=\"wp-caption-text\">Use Aurora DB for top-notch performance.<\/figcaption><\/figure>\n<p>Once you&#8217;ve selected Aurora DB, you need to specify some basic configurations. You&#8217;ll need to figure out what the <a href=\"http:\/\/docs.aws.amazon.com\/AmazonRDS\/latest\/UserGuide\/Concepts.DBInstanceClass.html\" rel=\"noopener\" target=\"_blank\">right DB Instance Class<\/a> for you is. Besides actual throughput, you&#8217;ll also need to consider DB Instance\u00a0<a href=\"https:\/\/aws.amazon.com\/rds\/pricing\/\" rel=\"noopener\" target=\"_blank\">pricing<\/a>.<\/p>\n<figure class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-1364x1364 size-1364x1364\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2016\/12\/AWS_Database_configuration_.png\" alt=\"AWS Aurora database configuration.\" width=\"1364\" height=\"508\" \/><figcaption class=\"wp-caption-text\">AWS Aurora database configuration.<\/figcaption><\/figure>\n<p>Take note of the settings you are using, particularly names, because we&#8217;re going to need them later on when we&#8217;re creating the WordPress instance.<\/p>\n<h2>Step 4: Creating and Setting up Your Web Server Infrastructure<\/h2>\n<p>Once our database has been created, we&#8217;re now going to set up our web server. We&#8217;re be using an EC2 instance to run our WordPress web server.<\/p>\n<p>Once again, you&#8217;ve got various options to install WordPress on an EC2 instance. If you head over to the <a href=\"https:\/\/aws.amazon.com\/marketplace\/\" rel=\"noopener\" target=\"_blank\">AWS MarketPlace<\/a>, you&#8217;ll find preconfigured instances of WordPress which you can get up and running in next to no time. These come with the added benefit of using a tried and tested configuration.<\/p>\n<p>The AWS MarketPlace also allows you to install very specific WordPress configurations. For example, if you want to push performance to the limit, you might want to use an Nginx web server rather than an Apache webserver. There are <a href=\"https:\/\/docs.nginx.com\/nginx\/deployment-guides\/amazon-web-services\/ec2-instances-for-nginx\/\" rel=\"noopener\" target=\"_blank\">various Nginx configurations available on the AWS Marketplace<\/a>.<\/p>\n<p>To create a new EC2 instance, access the AWS Management Console and click the EC2 tab:<\/p>\n<ul>\n<li>Choose an Amazon Machine Image (AMI) in the wizard: a good choice for WordPress would be\u00a0<strong>Amazon Linux AMI 2016.09.0 (HVM), SSD Volume Type\u00a064-bit<\/strong>.<\/li>\n<li>Choose the Instance types details: Once again, this is something that\u00a0depends on\u00a0two main things: the expected traffic, and consequently, the throughput and performance you need, together with what you are prepared to pay for them. You can <a href=\"https:\/\/aws.amazon.com\/ec2\/instance-types\/\" rel=\"noopener\" target=\"_blank\">learn more about EC2 Instance types here<\/a>. Select the\u00a0<strong>Instance Type<\/strong>\u00a0you want to use.<\/li>\n<li>Create a new key pair. Enter a name for your key pair (i.e. WordPress_AWS) and download your key pair (i.e. WordPress_AWS).<\/li>\n<li>Select the quick start security group.<\/li>\n<li>Launch your instance.<\/li>\n<\/ul>\n<p>Woohoo! You&#8217;ve got our main components setup!<\/p>\n<p>Setup correct inbound and outbound rules to be able to access the server through HTTP. Using the security groups, you can edit the inbound and outbound rules to add firewall rules as necessary to allow traffic to the various instances you have created.<\/p>\n<figure class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-1364x1364 size-1364x1364\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2017\/01\/Edit_HTTP_HTTPS_inbound_rules.png\" alt=\"Allowing inbound traffic.\" width=\"1364\" height=\"587\" \/><figcaption class=\"wp-caption-text\">Allowing inbound traffic.<\/figcaption><\/figure>\n<h3>Step 5: Install Apache Web Server + WordPress<\/h3>\n<p>So now that our actual server instances\u00a0are up and running, we need to get all of our software components in place.<\/p>\n<h4>Install the Web Server<\/h4>\n<p>We&#8217;re going to skim through a few steps which we&#8217;re going to assume are pretty standard stuff.<\/p>\n<figure class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-670x670 size-670x670\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2017\/01\/AWS_SSH_EC2_Instance.png\" alt=\"A SSH into EC2 instance.\" width=\"670\" height=\"387\" \/><figcaption class=\"wp-caption-text\">A SSH into EC2 instance.<\/figcaption><\/figure>\n<ol>\n<li>SSH into your web server instance (EC2)<\/li>\n<li>Install the Apache web server (sudo\u00a0yum install httpd)<\/li>\n<li>Start the web server (sudo service httpd start)<\/li>\n<\/ol>\n<div class=\"gist\" data-gist=\"1f639aec23aa9a33b0148187d35b54a6\" data-gist-file=\".gistfile1.txt\"><a class=\"loading\" href=\"https:\/\/gist.github.com\/1f639aec23aa9a33b0148187d35b54a6.js?file=.gistfile1.txt\">Loading gist 1f639aec23aa9a33b0148187d35b54a6<\/a><div class=\"gist-consent-notice\" style=\"display:none\"><p>Please <a href=\"javascript:Cookiebot.renew()\">update your cookie preferences<\/a> to enable preference cookies to view this gist.<\/p><\/div><\/div>\n<p>Test whether the server is up and running (Access\u00a0http:\/\/ec2-54-202-202-135.us-west-2.compute.amazonaws.com &#8211; you&#8217;ll actually need to enter the public DNS name of your EC2 instance). If you are unable to connect you&#8217;ll need to make sure that the security groups have been set correctly to allow inbound HTTP traffic.<\/p>\n<h3>Install PHP on the Web Server<\/h3>\n<ol>\n<li>Install the PHP package specifically for MySQL \u00a0(<em>sudo yum install php php-mysql<\/em>)<\/li>\n<li>Restart the Apache Web Server (<em>sudo\u00a0service httpd restart<\/em>)<\/li>\n<li>Create a <em>test.php<\/em> file which simply runs phpinfo()<\/li>\n<\/ol>\n<div class=\"gist\" data-gist=\"c10dd17b7c10583f92b960bd20298151\" data-gist-file=\".gistfile1.txt\"><a class=\"loading\" href=\"https:\/\/gist.github.com\/c10dd17b7c10583f92b960bd20298151.js?file=.gistfile1.txt\">Loading gist c10dd17b7c10583f92b960bd20298151<\/a><div class=\"gist-consent-notice\" style=\"display:none\"><p>Please <a href=\"javascript:Cookiebot.renew()\">update your cookie preferences<\/a> to enable preference cookies to view this gist.<\/p><\/div><\/div>\n<p style=\"padding-left: 90px;\">type\u00a0i\u00a0to start the insert mode in VI<\/p>\n<p style=\"padding-left: 90px;\">Type\u00a0&lt;?php phpinfo() ?&gt;<\/p>\n<p style=\"padding-left: 90px;\">Type\u00a0:wq\u00a0to write the file and quit vi<\/p>\n<p>Open a browser and access test.php to test your PHP installation: http:\/\/ec2-54-202-202-135.us-west-2.compute.amazonaws.com\/test.php\u00a0(Use your actual public DNS name).<\/p>\n<figure class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-670x670 size-670x670\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2016\/12\/aws_php_is_up_and_running.png\" alt=\"Confirmation that PHP is up and running.\" width=\"582\" height=\"670\" \/><figcaption class=\"wp-caption-text\">Confirmation that PHP is up and running.<\/figcaption><\/figure>\n<p>Great, so now we know our web server is up and running with PHP5.<\/p>\n<h3>Download, Install and Setup WordPress on the Amazon Web Server<\/h3>\n<p>Given that PHP is working on our web server, we need to download and install WordPress. Let&#8217;s download and configure our WordPress installation.<\/p>\n<ol>\n<li>Go to the public HTML folder of the server where we will be installing WordPress\u00a0(<em>cd \/var\/www\/html<\/em>)<\/li>\n<li>Download the latest version of WordPress (<em>wget http:\/\/wordpress.org\/latest.tar.gz<\/em>)<\/li>\n<li>Uncompress the file we&#8217;ve downloaded (<em>tar -xzvf latest.tar.gz<\/em>)<\/li>\n<li>This will uncompress WordPress in its a directory called\u00a0\u201cwordpress\u201d directory. We will rename this to something which makes more sense, so that we can set up more stuff on the web server. Let&#8217;s rename it to blog. (<em>mv wordpress blog<\/em>)<\/li>\n<li>Create the WordPress wp-config.php file and modify the database connection parameters as follows \u2013 of course, you&#8217;ll need to use your own set of parameters which you&#8217;ve used when creating the Aurora DB instance<\/li>\n<\/ol>\n<div class=\"gist\" data-gist=\"f16a8a931cc9ce3d52e9d1f6bb0c3b34\" data-gist-file=\".gistfile1.txt\"><a class=\"loading\" href=\"https:\/\/gist.github.com\/f16a8a931cc9ce3d52e9d1f6bb0c3b34.js?file=.gistfile1.txt\">Loading gist f16a8a931cc9ce3d52e9d1f6bb0c3b34<\/a><div class=\"gist-consent-notice\" style=\"display:none\"><p>Please <a href=\"javascript:Cookiebot.renew()\">update your cookie preferences<\/a> to enable preference cookies to view this gist.<\/p><\/div><\/div>\n<p style=\"padding-left: 60px;\">Type &#8220;i&#8221; to start insert mode.<\/p>\n<p style=\"padding-left: 60px;\">Edit with the correct parameters.<\/p>\n<p style=\"padding-left: 60px;\">Type &#8220;:wq&#8221;\u00a0to write the file and quit &#8220;vi.&#8221;<\/p>\n<div class=\"gist\" data-gist=\"998d96cf4c7a370d32780bb3bea10ec4\" data-gist-file=\".gistfile1.txt\"><a class=\"loading\" href=\"https:\/\/gist.github.com\/998d96cf4c7a370d32780bb3bea10ec4.js?file=.gistfile1.txt\">Loading gist 998d96cf4c7a370d32780bb3bea10ec4<\/a><div class=\"gist-consent-notice\" style=\"display:none\"><p>Please <a href=\"javascript:Cookiebot.renew()\">update your cookie preferences<\/a> to enable preference cookies to view this gist.<\/p><\/div><\/div>\n<p>If you&#8217;re not sure of what values you&#8217;ll need to enter, you can find the details you&#8217;ll need to use by using the details found on your Aurora Database instance.<\/p>\n<figure class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-1364x1364 size-1364x1364\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2016\/12\/AWS_aurora_database_settings.png\" alt=\"AWS Aurora database settings.\" width=\"920\" height=\"560\" \/><figcaption class=\"wp-caption-text\">AWS Aurora database settings.<\/figcaption><\/figure>\n<p>Open a Browser and access your new WordPress website blog: <em>http:\/\/ec2-54-202-202-135.us-west-2.compute.amazonaws.com\/blog<\/em>\u00a0\u00a0(Use your actual public DNS name).<\/p>\n<p>This should trigger the WordPress configuration process. If you get an error establishing a connection to your database, you either have some of the database details which are incorrect or possibly you need to ensure you&#8217;ve set up a correct security group with the correct firewall rules (this is a bit outside the scope of this blog).<\/p>\n<p>Run through the 5-minute install (which should actually take much less, since everything should be nearly done), set up a WordPress administrator, a strong password and you should be good to go.<\/p>\n<p>Once you&#8217;re done you should get a nice fresh, new install of WordPress!<\/p>\n<h3>Step 6: Set up an Amazon Mailer (SES) Instance with WordPress<\/h3>\n<p>SES or Simple Email Service is just that &#8211; a way of sending email where you pay as you go based on the volumes you send. If you&#8217;re planning to send newsletters or other mass mailing to thousands of users, SES is a good, reliable, cheap choice, if you just need a volume sending server. If you&#8217;re looking at more complex stuff for sending emails, we make a few great recommendations for <a href=\"https:\/\/www.collectiveray.com\/wordpress-email-subscription\" rel=\"noopener\" target=\"_blank\">growing your email list and sending emails here<\/a>.<\/p>\n<p>To be able to send emails using SES, you&#8217;ll need to verify that you own and are able access to the domain you&#8217;ll be\u00a0sending emails from. You can do this by creating DKIM DNS entries to your domain.<\/p>\n<p>Follow the AWS SES domain verification process:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"attachment-670x670 size-670x670 aligncenter\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2017\/01\/AWS_verify_domain.png\" alt=\"AWS Verify SES domain\" width=\"670\" height=\"311\" \/><\/p>\n<p>Once you&#8217;ve created and verified the domain through your DNS settings, you&#8217;ll need to set up an identity (email address) to send from. Again, there is a verification process associated with creating an identity, so follow that through to verify you have access to the email address.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"attachment-670x670 size-670x670 aligncenter\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2017\/01\/Verify_AWS_SES_identity.png\" alt=\"Verify AWS SES identity\" width=\"670\" height=\"256\" \/><\/p>\n<p>We&#8217;re not ready yet &#8211; we need to create credentials to be able to access the SES\u00a0server via SMTP. To do this, go to SMTP Settings and create a new set of SMTP credentials of our WordPress website.<\/p>\n<figure class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-1364x1364 size-1364x1364\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2017\/01\/AWS_SES_WordPress_SMTP_Credentials-1.jpg\" alt=\"AWS SES SMTP credentials.\" width=\"1364\" height=\"569\" \/><figcaption class=\"wp-caption-text\">AWS SES SMTP credentials.<\/figcaption><\/figure>\n<p>This will involve creating a new IAM user which will have an SMTP Username and SMTP password.<\/p>\n<p>Now, using SMTP with WordPress requires the installation of\u00a0the <a href=\"https:\/\/wordpress.org\/plugins\/wp-mail-smtp\/\" rel=\"noopener\" target=\"_blank\">WP Mail SMTP Plugin<\/a>.<\/p>\n<p>Copy the username and password and put them directly into the WordPress SMTP settings plugin details. You will only be shown these details once &#8211; a safety precaution meant to keep access to the SES servers limited.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"attachment-670x670 size-670x670 aligncenter\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2017\/01\/AWS_SMTP_Settings.png\" alt=\"AWS SMTP Settings\" width=\"670\" height=\"644\" \/><\/p>\n<h3>Step 7: Serve WordPress Media from Amazon&#8217;s CloudFront CDN\u00a0(Optional, But Recommended)<\/h3>\n<p>Since we&#8217;re on the subject of boosting performance, integrating Amazon&#8217;s CloudFront CDN would help scale out our setup further, allowing the site to achieve better levels of performance. As <a href=\"https:\/\/wpmudev.com\/blog\/top-cdn-services-to-make-your-wordpress-site-blazingly-fast\/\" target=\"_blank\" rel=\"noopener\">we&#8217;ve discussed on this blog<\/a> (and elsewhere), a <a href=\"https:\/\/wpmudev.com\/blog\/how-to-choose-the-best-cdn-for-wordpress\/\" target=\"_blank\" rel=\"noopener\">CDN gives your website a performance<\/a> boost by serving static, heavy resources from a location that is closer to your website&#8217;s visitor.<\/p>\n<p>To integrate the WordPress site with CloudFront, you can use the Amazon S3 and CloudFront WordPress plugin, to store the media folder onto Amazon S3 and then serve it through Amazon CloudFront. This has been already been covered in detail by our very own Daniel, so have a look at <a href=\"https:\/\/wpmudev.com\/blog\/moving-wordpress-media-to-amazon-s3\/\" target=\"_blank\" rel=\"noopener\">how to move WordPress media folder to Amazon S3<\/a>.<\/p>\n<h3>Step 8:\u00a0Connect EC2 Instance with Your Domain<\/h3>\n<p>To be able to use the AWS WordPress installation with our domain, we need to associate a public IP address to our instance and then map our domain name to that IP address.<\/p>\n<h4>Associate an IP Address to an EC2 Instance<\/h4>\n<ol>\n<li>In the AWS EC2 Management Console, click <strong>Elastic IPs<\/strong> (left navigation bar)<\/li>\n<li>Allocate New Address, and confirm by clicking the <strong>Allocate<\/strong>\u00a0button<\/li>\n<li>Right-click the newly allocated IP address and select <strong>Associate<\/strong>\u00a0in the popup menu. Select the WordPress EC2 instance we\u00a0created above and click <strong>Associate<\/strong><\/li>\n<\/ol>\n<figure class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-1364x1364 size-1364x1364\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2017\/01\/Assosciate_AWS_Elastic_IP_Address.png\" alt=\"Associating an AWS Elastic IP to instance.\" width=\"715\" height=\"531\" \/><figcaption class=\"wp-caption-text\">Associating an AWS Elastic IP to instance.<\/figcaption><\/figure>\n<h3>Setup DNS records\u00a0for your domain with Route53<\/h3>\n<p><a href=\"https:\/\/aws.amazon.com\/route53\/\" rel=\"noopener\" target=\"_blank\">Route53<\/a> is a DNS service from AWS, which will essentially be used to translate the domain name to the elastic IP we have just created. It&#8217;s quite cheap, at about $.50\/month.<\/p>\n<ol>\n<li>Create a hosted zone, with the name of your domain (without www). This will create four name servers, one\u00a0master and three slaves.<\/li>\n<li>While still in the hosted zone, unselect all records and then click on\u00a0<strong>Create Record Set<\/strong>. Create a new A record (for example <em>www.worpressaws.com<\/em>) pointing to the Elastic IP record you created in the previous step.<\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"attachment-670x670 size-670x670 aligncenter\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2017\/01\/Create_A_record.png\" alt=\"Create DNS A Record to Elastic IP\" width=\"418\" height=\"614\" \/>With the above, we now know that a domain lookup of <em>www.wordpressaws.com<\/em> will resolve to the EC2 elastic IP.<\/p>\n<p>The final step is to map your domain from the registrar to your Route53 name server. In GoDaddy or wherever you have registered your domain to point to the name of your master DNS server (e.g. ns-1329.awsdns-38.org.)<\/p>\n<p>You&#8217;ll need to wait a few hours (sometimes up to 48 hours) to check whether your IP is resolving correctly. You can check the progress of the domain name propagation using a service such as <a href=\"https:\/\/www.whatsmydns.net\" rel=\"noopener\" target=\"_blank\">What&#8217;s my DNS<\/a>.<\/p>\n<p>Once DNS has propagated\u00a0correctly, go to\u00a0WordPress General Settings in the WordPress management console and make sure the WordPress Address and Site Address are specified correctly using your domain name.<\/p>\n<h3>Using Amazon LightSail VPS<\/h3>\n<p>A few weeks ago, AWS launched a new service, <a href=\"https:\/\/amazonlightsail.com\/\" target=\"_blank\">LightSail<\/a>. Essentially, these are virtual private servers priced at a very cheap $5 per month.<\/p>\n<ol>\n<li>You simply click on the instance of the application you&#8217;d like to host.<\/li>\n<\/ol>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"attachment-670x670 size-670x670 aligncenter\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2017\/01\/AWS_LightSail.png\" alt=\"Create a AWS LightSail instance\" width=\"670\" height=\"638\" \/><\/p>\n<p>2. Select how much resources you want to allocate.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"attachment-670x670 size-670x670 aligncenter\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2017\/01\/AWS_LightSail_Instance_plan.png\" alt=\"Choose LightSail plan\" width=\"670\" height=\"319\" \/><\/p>\n<p>And AWS LightSail will spin up an instance for you with WordPress and a database pre-installed. You can then SSH into as a regular EC2 instance and tweak as necessary.<\/p>\n<figure class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-1364x1364 size-1364x1364\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2017\/01\/AWS_WordPress_LightSail_instance.jpg\" alt=\"AWS WordPress LightSail Instance.\" width=\"1364\" height=\"740\" \/><figcaption class=\"wp-caption-text\">AWS WordPress LightSail Instance.<\/figcaption><\/figure>\n<h3>Phew, We&#8217;re Done! But Are We Really&#8230;?<\/h3>\n<p>That was pretty taxing to set up! Getting it all up and running smoothly is not for the faint-hearted. Keeping everything up and running in tip-top shape is going to take a continuous effort of monitoring states of the various instances, making sure we&#8217;re not running up costs on large instances. We also need to monitor whether the servers are coping with demand &#8211; where necessary we can stop an instance and allocate more resources to it as necessary.<\/p>\n<p>We&#8217;ll also be discussing in another post, how to actually set up autoscaling on AWS such that traffic spikes will automatically create new instances of the web server we have created to be able to handle loads as necessary.<\/p>\n<h3>Why Not Leave It All to the Experts?<\/h3>\n<p>As you might have seen from the above, setting up and maintaining an AWS WordPress infrastructure is not an easy task. Keeping it up and running is also going to need constant investment in time, and of course the billings on AWS itself.<\/p>\n<p>Whilst AWS gives you quite a lot of control, you can literally configure bits and pieces as necessary for your infrastructure, we do believe this is only for those who have very specific needs.<\/p>\n<p>On the other hand, if you run an enterprise website and want top performance right off the bat, <a href=\"https:\/\/wpmudev.com\/enterprise-hosting\/\" target=\"_blank\" rel=\"noopener\">why not go for managed WordPress hosting with WPMU DEV<\/a>? It gives you the same performance and scaling, without all the headaches that come with managing a server. Get scaling!<\/p>\n<a class=\"general_big_button\" href=\"https:\/\/wpmudev.com\/blog\/wordpress-host-test-results\/\"><span class=\"text\">Oct 2020: We tested all the best WordPress hosts! Find out how we compare.<\/span><span class=\"button-a-b\">View Results<\/span><\/a>\n","protected":false},"excerpt":{"rendered":"<p>You&#8217;ve almost definitely heard about Amazon Web Services. And, given that you&#8217;re on this site, I&#8217;m going to make the obvious assumption that you&#8217;ve heard about WordPress, too. But what you might not have heard about is combining WordPress with Amazon Web Services (AWS) for web hosting. Articles about hosting WordPress on shared hosting, CPanel [&hellip;]<\/p>\n","protected":false},"author":375995,"featured_media":162299,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"blog_reading_time":"","wds_primary_category":0,"wds_primary_tutorials_categories":0,"footnotes":""},"categories":[263,11119],"tags":[39,712,10604],"tutorials_categories":[],"class_list":["post-161138","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","category-wordpress-hosting","tag-hosting","tag-amazon","tag-aws"],"_links":{"self":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/161138","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/users\/375995"}],"replies":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/comments?post=161138"}],"version-history":[{"count":31,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/161138\/revisions"}],"predecessor-version":[{"id":209390,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/161138\/revisions\/209390"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/media\/162299"}],"wp:attachment":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/media?parent=161138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/categories?post=161138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/tags?post=161138"},{"taxonomy":"tutorials_categories","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/tutorials_categories?post=161138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}