AWS WordPress

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
OR
# 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.

http://ec2-54-175-34-198.compute-1.amazonaws.com

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.

http://ec2-54-175-34-198.compute-1.amazonaws.com/phpinfo.php

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 http://wordpress.org/latest.tar.gz
# 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_PASSWORD’, ‘YOUR_PASSWORD’);
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.

http://ec2-54-175-34-198.compute-1.amazonaws.com/

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

wordpress-initial_config

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.

word-press-confirm_installation

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

wordpress-login

Now you will presented with the WordPress Interface.

wordpress-admin_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 webmaster@localhost
DocumentRoot /var/www/html
ServerName server_domain_name_or_IP
<Directory /var/www/html/>
AllowOverride All
</Directory>
. . .

</VirtualHost>

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.

Thanks:)

Thank you! for visiting LookLinux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.

About the author

mm

Santosh Prasad

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

1 Comment

  • Right here is the right webpage for anybody who wants to understand this
    topic. You know a whole lot its almost hard to argue
    with you (not that I actually will need to…HaHa). You certainly put a fresh spin on a topic that’s been discussed for
    ages. Excellent stuff, just wonderful!

Leave a Comment