Skip to main content

Moving WordPress to Amazon EC2

I decided to move my small project from GoDaddy 4GH Hosting to Amazon EC2 using their micro instance.

Here's how I did it.

I am an existing Amazon customer, so I decided to use the same email address and password to access AWS Amazon. I am using Amazon S3 for backup, and use my account to buy books.

  • In EC2 Dashboard, you will see "Launch Instance" to initiate your first server at Amazon cloud.
  • I've used the Classic Wizard to launch  the setup, click continue.
  • In choose an AMI, you have the option to select from the Quick Start, My AMIs, Community AMIs, and Marketplace. For this guide, let's use Amazon Linux AMI 2012.03 package, it includes Linux 3.2, AWS tools, and repository access to multiple version of MySQL. I click Select 64 bit to proceed.
  • Select Launch Instances, availability zone, select default no preference, then click Continue.
  • In Key, I simply use my domain name, click Continue.
  • Select "Create a new Key Pair" using your domain name for simple management of keys.
  • Choose one or more of your existing Security Groups. I prefer to create a new group for a new project.
Firewall Policy example:
HTTP (0.0.0.0/0)

SSH (0.0.0.0/0)
Custom Rule, Port Range 20-21 (0.0.0.0/0)
Custom Rule, Port Range 14000-14050 (0.0.0.0/0)

  • Click Launch to finish the setup. I did not create Status Check Alarms, I will go back when the server is in production.
  • In My Resources, click the Refresh button to see your new instance.
  • Click running instances to see the list of instance.
  • Now to manage the server. Select the instance (put check to select the instance). In Instance Actions, select Connect, this will give you option to connect e.g. Connect with a standalone SSH Client and Connect from your browser using the Java SSH Client (Java Required).
  • I like Putty SSH tool, so obviously I choose Connect with a stand alone SSH client.
  • You need to download the PuTTYgen to convert your private key. Here's a procedure provided by Amazon.
  • Let's get an Elastic IP address for the server. In AWS console dashboard, click Elastic IPs, click on Allocate New Address, click Yes, Allocate
  • In Addresses, put check on the IP address, then click Associate Address. In Select an instance, choose the instance to associate your IP, click Yes Associate. It will shows in your list of Addresses, IP Address point to your Public DNS. 
For example: 184.x.x.x associated to ec2-x.x.x.x.computer-1.amazonaws.com
  • Now go to your domain name registrar e.g. NeedName.com, Enom, or GoDaddy. Add A record IP Address to your domain.
  • After that, let's begin managing our instance (cloud server). If everything is correctly configured with your PuTTY setup, you should be using your user name (ec2-user) to login, and yes no password required because of your private key.
Now we're connected to the first instance. Let's do update, very important run the following command.
[ec2-user@ip-information-here ~]$ sudo yum update [Enter]
The script will run for about 2-5 minutes depending your Internet bandwidth speed.

Next.
[ec2-user@ip-information-here ~]$ sudo su [Enter]

After you execute sudo su, you're now in super user mode.
[root@ip-information-here ~]$

We have the server but we have nothing configure yet, so let's install Apache Web Server.
[root@ip-information-here ~]$ yum install httpd
Start the service
[root@ip-information-here ~]$ service httpd start
Configure to start httpd service automatically

[root@ip-information-here ~]$ chkconfig httpd on

How about installing PHP? Let install PHP
[root@ip-information-here ~]$ yum install php php-mysql

Restart the Apache web server to introduce PHP
[root@ip-information-here ~]$ service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]

And install MySQL database to hold our data.
[root@ip-information-here ~]$ yum install mysql-server

Start MySQL service:
[root@ip-information-here ~]$ service mysqld start

Similar to httpd, we need to start MySQL service automatically:
[root@ip-information-here ~]$ chkconfig mysqld on

Create your first database:
[root@ip-information-here ~]$ mysqladmin -uroot create friended
where friended is the database name

Let us secure our database:
[root@ip-information-here ~]$ mysql_secure_installation
Enter the root current password.
Change root password, and confirm.
Remove anonymous user: Y
Disallow root login remotely: Y
Remove test database and access to it: Y
Reload privilege tables now: Y 

I want to install my wordpress in my root directory e.g. /var/www/html.

Check your current directory:
[root@ip-information-here ~]$ pwd
Output:
//home/ec2-user

Change directory to /var/www/
[root@ip-information-here ~]$ cd /var/www

Download the latest copy of Wordpress:
[root@ip-information-here ~]$ wget http://wordpress.org/latest.tar.gz

Extract WordPress:
[root@ip-information-here ~]$ tar -xzvf latest.tar.gz

Move the wordpress directory to the html folder.ec2
[root@ip-information-here ~]$ rmdir html
[root@ip-information-here ~]$ mv wordpress html

Delete the latest.tar.gz copy to clean our install.
[root@ip-information-here ~]$ rm latest.tar.gz

Now, configure the Wordpress install
Change directory to html
[root@ip-information-here ~]$ cd html

[root@ip-information-here ~]$ mv wp-config-sample.php wp-config.php
Edit wp-config.php with your database connection credentials e.g. db name, username, and password.
[root@ip-information-here ~]$ vi wp-config.php

define(‘DB_NAME’, ‘YOUR_DATABASE_NAME’);
define(‘DB_USER’, ‘root’);
define(‘DB_PASSWORD’, ‘YOUR_PASSWORD’);
define(‘DB_HOST’, ‘localhost’);

Press ESC, type :wq to save.

Configure your wordpress.

It's easier if you have an FTP Server, let's go ahead and install one for our server.
[root@ip-information-here ~]$ yum install vsftpd


References:

Step-by-step installation of phpMyAdmin to Amazon EC2: http://calebogden.com/wordpress-on-linux-in-the-amazon-cloud-with-mac/








Comments

Popular posts from this blog

Alternative Social Networks

If you are planning to create your  social network  e.g. similar to Facebook. Here's a short list of alternative software's: Open Source and Free​ http://buddypress.org/  - Wordpress (Open Source and Free) http://elgg.org/  - (Open Source and Free) Commercial Social Networks software http://www.socialengine.com/  ($299 Stand Alone, $29/mo Cloud) http://www.jomsocial.com/  (run with Joomla, need to know CMS) http://www.boonex.com/  (very expensive, $399 for Standard) http://www.anahitapolis.com/ http://www.oxwall.org/ http://sharetronix.com/ http://www.moosocial.com/ http://www.jcow.net/ http://phpdolphin.com http://www.grou.ps  (from free to Commercial, I left my networks and they are selling it  http://www.phpfox.com/  (I used this before, it's hard to maintain. I moved to NING but left too after it was sold to another company) http://www.ning.com  (I don't recommend using this service, it's hard to export your data when it's time to move) S

Learning Vulnerability Scanning by KING.NET

Learning Vulnerability Scanning is fun and easy. So I hope you enjoy reading this short how to guide on how to use vulnerability scanning to secure your servers and networks. NMAP is the swiss tool that you need to learn if you're serious in Cyber Security profession. The NMAP tool can be use with NSE scripting (Nmap Scripting Engine) to automate your tasks. For example using NSE Script using a  single vulnerability (cold fusion)  to scan our test lab machine. root@kali:~# nmap -v -p 80  --script http-vuln-cve2010-2861  10.11.1.220 Starting Nmap 6.47 ( http://nmap.org ) at 2016-07-22 17:34 EDT NSE: Loaded 1 scripts for scanning. NSE: Script Pre-scanning. Initiating ARP Ping Scan at 17:34 Scanning 10.11.1.220 [1 port] Completed ARP Ping Scan at 17:34, 0.04s elapsed (1 total hosts) Initiating Parallel DNS resolution of 1 host. at 17:34 Completed Parallel DNS resolution of 1 host. at 17:35, 13.01s elapsed Initiating SYN Stealth Scan at 17:35 Scanning 10.11.1.220 [1 port] Comp