Wednesday, May 27, 2015

Setup WordPress On Amazon EC2 : Installation steps with Linux commands cheat sheet

This is a real quick guide to setup WordPress On Amazon EC2. It is a direct result of following a Youtube tutorial on the same subject by a guy named Avishai Sam Bitton, who is the Marketing Director at Imonomy & Founder of Go Social.

The Youtube tutorial by itself was great. In 10 minutes, Avishai shows you how to go from creating a Linux instance to the WordPress admin page. It is done on the Amazon Linux AMI (not Ubuntu or RHEL). The only missing thing is the Linux commands cheat sheet (copy-paste-able) which I will cover in the following paragraphs. I will try to provide maximum information in minimal words.

Here is the actual video and what follows is my notes on the same :

To setup a WordPress blog on the Amazon EC2 infrastructure, you need to know and do the following as a prerequisite:
  • Have Putty and PuttyGen installed (or ready for use)
  • Have basic understanding of Linux concepts and commands. Know how to use putty, and optionally understand security concepts.
  • You should have created an Amazon AWS account. A credit card signup is required even though the basic Linux instance (micro instance) is free for 12-months.
Once you're ok with the above, follow these steps.

Part A

  1. Login to the Amazon AWS console.
  2. Select :  EC2  - Virtual servers in the cloud.
  3. Under Create Instance, click on Launch Instance.
  4. Select Amazon AMI Linux - 64 bit
  5. Check settings. Maintain defaults. Keep clicking next - until you reach the Configure Security Group section.
  6. Click Add Rule twice : 
    • One for the HTTP (port 80) 
    • another for the HTTPS (port 443). 
    • Also add a third one and select Custom TCP port. Enter port 8080 (if your apache or nginx server runs on this port)
    • The SSH rule is already added with port 22.
  7. Click Review and Launch. Click Launch. This opens a dialog to create a new key pair. 
  8. Create a new key pair. Download the pem file to your local folder.
  9. Now click Launch Instance (wait for 5 mins for startup)
  10. In the meantime, convert the pem file to ppk file
    • Windows :  PuttyGen tool, go to Menu->Convert->Import->Save file with ppk extension to your local drive.
    • If you are on Mac, no need to convert. You can use the pem file to login directly using the generated Elastic IP address (steps given below).

Part B

  1. The instance which you launched couple of steps back should now be running(green tick mark)
  2. On the Left pane -> click Elastic IPs -> Allocate New Address -> Yes,Allocate
  3. Right click on the allocated Elastic IP -> Associate Address -> running instance (some 10-character code). Click Associate.
  4. Go to EC2 Dashboard -> Running Instances. Check the Public IP and Elastic IP (both should be same).
  5. Copy the IP address. Open Putty and copy the IP address (say into putty's Host.
  6. Go to SSH->Auth, browse open the converted ppk file. Go back to Session and click Open. Putty's black screen should open up.
    • Windows  : Login as : ec2-user
    • Mac : 
      ssh -i keyfile.pem ec2-user@

Part C - The Linux Commands (aka Cheat Sheet)

Once you've logged in as the ec2-user, type in the below commands one after another.
Note: In all the "install" commands, press "y" if the shell asks for install confirmation.
sudo yum updateUpdates all software patches on the instance.
sudo suSwitching to root user
yum install httpdInstalls Apache server
service httpd startStarts Apache server
yum install php php-mysqlInstalls PHP
yum install mysql-serverInstalls MySQL
service mysqld startStarts MySQL server
mysqladmin -uroot create myblogmyblog will the name of the database in this example)
mysql_secure_installationFollow these steps:
* Enter current password for root: just press enter key
* Set root password? : Y (enter password twice)
* Remove Anonymous Users? : Y
* Disallow root login remotely: Y
* Remove test database and access to it? : Y
* Reload privileges table now? : Y
cd /var/www/htmlGo to this directory
wget the latest version of Wordpress
tar -xzvf latest.tar.gzExtract Wordpress
mv wordpress myblogRename the the blog to myblog
cd myblogGo to the myblog directory
mv wp-config-sample.php wp-config.phpRename the php config file.
vi wp-config.phpEdit the wp-config.php file with the given information :
* define('DB_NAME', 'myblog')
* define('DB_USER', 'root')
* define('DB_PASSWORD', 'yourpassword')
* press escape key
* :wq! (to save and exit)
service httpd restartRestarts Apache server

Now, open your browser, and enter : http://IPAddress/myblog  (in our case,
Your Wordpress blog's Admin installation page should be ready for configuration.
If your web server is running on port 8080, then use the url :


Unknown said...

This is incredible, what a great resource, thank you. Any idea why permalinks (specifically, setting to /%postname%/) don't work?

Unknown said...

NM, I got it. You can fix it by following the instructions here:

Ajay Kiran said...

what if i dont want ip/myblog
and just hve ip/ to install wordpress

how to do it

mukesh said...

I've followed each and every step as mentioned by you everything went well but when I'm trying to view my blog ipaddress/myblogname all I'm getting is a blank page! Please help

Royer Adames said...

After done installing, how to you access the directory? The installation files.

vinoth R said...

Thanks man! your steps are more helpful than Youtube tutorial videos that would setup my WP account easily.

Unknown said...

Great Tutorial.
I actually saw the youtube video and felt that the cheat sheet and some explanation on each steps are missing - this is a great addendum.

Parana Impact said...

Thank you for the Blog.Parana Impact help you reach the right target customers
to advertise your products and services.
Amazon AWS Email List

shree priya said...

This is my first visit to your blog, your post made productive reading, thank you. WordPress Installation

Arvind Sharma said...

I really appreciate information shared above. It’s of great help to us. If someone wants to learn (ILT) instructor lead live training on AWS (Amazon Web Services) MaxMunus Offer World Class AWS Certification level classroom training in Bangalore, we have industry expert trainers. We provide Training Material and Software Support. MaxMunus has successfully conducted 1, 00,000 + trainings in India, USA, UK, Australia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
Enroll for the live & interactive classroom training
Skype id: arvind.sharma901
Ph :( 0) 9019891304 / 080 - 41103383

sai venkat said...

Everyone wants to get unique place in the IT industry’s for that you need to upgrade your skills, your blog helps me improvise my skill set to get good career, keep sharing your thoughts with us.

Aws Online Training

supriya seth said...

Good article ,Thank you very much for the great guidance.

Best Regards,
CourseIng - AWS Online Training in Hyderabad

Swathi Samala said...

The article is very easy to under stand AWS Online course Bangalore

Gokula krishnan said...

Please tell me how to upload existing wordpress site which is in local disk. It is confusing with linux commands. Is there any easy steps to upload existing file with DB and how to connect it.

Renith Harsan said...

Those guidelines additionally worked to become a good way to recognize that other people online have the identical fervor like mine to grasp great deal more around this condition. devops training in bangalore .


I feel really happy to have seen your webpage and look forward to so
many more entertaining times reading here. Thanks once more for all
the details.

AWS Training in Bangalore

AWS Training in Bangalore

soukya reddy said...

I have read your blog its very attractive and impressive. I like your blog. AWS Online Training Bangalore
AWS Online Training Hyderabad
AWS Online Training

IT Tutorials said...

It is really a great work and the way in which you are sharing the knowledge is excellent.Amazon Web service Training in Velachery

IT Tutorials said...

It is really a great work and the way in which you are sharing the knowledge is excellent.Amazon Web service Training in Velachery

Unknown said...

Best Solidworks training institute in noida

SolidWorks is a solid modeling computer-aided design (CAD) and computer-aided engineering (CAE) computer program that runs on Microsoft Windows. SolidWorks is published by Dassault Systems. Solid Works: well, it is purely a product to design machines. But, of course, there are other applications, like aerospace, automobile, consumer products, etc. Much user friendly than the former one, in terms of modeling, editing designs, creating mechanisms, etc.
Solid Works is a Middle level, Main stream software with focus on Product development & this software is aimed at Small scale & Middle level Companies whose interest is to have a reasonably priced CAD system which can support their product development needs and at the same time helps them get their product market faster.

Company Address:
Phone No: 0120-4330760 ,+91-880-282-0025