Credit for this post goes to my mentor, Andy Cross, who walked me through my first EC2 deployment. Three cheers to Andy!!!
Amazon recently released Micro instances on their EC2 platform, which makes cloud computing incredibly cheap ($16 a month) and viable for hosting small sites. Plus your’e backed by the power of the THE CLOUD. Anyway, I’ve decided to host my blog in the cloud, in Linux!!
I run a WordPress blog because a) it’s full of features, b) it’s free c) is awesome. Even tho it’s php, as a developer, you have stick your oar into technologies outside of your comfort zone now and then. It’s been running on a Windows VPS, so far for which I pay a ridiculous sum of money, because Windows is a power hungry whore. Using the Amazon Web Services Calculator, I found then on a micro instance I could be saving over 90% on my monthly bill.
I started out with an Ubuntu 10 LAMP instance and has it running in under 2 hours, but Ubuntu has a bug with Elastic Block Stores and I didn’t really want to mess about with the work around that had been posted on various forums, so I went for Fedora box instead.
Here’s my screen by screen guide on setting up WordPress on Fedora 8 on an Amazon EC2 micro instance.
Head to https://console.aws.amazon.com/ec2/home (you’ll need to create an account if your don’t have one, oh and you’ll also need to choose where you want your servers to reside, the choice is yours) and you should be presented with the EC2 management console dashboard. You won;t have any instances set up yet, so click on Launch Instance to create one.
You launch an instance with a base image (Amazon Machine Image) which will be an OS that may or may not have other software preinstalled, for example there are community AMI’s for mail servers and web servers and a whole lot more. We’re going to use the Getting Started on Fedora Core 8 AMI.
Choose how many you want, which zone in the your chosen part of the world and what type. Make sure you select Micro. You can also choose you either Launch an Instance (which we want to do), Request a Spot Instance (basically request a temporary server for a specific price) or Launch it into you Virtual Private Cloud, if you have one.
Make changes to the Kernel and RAM Disk at your own risk
You need a Key pair for authenticating when you connect to your server over SSH. Create and download one and make sure you actually download it. You will not be able to download it again and without it you won;t be able to SSH into your instance.
A security group is what it is. You’ll want at least SSH and HTTP for WordPress. you also resuse existing groups
Confirm it
Done. It should only take a few seconds for you instance to launch (it depends how busy it is)
When it is running, it should be in the manager shown as running.
You need to grab PuTTY from here and extract it somewhere on your drive. Fire up PuTTYgen and Load the Key Pair (pem) file that you downloaded from Amazon. Save the Private Key (ppk) without a passphrase.
Launch PuTTY, head down to the Auth menu and select the ppk you just created.
Enter your Amazon EC2 Instance Hostname (you can find this in the EC2 Management console ) and save the session settings.
Click Open and when the warning below is displayed, click Yes.
A fantastic cmd screen show pop up and you can login with the username ‘root’
Use the command ‘˜lsof -i’ to view open ports on the instance. As you can see, no port 80 is open, so we need to install Apache (and the rest of the LAMP stack)
Install Apache (httpd)
Start the Apache service
Make sure Apache is running by checking that it’s listening on port 80
Browse to your hostname and you should see the Fedora welcome page!
Install php and the mysql client
install the mysql server
Install PHPMyAdmin (web client admin interface for mysql)
By default, PHPMyAdmin is blocked to external IP’s, so open up the PHPMyAdmin config file using vim.
Edit the file as per below. You need to hit the Insert key to start editing.
You can’t Crtl+S to save in vim. Hit the ESC key, then
and Enter to save an exit. For reference, ESC followed by :q and Enter will exit the file without saving (vim will also warn you if you have unsaved changes)
Restart Apache to pick up the changes
Start mysql
Set the root user’s password for mysql
Head to http:///phpmyadmin. Log in with root credentials and create a new database called wordpress (default settings)
Create a new user and hit GO
Click on edit privileges
From the Database specific privileges section, select the wordpress database from the drop down
Click Check All and Go
And the privileges should end up looking like this
Jump back into you server and download wordpress using wget (you could use yum install to install wordpress, but it configures it in a slightly different way meaning that the only way to auto-update would be via yum, not via wordpress)
Unpack it to your html folder, it will be unpacked as /var/www/html/wordpress, meaning your the URL for your blog will be http:///wordpress but …
… you can host it at the root of your domain by moving the content into html and follow this by …
… deleting the wordpress directory.
We need to apply the right permissions to the html folder so that the Apache user can Write to it, but first we need to find out who the Apache user actually is. Open the Apache config file.
Find the name of the Apache user, in this case ‘apache’.
Change the owner and permissions on the html folder
Don’t go to your wordpress site just yet. If you do, wordpress will configure it with your EC2 hostname as the domain for the blog, and when we attach an IP to our instance (so we can point a domain at it) we won’t be able to log in (without changing the setting directly in the database, so it’s not a complete fail). head back to the EC2 management console, click on Elastic IP and Allocate New Address
Associate the IP with your instance. Amazon change you if you have an IP that is not assigned, so it’s best to always assign IP’s or release them completely.
Select the instance id of the instance to attach the IP to.
Attachment complete, as shown the the information panel for your instance in the EC2 management console.
You have to connect to your server by IP address now. Your hostname will no longer work, and if you detach the IP, your instance will be assigned a different hostname
Head to your blog
Enter the database connection details
Database setup complete
Enter you site configuration details
Setup complete!!













































