July 16, 2019 / Nirav Shah
<strong>Host your first wordpress website free for the first 12 months on AWS EC2</strong>
<strong>EXTRACT</strong> We are going to share the steps that should be performed to host your first wordpress website on AWS which will be <a style=”color: #0b5f9e;” href=”https://aws.amazon.com/free/” target=”_blank” rel=”noopener”>free of charge</a>* for the first 12 months.
<!– Begin Table of Contents –>
<script>
var allHeadings;
document.addEventListener(“DOMContentLoaded”, function(event) {
allHeadings = Array.prototype.slice.call(document.querySelectorAll(‘h1, h2, h3, h4, h5, h6’));
});
function jumpTo(title,tag){
allHeadings.forEach(function (singleHeading){
if((singleHeading.localName.toLowerCase().replace(/\u00a0/g, ‘ ‘) == tag.toLowerCase().replace(/\u00a0/g, ‘ ‘) ) && (singleHeading.innerText.toLowerCase().replace(/\u00a0/g, ‘ ‘) == title.toLowerCase().replace(/\u00a0/g, ‘ ‘) )){
singleHeading.scrollIntoView({behavior: ‘smooth’, block: ‘center’});
}
})
}
</script>
<div class=”topic-table-of-contents-container topic-table-of-contents-align-left” style=”position: relative; text-align: left;”>
<div class=”topic-table-of-contents” style=”background-color: rgb(240, 244, 248);
position:relative;
margin-bottom: 40px;
padding: 1.5rem;
border-radius:4px;
display: inline-block;
text-align: left;
width: 300px;”>
<div class=”topic-table-of-contents-label” style=”color:rgb(16, 42, 67) !important; font-weight: bold;
font-size:1rem;
margin-bottom: 1rem;” >
TABLE OF CONTENTS
</div>
<div class=”topic-table-of-contents-line topic-table-of-contents-type-heading topic-table-of-contents-tag-h1″ style=””>
<p onClick=”jumpTo(‘Step by Step Guide to Install WordPress on AWS for free
Step by Step Guide to Install WordPress on AWS for free’,’H1′)” style=”color:rgb(16, 42, 67) !important; font-weight: normal;
cursor: pointer;
line-height:normal;
margin-bottom: 1rem !important;
font-size: 1rem;”>
<span style=”color:inherit;
border-bottom: 1px solid rgba(0,0,0,0.1);
line-height: 1.5rem;”>Step by Step Guide to Install WordPress on AWS for free</span>
</p>
</div>
<div class=”topic-table-of-contents-line topic-table-of-contents-type-heading topic-table-of-contents-tag-h2″ style=”margin-left: 1rem;”>
<p onClick=”jumpTo(‘Steps To Setup WordPress on AWS’,’H2′)” style=”color:rgb(16, 42, 67) !important; font-weight: normal;
cursor: pointer;
line-height:normal;
margin-bottom: 1rem !important;
font-size: 1rem;”>
<span style=”color:inherit;
border-bottom: 1px solid rgba(0,0,0,0.1);
line-height: 1.5rem;”>Steps To Setup WordPress on AWS</span>
</p>
</div>
<div class=”topic-table-of-contents-line topic-table-of-contents-type-heading topic-table-of-contents-tag-h4″ style=”margin-left: 3rem;”>
<p onClick=”jumpTo(‘Spread Love By Sharing:’,’H4′)” style=”color:rgb(16, 42, 67) !important; font-weight: normal;
cursor: pointer;
line-height:normal;
margin-bottom: 1rem !important;
font-size: 1rem;”>
<span style=”color:inherit;
border-bottom: 1px solid rgba(0,0,0,0.1);
line-height: 1.5rem;”>Spread Love By Sharing:</span>
</p>
</div>
<div class=”topic-table-of-contents-line topic-table-of-contents-type-heading topic-table-of-contents-tag-h2″ style=”margin-left: 1rem;”>
<p onClick=”jumpTo(‘Related Blogs’,’H2′)” style=”color:rgb(16, 42, 67) !important; font-weight: normal;
cursor: pointer;
line-height:normal;
margin-bottom: 1rem !important;
font-size: 1rem;”>
<span style=”color:inherit;
border-bottom: 1px solid rgba(0,0,0,0.1);
line-height: 1.5rem;”>Related Blogs</span>
</p>
</div>
<div class=”topic-table-of-contents-line topic-table-of-contents-type-heading topic-table-of-contents-tag-h3″ style=”margin-left: 2rem;”>
<p onClick=”jumpTo(‘Services’,’H3′)” style=”color:rgb(16, 42, 67) !important; font-weight: normal;
cursor: pointer;
line-height:normal;
margin-bottom: 1rem !important;
font-size: 1rem;”>
<span style=”color:inherit;
border-bottom: 1px solid rgba(0,0,0,0.1);
line-height: 1.5rem;”>Services</span>
</p>
</div>
<div class=”topic-table-of-contents-line topic-table-of-contents-type-heading topic-table-of-contents-tag-h3″ style=”margin-left: 2rem;”>
<p onClick=”jumpTo(‘Contact us’,’H3′)” style=”color:rgb(16, 42, 67) !important; font-weight: normal;
cursor: pointer;
line-height:normal;
margin-bottom: 1rem !important;
font-size: 1rem;”>
<span style=”color:inherit;
border-bottom: 1px solid rgba(0,0,0,0.1);
line-height: 1.5rem;”>Contact us</span>
</p>
</div>
<a href=”https://www.usetopic.com/wordpress-table-of-contents” style=”color: transparent;”><div style=”position: absolute;
bottom: -28px;
background-image: url(https://www.usetopic.com/wordpress-table-of-contents-powered-by.png);
background-size: contain;
width: 134px;
height: 22px;
background-repeat: no-repeat;
right: 0;
opacity: 0.5;
color: transparent;”>Wordpress Table of Contents by Topic</div></a>
<style>
/* Alignment */
@media screen and (max-width: 600px) {
.topic-table-of-contents-align-float-left {
float: none;
margin-right: 0;
}
.topic-table-of-contents-align-float-left .topic-table-of-contents,
.topic-table-of-contents-align-left .topic-table-of-contents,
.topic-table-of-contents-align-center .topic-table-of-contents{
width: auto;
display: block;
}
}
/* General Styles */
.topic-table-of-contents-type-heading.topic-table-of-contents-line span:hover{
border-bottom: 1px solid rgba(0,0,0,0.4);
}
</style>
</div>
</div>
<!– End Table of Contents –>
WordPress is one of the many popular Open Source Platform which will help you host your content which can widely range from blogs on anything to your enterprises main-page. It is probably an easy and power packed Blogging and Website Content Management System(CMS). It is so famous that it powers a percentage of 26.4% of the Internet as well as the most used CMS as it has almost 59% market share in CMS usage as well as interestingly, on a daily basis almost 500 sites are created on WordPress.
Amazon Web Services(AWS) on the other hand is leading the Cloud Market by providing extremely customizable/tweakable cloud infrastructure as well as to-your-liking custom solutions for your cloud Hosting requirements.
To promote and make more and more people start using AWS Cloud Infrastructure they have an Introductory Plan called <a style=”color: #0b5f9e;” href=”https://aws.amazon.com/free/” target=”_blank” rel=”noopener”>AWS Free Tier</a> where they provide majority of services with a specified limit of usage every month for a consecutive 12 months period for newly created accounts. All you have to do is create a New Account and this Plan will be attached to your new account by default.
If you use the resources under their specified free tier limit; <strong>voila!</strong> No need to pay a single cent for that month and if you plan your resource usage accordingly for the next 11 months; you will be hosting your Content on AWS’s Best-in-the-Cloud-Market Infrastructure for <strong>$ 0</strong>, we repeat <strong>$ 0</strong> for 1 year straight (exclude the domain-name ownership/renewal cost for your website).
We will Guide you through the procedure of launching an Instance in your AWS account to host your wordpress website but, the prerequisite would be for you to have a brand new AWS account which you should be able to create by clicking on the “Create a Free Account” on this <a style=”color: #0b5f9e;” href=”https://aws.amazon.com/free/” target=”_blank” rel=”noopener”>page</a>.
<h2><b>Steps To Setup WordPress on AWS</b></h2>
Once you are done with all the account creation formalities; hop back over here and follow the Steps which we instruct :-
<strong>1. <a style=”color: #0b5f9e;” href=”https://www.eternalsoftsolutions.com/blog/launch-aws-ec2-instance-for-free/”>Launch EC2 instance from AWS Console</a></strong>
<strong>2. <a style=”color: #0b5f9e;” href=”https://www.eternalsoftsolutions.com/blog/install-apache-mysql-php-on-aws-ec2/”>Install Apache,MysqL,PHP on AWS EC2</a></strong>
<strong>3. Download and Configure WordPress for free on EC2</strong>
<ul class=”listing” style=”margin-left: 15px; margin-bottom: 20px;”>
<li>Now that our server software is configured, we will download the latest version of wordpress into the server as it is always recommended to get the latest version and set it up in the website root directory.
<ul class=”awsul”>
<li>Go to “/tmp” directory and download the compressed release there:<strong>$</strong> cd /tmp<strong>$</strong> curl -O <a style=”color: #0b5f9e;” href=”https://wordpress.org/latest.tar.gz” target=”_blank” rel=”noopener”>https://wordpress.org/latest.tar.gz</a><img src=”https://www.eternalsoftsolutions.com/blog/wp-content/uploads/2019/07/cf_Screenshot.png” width=”100%;” /></li>
<li>Extract the compressed file:<strong>$</strong> tar zxvf latest.tar.gz<img src=”https://www.eternalsoftsolutions.com/blog/wp-content/uploads/2019/07/cg_Screenshot.png” width=”100%;” />
<img src=”https://www.eternalsoftsolutions.com/blog/wp-content/uploads/2019/07/ch_Screenshot.png” width=”100%;” /></li>
<li>Before moving these files into the web-server root directory, we will add a dummy .htaccess file and set its permissions so that this will be available for WordPress to use later.<strong>$</strong> touch /tmp/wordpress/.htaccess<strong>$</strong> chmod 660 /tmp/wordpress/.htaccessWe’ll also copy over the sample configuration file to the filename that WordPress actually reads:<strong>$</strong> cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php
<img src=”https://www.eternalsoftsolutions.com/blog/wp-content/uploads/2019/07/ci_Screenshot.png” width=”100%;” /></li>
<li>We can also create the upgrade directory, so that WordPress won’t run into permissions issues when trying to do this on its own following an update to its software:<strong>$</strong> mkdir /tmp/wordpress/wp-content/upgrade<img src=”https://www.eternalsoftsolutions.com/blog/wp-content/uploads/2019/07/cj_Screenshot.png” width=”100%;” /></li>
<li>Now, we will copy the entire contents of the directory into our web-server root. We will use the -a flag to make sure our permissions are maintained. We will use a dot at the end of our source directory to indicate that everything within the directory should be copied, including hidden files (like the .htaccess file we created):<strong>$</strong> sudo cp -a /tmp/wordpress/. /var/www/html<img src=”https://www.eternalsoftsolutions.com/blog/wp-content/uploads/2019/07/ck_Screenshot.png” width=”100%;” /></li>
</ul>
</li>
<li>Now, before doing the web-based WordPress setup, we will need to adjust some items in our WordPress directory.</li>
<li>One of the main things is setting up reasonable file permissions and ownership. We need to be able to write these files as a regular user, and we need the web-server also to be able to access and adjust certain files and directories in order to function correctly.
<ul class=”awsul”>
<li>We’ll assign ownership over all of the files in our web server root to our username which is <strong>ubuntu</strong> in our case but may vary according to your personal configuration and we will assign group ownership to the <strong>www-data</strong> group:<strong>$</strong> sudo chown -R ubuntu:www-data /var/www/html<img src=”https://www.eternalsoftsolutions.com/blog/wp-content/uploads/2019/07/cl_Screenshot.png” width=”100%;” /></li>
<li>Next, we will set the <strong>setgid</strong> bit on each of the directories within the web-server root. This causes new files created within these directories to inherit the group of the parent directory (which we just set to <strong>www-data</strong>) instead of the creating user’s primary group. This just makes sure that whenever we create a file in the directory on the command line, the web-server will still have group ownership over it. We can set the <strong>setgid</strong> bit on every directory in our WordPress installation by typing:<strong>$</strong> sudo find /var/www/html -type d -exec chmod g+s {} \;<img src=”https://www.eternalsoftsolutions.com/blog/wp-content/uploads/2019/07/cm_Screenshot.png” width=”100%;” /></li>
<li>There are a few other fine-grained permissions we’ll adjust. First we’ll give group write access to the <strong>wp-content</strong> directory so that the web interface can make theme and plugin changes:<strong>$</strong> sudo chmod g+w /var/www/html/wp-contentAs part of this process, we will give the web server write access to all of the content in these two directories:<strong>$</strong> sudo chmod -R g+w /var/www/html/wp-content/themes<strong>$</strong> sudo chmod -R g+w /var/www/html/wp-content/plugins
<img src=”https://www.eternalsoftsolutions.com/blog/wp-content/uploads/2019/07/cn_Screenshot.png” width=”100%;” />
This should be a reasonable permissions set to start with. Some plugins and procedures might require additional tweaks.</li>
</ul>
</li>
<li>Now, we will make some changes to the main WordPress configuration file.
<ul class=”awsul”>
<li>We will adjust some secret keys to provide some security for our installation. WordPress provides a secure generator for these values so that you do not have to try to come up with good values on your own. These are only used internally, so it won’t hurt usability to have complex, secure values here.To grab secure values from the WordPress secret key generator, type:<strong>$</strong> curl -s https://api.wordpress.org/secret-key/1.1/salt/You will get back unique values that look something like this:<img src=”https://www.eternalsoftsolutions.com/blog/wp-content/uploads/2019/07/co_Screenshot.png” width=”100%;” />
Now, open the WordPress configuration file:
<strong>$</strong> nano /var/www/html/wp-cofig.php
Find the section that contains the dummy values for those settings.
<img src=”https://www.eternalsoftsolutions.com/blog/wp-content/uploads/2019/07/cp_Screenshot.png” width=”100%;” />
Replace these lines with the recently generated codes.
<img src=”https://www.eternalsoftsolutions.com/blog/wp-content/uploads/2019/07/cq_Screenshot.png” width=”100%;” /></li>
<li>Next, we need to modify some of the database connection settings like, adjusting the database name, the database user, and the associated password that we configured within MySQL.</li>
<li>The other change we need to make is to set the method that WordPress should use to write to the filesystem. Since we’ve given the web server permission to write where it needs to, we can explicitly set the filesystem method to “direct”. Failure to set this with our current settings would result in WordPress prompting for FTP credentials when we perform some actions. This setting can be added below the database connection settings, or anywhere else in the file:<img src=”https://www.eternalsoftsolutions.com/blog/wp-content/uploads/2019/07/cr_Screenshot.png” width=”100%;” />
<img src=”https://www.eternalsoftsolutions.com/blog/wp-content/uploads/2019/07/cs_Screenshot.png” width=”100%;” /></li>
<li>Save and close the file when you are finished.</li>
</ul>
</li>
<li>Now, we can hit our server-IP in the browser to complete the Installation through web interface:</li>
</ul>
<a href=”https://www.eternalsoftsolutions.com/aws-services/hire-aws-developer.php” target=”_blank” rel=”noopener”><button class=”btn btn-primary” role=”button”>Hire AWS Expert From Eternal</button></a>
<img src=”https://www.eternalsoftsolutions.com/blog/wp-content/uploads/2019/07/ct_Screenshot.png” width=”100%;” />
And the wordpress installation is done.
<style type=”text/css”>
ul.listing li {<br /> list-style-type: disc !important;<br /> }<br /> ul.listing-new li {<br /> list-style-type: disc !important;<br /> }<br /> .blog-portion-one ul li.list-none {<br /> list-style-type: none !important;<br /> list-style: none !important;<br /> }<br /> .blog-portion-one ul li {<br /> list-style: outside none none;<br /> margin-bottom: 10px;<br /> list-style-type: disc;<br /> }<br /> .listing img {<br /> width:100%;<br /> }<br /> ul.awsul li {<br />list-style-type: square !important;<br />}<br /></style>

Nirav Shah is the Director of Eternal Web Pvt Ltd, an AWS Advanced Consulting Partner and certified Odoo Partner based in the UK. With over a decade of experience in cloud computing, digital transformation, and ERP implementation, Nirav helps enterprises adopt the right technology to solve complex business challenges. He specialises in AWS infrastructure, Odoo ERP, and web development solutions for businesses across the UK and beyond.
Have queries about your project idea or concept? Please drop in your project details to discuss with our AWS Global Cloud Infrastructure service specialists and consultants.