Looking For A Fast, Responsive, SEO Optimized & Self Customizable FREE WordPress Theme?

How
Pricing
My Account

How to Install WordPress on Amazon AWS EC2

Last Updated on February 26, 2024
by Neeraj Agarwal

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 on Amazon AWS Server.

 

If you have made your website on WordPress, you may have difficulty to upload it to 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 website on the Amazon server and after solving all those hectic steps I thought it should be a subject of my upcoming post.

Here are few important topics that are related to WordPress:-

  • Create A WordPress Website

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 an account on Amazon then create it first.

Step #1

Login to your AWS account.

Go to My Account / Console –> My Account

Goto Login

Step #2

Login to 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 a tag to your Instance. For that create a Key-Value pair.

Enter Value to the Name key. Let’s 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 (let’s 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.

wp-connect-file.pem

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 to 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

An instance is launched now and it is at running position.

instance launched

Step #16

Put the 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

By default user logged in as ubuntu. Switch user to root by the following command.

sudo su

switch user to root

Step #20

Install Apache on your server by using a 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 a password for the MySQL root user in the respective field.

enter password in the field

Re-enter the above password for confirmation.

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 the 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 a database for phpmyadmin.

step to configure database

 Enter a password for the user admin.

enter password in the field

Enter MySQL Application password for phpmyadmin.

enter password in the field

Confirm password.

step to confirm password

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

step to ignore error

Configure Apache

You need to configure Apache to make phpmyadmin accessible via a 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 the 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 (let’s say WordPress)

step tp create databse

The 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 a command.

cd

unix command

Command #2

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

wget https://wordpress.org/latest.tar.gz

unix command

Command #3

Extract it to the /var/www directory

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

unix command

Command #4

By default, all files will be extracted in a directory “WordPress”.

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

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

unix command

Command #5

Now remove the “WordPress” directory by using a command.

rm -rf /var/www/WordPress

unix command

Mapping Domain Name With Instance IP

Before you install WordPress you need to map a domain name to 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 to 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 key file…

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 the path of a local directory of your machine -> click on Connect.

unix command

A 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 the 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.

Command

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 making changes in file attributes.

Now delete this index.html file permanently.

Enable access 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 to 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 is 2 type of Apache extension exists.

1. Rewrite Module

This module enables custom permalink on WordPress.

To enable it to use following 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 to 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 steps, let me know. I will definitely resolve your issues.

You might also be interested in:

  • How to Install WordPress on Localhost
  • How to install WordPress locally on Mac system
Leave a Reply Cancel reply

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

InkThemes Logo

Customize Your Website With Beautiful Premium WordPress Themes, Templates & Plugins.

One Click Installation With Advanced Functionality & Awesome Support.

For any query contact us at:
  • [email protected]
Products
  • WordPress Themes
  • Email Marketing
  • Subscription Billing
  • Form Builder
  • Email Verification
Terms of Usage
  • Terms and Conditions
  • Privacy Policy
  • InkThemes Branding
  • Affiliate
  • Contact Us
Join Us
  • Follow us on Twitter
  • Be a fan on Facebook
Analytics
heap-logo1
Help and Support
  • Support
  • Documentation
About
  • Who we are?
  • Careers
Links
  • Blog Categories
  • Marketplace Categories

© 2023 InkThemes LLC. All rights reserved.