How to Install WordPress on Amazon AWS EC2

Malika Rani

Nowadays, everyone wants to run a website and I am sure you too are looking for the same. You need to require hosting to launch your website, So I am covering step by step process to host your website with Amazon AWS Server.

step by step procedure

If you have made your website on WordPress, you may have difficulty to upload it on the server. You may search all the possible solutions for a step by step process to do so (as we did while hosting FormGet on Amazon), but you won’t find any.

We faced some issues while uploading FormGet on the Amazon server and after solving all those hectic steps I thought it should be a subject of my upcoming post.

So, in this post, you will find a complete procedure (a step by step tutorial) of How you can upload WordPress on Amazon EC2.

Note : I assume that you have an account on Amazon Web Server (AWS). If you do not have account on Amazon then create it first.

Step #1

Login into your AWS account.

Go to My Account / Console –> My Account

Goto Login

Step #2

Login into your AWS account by entering your email address and password.

login into Amazon account

Step #3

After successfully login,

Go to My Account / Console –> AWS Management Console

select AWS management console

Step #4

Select EC2 from the list of Amazon Web Services.

select EC2 from the list of Amazon Web Services

Step #5

EC2 Dashboard appears on the screen. Now you need to create a new Instance. For that,

Go to Instance –> Launch Instance

EC2 dashboard

Step #6

Select Classic Wizard for the instance and click on Continue.

select classic wizard

Step #7

Choose Ubuntu Server 13.04 of 64-bit from the Amazon Machine Image (AMI) list and click on Select.

choose ubuntu server 13.04 from list

Step #8

Select Instance Type T1 Micro

select T1 Micro instance

Click to Continue

click on Continue

Step #9

Continue with default Instance Details.

go to continue with default instance details

Again click to Continue

click to continue

Step #10

Add tag to your Instance. For that create Key-Value pair.

Enter Value to the Name key. Lets give WordPress and go to Continue.

step to enter key value

Step #11

Create a key pair to securely connect to your instance after it launches. For that,

Go to Create a new Key Pair –> Enter a name for your key pair (lets give name wp-connect-file) –> click on Create & Download your Key Pair.

 create a new key pair

In just a click wp-connect-file.pem file downloaded into your computer.


Step #12

Create a security group which helps to determine whether the network port is open/blocked on your Instance. For that,

Go to Create a new Security Group –> Enter Group Name( lets give WordPress) –> Enter Group Description –> select HTTP rule from the inbound rules list.

security group

Click on Add Rule

click on add rule button

HTTP Service added into the group.

HTTP service added

Similarly select another rule SSH and added into the group

 HTTP & SSH added

click to Continue

step to continue

Step #13

Review the details and click on Launch

review the information

Step #14

If you want you can create status check alarms. Then click on Close.

step to create alarms check

Step #15

Instance is launched now and it is at running position.

instance launched

Step #16

Put check on the newly created Instance. Then go to Actions –> Connect

step to connect instance

Step #17

Enter the Private key path ( location of your wp-connect-file.pem file which is stored on your machine)

Then click on Launch SSH Client.

step to enter private key path

Setup An Apache

Step #18

You can see here wp-connect-file.pem file is opened now.

wp-connect-file.pem file is opened now

Step #19

Bydefault user logged in as ubuntu. Switch user to root by following command.

sudo su

switch user to root

Step #20

Install Apache on your server by using command.

apt-get install apache2

commant to install apache

Step #21

After completion of Installation process.

Copy the Public DNS code.

copy the public DNS code

Now, paste the code in browser’s address bar. You will see the page like this.

run the code in browser

Above page shows that Amazon is working properly.

Install Php5 on Server

Step #22

Use the following command to install Php5 on the server.

Command #1

apt-get install php5

php5 install command

Command #2

apt-get install libapache2-mod-php5

unix command

Command #3

/etc/init.d/apache2 restart

unix command

Note :

If your php installation fails with a message such as “Unable to fetch some archives…” then run the following command and repeat the above process.

apt-get update

Step #23

Create a php test file ( let say mytest.php) to test php5 is running properly or not. Use the following command to do so.

Command #1

cd /var/www/

unix command

Command #2

vi mytest.php

unix command

Step #24

Php test file is created. Now insert the content in the file by following sub-steps.

1. To switch into insert mode. Press i

2. Type <? php phpinfo() ?>

insert php code

3. Press esc key to escape from insert mode.

4. Type :wq to write content in the file and quit form the editor.

write and quit from the editor

Step #25

Run the mytest.php file in your browser.

Use the address like this –> public DNS/mytest.php

run mytest.php file

The above page shows that PHP is running properly on your Apache.

Install MySQL

Step #26

Use the command to install MySQL server.

apt-get install mysql-server

unix command to install mysql

Step #27

Enter password for the MySQL root user in the respective field.

enter password in the field

Re-enter the above password for confirm.

re-enter the password in the field

Step #28

Command #1

To run Php5 with MYSQL use command.

apt-get install php5-mysql

unix command

Command #2

Install PHP module for MYSQL by following command.

apt-get install libapache2-mod-auth-mysql

unix command

Install phpMyAdmin

Step #29

Use the following command to Install phpMyAdmin on your server.

apt-get install phpmyadmin

step to install phpmyadmin

Select apache2 web server.

select apache2 web server

Go with Yes to configure database for phpmyadmin.

step to configure database

 Enter password for the user admin.

enter password in the field

Enter MySQL Application password for phpmyadmin.

enter password in the field

Comfirm password.

step to confirm password

If error generate while installing database then choose ignore to continue with the operation.

step to ignore error

Configure Apache

You need to configure Apache to make phpmyadmin accessible via browser.

 Step #30

Use the following command to configure Apache.

Command #1

To make phpMyAdmin accessible via browser use the command

ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf

step tp configure apache

Command #2

Restart Apache web server to pick up the changes by following command.

/etc/init.d/apache2 reload

unix command

 Step #31

Now you can access phpmyadmin in your browser.

Use the address like this –> public DNS/phpmyadmin

phpmyadmin page

Go to Database for creation.

select database

Create database (lets say wordpress)

step tp create databse

Database is created now as you can see in the image given below.

database is created

Installation of WordPress

Step #32

Command #1

Navigate to home directory of the server by using command.


unix command

Command #2

Download the latest copy of the WordPress by using following command.


unix command

Command #3

Extract it to the /var/www directory

tar -xzvf latest.tar.gz -C /var/www

unix command

Command #4

Bydefault all files will be extracted in a directory “wordpress”.

So to move the files to root of the web server by using command given below.

cp -avr /var/www/wordpress/* /var/www

unix command

Command #5

Now remove the “wordpress” directory by using command.

rm -rf /var/www/wordpress

unix command

Mapping Domain Name With Instance IP

Before you install WordPress you need to map domain name with the virtual server.

Step #33

Select the newly created instance and then click on Elastic IPs listed in EC2 Dashboard.

unix command

Click on Allocate New Address

unix command

A window appears on the screen for Allocate New Address.

Click on Yes,Allocate.

unix command

Now go to Associate Address.

unix command

Select your Instance from the drop-down list and then click on Yes,Associate.

unix command

 You can see here Elastic IP is now associated with your Instance.

unix command

Now run this Elastic IP in the address bar of your browser.

unix command

From the above image it is clear that it will work perfectly.

Open WordPress Installation Page

Step #34

Enter the Elastic IP followed by index.php in the address bar of your browser.

Click on Create a Configuration File.

unix command

Continue with the next step by click on Let’s go!

unix command

Enter the database connection details.

unix command

Setting FTP Access To Your Server

Step #35

Install FileZilla On Your Machine.

Now open FileZilla and then go to Edit –> Settings….

unix command

Under Settings select SFTP from the list and then click on Add keyfile…

unix command

Convert your wp-connect-file.pem in a format supported by FileZilla.

For this, click on Yes

unix command

Now the above file is converted into wp-file-connect1.ppk format.

Establish Connection With Server

Step #35

Go to File –> Site Manager…

unix command

Under General Settings of Site Manager.

Create New Site (lets say wordpress_1)

Enter Elastic IP Address under Host field –> Select SFTP – SSH File Transfer Protocol –>  Choose Logon Type as Normal —>Named user as ubuntu –> click on Connect.

step to create site

Under Advanced Settings of Site Manager.

Select Server Type Unix —> Enter path of local directory of your machine -> click on Connect.

unix command

Connection is established now.

Follow the path (  –> var –> www –> index.html)

In order to execute WordPress perfectly on your browser you need to delete this index.html file.

index.html file

But, you are not allowed to delete index.html file right now.

Before deleting index.html file do following steps

Step #37

Write the following command in the wp-connect-file.pem.


Below command allow you to write access to /var/www

sudo chown -R www-data /var/www

unix command

Step #38

Follow the path (  –> var –> www –> index.html)

Select index.html file –> do right click –> File permissions…

select file permission

Change the permissions of the index.html file by put check on the highlighted Write and Execute fields appear in the image given below and then click on OK.

unix command

After make changes in file attributes.

Now delete this index.html file permanently.

Enable htaccess and URL Rewrite

Step #39

You need to edit default Apache file by writing following code in the wp-connect-file.pem.

sudo vim /etc/apache2/sites-available/default

unix command

Step #40

Press i to switch into insert mode.

Change the setting of AllowOverride from None to All

unix command

Now hit esc key to escape from insert mode.

And write :wq –> to write the changes in the file and exit from the editor.

unix command

Restart the Apache web server for changes to take effect by writing following command.

sudo /etc/init.d/apache2 restart

unix command

Step #41

Now run the WordPress on Amazon EC2.

For that, paste Elastic IP / wp-admin in the address bar of the browser.

Click on Run the install.

step to run install

Create your WordPress site.

step to create WordPress site

You can see in the image given below WordPress site execute perfectly on your browser.

step to execute WordPress site.

Note: To map above elastic IP Address of Amazon EC2 with the domain name. You can follow this Tutorial.

Apache Extensions

There are 2 type of Apache extention exists.

1. Rewrite Module

This module enables custom permalink on WordPress.

To enable it use follownig commands –

sudo a2enmod rewrite

sudo service apache2 restart

2. Curl Module

This module enables curl based function. Some premium themes and plugins use this curl for verifying activation key.

To enable it use following commands –

sudo apt-get install php5-curl

sudo service apache2 restart

Hope this tutorial helps you to install WordPress on Amazon EC2 easily. If you find any difficulty in any of the above step, let me know. I will definitly resolve your issues.

Last Updated on: January 31, 2017

Under: ,

Comments and Responses

Your email address will not be published. Required fields are marked *