How To Install WordPress On Amazon EC2 Instance

WordPress is the most popular and famous CMS (Content Management System) which is used in the world. It is a free and opensource content management system which is based on PHP and MySQL.

Amazon Elastic Compute Cloud ( Amazon EC2) is a cloud infrastructure. Amazon offer this service which provides raw computing resources on demand. EC2 provides computing instances that can be scalable in term of computing power and memory. Amazon EC2 also known as AWS EC2 ( Amazon Web Services EC2).

In this article I will explain how you can setup and configure WordPress on AWS EC2 Instance. Follow the below steps to configure WordPress on Amazon EC2.

Steps #1: Create An AWS Account

First you will need to create a AWS account. You will have to provide a credit card and a phone number for online registration process for verification purpose. Amazon provide a Free Usage Tier to host real apps without any charge.

Step #2: Create And Launch An Instance

Now select the type of EC2 instance. You can select micro instance because its price structure is very attractive. Follow my previous post to setup and configure a free Amazon EC2 instance.

Step #3: Login Into Your Instance Using SSH

Login to your instance, and identify the address or public IP of your instance. Now use that address or public IP and path to your ” .pem “file to ssh into your instance.

# ssh [email protected] -i ~/root/AWS-key/Ubuntu-2-keypair.pem
# ssh -i ~/root/AWS-key/Ubuntu-2-keypair.pem [email protected]

If you got any permission related issue with your .pem file than change it like below.

# chmod 600 ~/root/AWS-key/Ubuntu-2-keypair.pem

Follow the below command to switch to root user.

# sudo su

Step #4: Install Web Server On EC2

Now install any web server what you want in my example I am going to install Apache web server.

# yum install httpd

Restart Apache web server.

# service httpd start

Testing Web Server

Open your browser to access your web site.

Use your actual Public DNS name. You will see a standard Amazon place holder page in the browser.

Step #5: Install PHP

Follow the below command to install PHP.

# yum install php php-mysql

Restart Apache web server.

# service httpd restart

Test PHP installation

Create a ” phpinfo.php “page to test your PHP installation.

# cd /var/www/html
# vim phpinfo.php
<? php phpinfo() ?>

Save and exit.

Open your browser and access phpinfo.php page to test your PHP installation.

Use your actual Public DNS Name and IP.

Follow my previous post to install PHP on Linux system.

Step #6: Install MySQL Server

Follow the below command to install MySQL server.

# yum install mysql-server

Start MySQL server.

# service mysqld start

Now Create a database for your blog. In my example database is “blog_db”

# mysqladmin -uroot create blog_db

Secure your database.

# mysql_secure_Installation

Follow my previous article to install MySQL server and secure it.

Step #7: WordPress Installation

Follow the below steps to install WordPress.

# cd /root/download
# wget
# tar -xzvf latest.tar.gz

Above we have download and uncompress WordPress tar file. Now move its all content form “wordpress” directory to your web document root. In my example my web document root is “/var/www/html/“.

# mv /root/download/wordpress/* /var/www/html/

Now create a WordPress wp-config.php file if not available.

# cd /var/www/html/
# cp wp-config-sample.php wp-config.php

Now open the wp-config.php file and modify the database connection parameters like below.

define(‘DB_NAME’, ‘blog_db’);
define(‘DB_USER’, ‘root’);
define(‘DB_HOST’, ‘localhost’);

Save and exit.

In my example I am using blog_db, root user and password for testing purpose. Please create a separate user with privileges for your live environment.

Now open your browser and access your blog.

Use your actual public DNS name. You will see the WordPress initial configuration page, where you will need to configure an initial administrator account.


Fill out the all information for the site and click on Install WordPress button. Than it will ask for WordPress installation and  log in with the account you just created.


Click on the Log In button then fill out your account information.


Now you will presented with the WordPress Interface.


Step #8: Modifying Apache

Now create a Apache virtul host file for your blog.

# vim /etc/httpd/conf.d/vhost.conf

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html
ServerName server_domain_name_or_IP
<Directory /var/www/html/>
AllowOverride All
. . .


Above you have to change server_domain_name_or_IP to your domain name then save and close.

Restart Apache web server.

# service httpd restart

Step #9: Map IP Address With Your Domain Name

To use your blog in production you will need to do below steps.

1. Associate IP address to your instance:

  • In the AWS Management Console, click Elastic IPs (left navigation bar).
  • Click Allocate New Address, and confirm by clicking the “Yes, Allocate” button.
  • Right-click the newly allocated IP address and select “Associate” in the popup menu. Select the instance you just created and click “Yes, Associate

2. Map your domain name to that IP address:
To map your domain name to your IP address, you will need to use the tools provide by your domain registrar.

I hope this article will help to install WordPress on Amazon EC2 instance. If you have any queries and problem please comment in comment section.




Creating a free Amazon virtual private server on A... Hello Friend, If you are planing to setup a website for your domain, you need not to worry. AWS provides a free micro-instance  virtual private se...
s3cmd – Installation and Management of AWS S... s3cmd is used to upload, download, and manage directory and file with s3 (amazon simple storage). It is storage service in AWS. It is command line uti...
How to Setup RDS Instance On AWS Cloud Amazon provides RDS service to setup, operate and scale a relational database in the cloud. Amazon RDS is easy to set up, operate and scale MySQL depl...


Hi! I'm Sagar and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Leave a Reply

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