Move WordPress site from shared hosting to Amazon EC2

This is a followup post from last week when I moved this blog from shared hosting on to Amazon Web Services EC2 Micro instance.

Basically the steps are straightforward for your old host
1. First is backup all your files
2. Backup the database.

Next series of steps are for the AWS side, first is to create an account
3. Create an account by signing up at and go through all verification to get your account activated.

Next setup EBS and launch an instance
4. Go to the AWS console and select the EC2 link(previously tab)
5. Next select a Region
6. Go under Elastic Block Store and choose Volumes

a. Click Create Volume, you can have up to 30GB EBS size with your Free Tier, select availability zone, no snapshot and Standard volume type.

7. Next to go to Instances link and click on Launch Instance

a. Go with the Classic wizard and select the AMI available(I selected Ubuntu Server)
b. On Instance Details, select 1 instance and Instance Type as Micro(t1.micro, 613MB), select availability zone or no preference.
d. Continue to next page with default options selected
e. Download the Keypair in a safe location
f. Select a security group
g. Finally launch new instance

7. Once Launched, you need to go to the EBS section then click on Volumes, select the EBS created earlier on step 6, click on More then choose Attach Volume and select the newly launched instance.
8. Next is to configure the firewall go to Security Groups and select the default, click on the Inbound tab, add the following ports 22 for SSH then Apply Rule to save it.
9. Finally go to Elastic IPs and click on Associate New Address, on EIP select EC2, select the new IP and click on Associate Address and assign it to the new Instance.

Accessing the IP should now load the default apache page.

Accessing your new instance via SSH and SFTP

This next series of steps is for accessing the server to be sure LAMP is working right. In summary you need to make sure Apache, MySQL and PHP are running luckily by default on Ubuntu this should all be loaded.

For SSH and MySQL setup
1. From the downloaded keypair earlier, you need to connect via Command Line, for Mac users you can open the Terminal, for Windows users you can download putty.

To login enter the command
#ssh -i mykeypair.pem ubuntu@ with your IP)

2. Once you are able to login you’ll be logged in as the ubuntu user, to get around things you need to either add sudo or quickly change to root by command
#sudo bash

3. Go to your mysql via, initial installation does not have a password

4. Add a password for the root and create a new user with grant all privileges. This should be the the new user/password in your wp-config.php file.

5. Create new database.
#create wpconfig database;

5. By being a little more savvy you can load the backup.sql file without using phpMyAdmin, but first you need to FTP the file by following the steps below.

Then access the file on mysql by dumping it
# sourcedump wp-backup.sql;

Finally time to SFTP and upload your files.
1. Download an FTP client like Filezilla
2. For Mac users, Launch Filezilla and choose Preference, select SFTP and click on Add Keyfile and select the keypair downloaded earlier, it should detect that its not the in the .ppk format and offers to create it for you, so just proceed.
3. Finally create a new Site by entering the Name of your site, the Host name which is the IP address, then Protocol choose SFTP and for the Logon Type choose Normal, and select Ubuntu as the user and password leave it blank.
4. Once logged in go to /var/www and upload your WordPress backup files, edit to the wp-config.php file
5. Make sure to change the file permission for the wp-content folder

Redirect your domain.
That should be it. Now for shared hosting we deal with DNS, but with Amazon EC2 we deal with A and CNAME records. Depending on your Domain Registrar create a new record and point the A or CNAME record to the IP address.

That should be it. If you have some questions just drop a note. Enjoy

9 thoughts on “Move WordPress site from shared hosting to Amazon EC2

  1. Hey thanks for this helpful step-by. I did everything thru step 9, and have found that when I go to the associated address, all I get is a message “Oops! Google Chrome could not connect to…”

    Of course,, there is nothing on the new site and my url does not point there. But being the pseudo-techy I am, how do I figure out if I have done this correctly to this point?

    1. thanks for dropping by. sometimes on new images and instances the apache is not installed, verify that apache is installed. If not, install one by loggin into ssh and either sudo install apache or in ubuntu to get the whole lamp stack sudo install lamp-server. Then access your IP.

  2. Can you give a little more detail on the following:
    5. Create new database.
    #create wpconfig database;

    5. By being a little more savvy you can load the backup.sql file without using phpMyAdmin, but first you need to FTP the file by following the steps below.

    Then access the file on mysql by dumping it
    # sourcedump wp-backup.sql;

    Do I still need to #create wpconfig database; if I do the second step 5? In the second step 5, where do I FTP the backup.sql to? Where do I enter the command # sourcedump wp-backup.sql; Do I FTP the backup.sql to the root folder and then run the #sourcedump command from the root of my ssh? Never ssh’d before so I’m not even sure my sentences are making sense.

    I’m guessing wp-backup.sql is the same as my backup.sql in the previous step.

Leave a Reply

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