2010 EC2 Setup Part 2

Setting up MySQL

1) sudo apt-get install mysql-server

2) Enter Root password

3) sudo service mysql start

EC2 Keypairs

Had not touched this for a while and got stuck trying to log into a new instance on EC2. Tried a few options and kept getting “Permission denied (publickey).”

So here are the gotcha’s

1) You need to use the correct keypair.

2) Use you private key

3) Log in a a specific user

For an Ubuntu instance with a private keypair called mykeys.pem

ssh -v -l ubuntu -i mykeys.pem ec2-some-ip.com

2010 EC2 setup

Started this again. Lots has changed, so blogging again.

1) Get new version of Ubuntu. These guys make it easy.

2) I chose ami-714ba518 since it has EBS and that means it remembers the instance between reboots

3) Fire it up and then log in

4) Log in as ubuntu and the server is the public DNS entry of the EC2 server

5) Start the updates & install Java JDK

# sudo add-apt-repository ‘deb http://archive.canonical.com/ lucid partner’

# sudo apt-get update

# sudo apt-get install sun-java6-jdk

# java -version

java version “1.6.0_20″Java(TM) SE Runtime Environment (build 1.6.0_20-b02)Java HotSpot(TM) Client VM (build 16.3-b01, mixed mode, sharing)

6) Now install Tomcat

# sudo apt-get install tomcat6

7) Test Tomcat

Enter this in a browser http://<public DNS>:8080

Up and running.

Next is to shut down 8080 and set up Apache with proxy to Tomcat

EC2 WordPress

Getting it up and running is straight forward

On a basic image (ami-ed46a784) do the following:

apt-get install -y mysql-server wordpress

hostname=$(curl -s
ln -s /usr/share/wordpress /var/www/wordpress
bash /usr/share/doc/wordpress/examples/setup-mysql -n wordpress localhost
ln -s config-localhost.php /etc/wordpress/config-$hostname.php
/etc/init.d/apache2 restart
echo Complete installation here: http://$hostname/wordpress

Go to the URL in the past step.

Create the account and note the password. Once in, you can change it.

Done! You are now running wordpress on your server.

Next thing to investigate is how to move the MySQL dB and also the themes, etc.

EC2 users (keypair)

Setting up EC2 the default login is root with a pub/priv key generated on the EC2 site as keypairs. I do not want to log in a root directly and disable this on the server. After a bit of searching I found this site that explained the process.


The problem with this method is there are a few errors and also once you do this you are screwed, because you cannot su to root!!!.

So new procedure is below

1) Change the root password!!!!

2) follow these steps

adduser des
(Need a password here)

ssh-keygen -b 1024 -f des -t dsa
(Need a passphrase here)

cd ~des
mkdir .ssh
chmod 700 .ssh
chown des:des .ssh

cp /root/des* .ssh/
chown  des:des .ssh/des
chown  des:des .ssh/des.pub
cat /root/des.pub > .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
chown des:des .ssh/authorized_keys

test if it works

ssh -i /home/des/.ssh/des -l des sfx.carrierfx.com

copy key to local machine. Easiest is to print it out and copy it to a text file on local machine as des.pem

cat .ssh

That’s it. Once this works fine, then change the

PermitRootLogin no

EC2 bundles

Finally figured out how to rebundle the image with the installed software. It is really easy.

Using the AWS tool:

Right click on EC2 Instances and select Bundle AMI.

Next you need to select a S3 bucket, and this is where the S3 firefox orginiser comes in. Download this plugin and create a bucket first. Do not try and be fancy with the name. Just name is with no underscores, since this is turned into a command line.

Use the bucket name and some name for the image name.

It will go off and create the AMI and your done. You can now load and associate the image as before, but if it fails you have the software installed and can be up and running again….

Simple as

EC2 eclipse plugin

Hit a bit of a snag with the AWS tool, specifically the eclipse tomcat server. It seems it only supports a subset of AMI’s and specifically only 32bit. They have opened a request to have more images and 64bit added. Might not be what I need after all, although it would have been great.

So, back to manuall deploying the server and setting it all up.