Installing Acquia Commons on an Amazon Web Services EC2 instance

Preparation

Main site: http://aws.amazon.com/

Console overview, tour, all categories of info: http://aws.amazon.com/console/

For example, Amazon EC2 Features at http://aws.amazon.com/console/#ec2

I watched the EC2 tutorial at http://d36cz9buwru1tt.cloudfront.net/console/AwsConsole.html

AWS Documentation: http://aws.amazon.com/documentation/

EC2 Documentation (Getting started (recommended), user's guide, etc.): http://aws.amazon.com/documentation/ec2/

Signing up

Go to http://aws.amazon.com/ and click on the button which says Sign up for a free Amazon Web Services Account – Sign Up Now.

You can use your existing Amazon customer account email and password if you already have one.

Preparation

Main site: http://aws.amazon.com/

Console overview, tour, all categories of info: http://aws.amazon.com/console/

For example, Amazon EC2 Features at http://aws.amazon.com/console/#ec2

I watched the EC2 tutorial at http://d36cz9buwru1tt.cloudfront.net/console/AwsConsole.html

AWS Documentation: http://aws.amazon.com/documentation/

EC2 Documentation (Getting started (recommended), user’s guide, etc.): http://aws.amazon.com/documentation/ec2/

Signing up

Go to http://aws.amazon.com/ and click on the button which says Sign up for a free Amazon Web Services Account – Sign Up Now.

You can use your existing Amazon customer account email and password if you already have one.

Some folks get approved immediately, some in “hours”, some the next day. If you hadn’t previously signed up, upon attempting to sign into a console you will be asked to do so.

Getting started

(It’s a great idea to consult Amazon’s Getting Started Guide: http://docs.amazonwebservices.com/AWSEC2/latest/GettingStartedGuide/ )

Click on Sign in to the AWS Management Console link above page header or the button at the top right hand block on the page.

I used the block on the right hand side of the page, and selected the Amazon EC2 console as my default, and hit the sign in button, filled in my user email and password, and was taken along to the Amazon EC2 Console Dashboard.

Launching an instance

Once in, I clicked on Key Pairs in the left-hand side Navigation column (needed to launch an instance), and then on Create Key Pair. I specified a name, and the private key, {Name}.pem, downloaded instantly. I followed the instructions to save it to a safe location.

I then elected to create a Security Group (so named because they contain a group of rules concerning the opening and closing of ports) in advance of launching my instance, so that it would be all ready. This actually is crucial, since the default group offered if you go right into the Launch Classic Wizard does not open ports 80 (for the web server) or 22 (for a command line ssh connection). I clicked on Security Groups and hit the Create Security Group button. I entered a name and description, left No VPC selected (see http://aws.amazon.com/vpc/faqs/#G1 for more Amazon Virtual Private Cloud info) and hit the Yes, Create button. I then selected the group I had just selected, and in the lower section where the group details appeared, I clicked on the Inbound tab. For the ssh rule, I selected SSH from the weird non-alphabetized drop down list, left the source open at 0.0.0.0/0 (optionally fill in an IP range) and clicked on the Add rule button, which added a rule opening the default port for SSH, 22. Of course, you could leave a different port open with a Custom TCP rule. Secondly, I chose HTTP from the list, and added a rule opening port 80. Things looked good, so I hit the Apply Rule Changes button.

Now I was ready to click on the EC2 Dashboard link at the top of the left-hand side Navigation column. I clicked on Launch Instance. I then had the option of using the classic wizard, or choose from the quick launch options.

The key pair I had created earlier was pre-selected for me.

I was in Quicklaunch mode. On the left hand side of the pop-up I selected the Launch Classic Wizard option (preferring to use an AMI (Amazon Machine Instance) rather than the “Launch Configuration” choices offered. I selected the Launch Classic Wizard option and hit Continue..

I clicked on the Community AMIs tab (which took quite a few seconds to load) and put Ubuntu 8 into the filter search box (I want to go with Ubuntu 8.04 LTS, Hardy, supported until well into 2013, since it sports Php 5.2.x out of the box, ideal for Drupal 6 and Commons). So I chose ami-0f54b966 (063491364108/ubuntu-8.04.3-hardy-server-i386-20091130), going with the 32 bit version for now (this was on the top of the unordered list, so I just selected it, although further down there was a newer version I might try the next time).

I clicked on the Select button on the right hand side of the row. On the second, instance details page, I left the defaults (1 instance of type micro, to be launched into EC2 with no preference for availability zone) and clicked Continue. I left the Advanced Instance Options at their default values and clicked Continue again. I left the the proposed Key “Name” and entered the Value “Drupal Commons 2.3”.

I left my recently created public/private key pair selected and clicked Continue (if you haven’t created one up till now, you can do so here).

On the Configure Firewall page I selected my dev security group and clicked Continue.

I reviewed my details and hit Launch and then Close.

Accessing our instance from the command line

To view our newly created instance, I selected Instances from the left-hand side Navigation menu, and it appeared as a single line. The green “running” state showed the instance had been launched successfully. I clicked on the name field and a table of information appeared below it. I carefully copied the url listed for the instance from the Public DNS row.

To connect, right click on the name field, and click on Connect. A usable command line is shown as an example. I clicked Close and opened a terminal to the directory where I had safely stored my private key. I did the following (reference: http://docs.amazonwebservices.com/AWSEC2/latest/GettingStartedGuide/ and hit Connect to Linux/UNIX instance):

$ chmod 400 GSG_Keypair.pem
$ ssh -i GSG_Keypair.pem ubuntu@ec2-184-72-204-112.compute-1.amazonaws.com

The latter command is based on the domain noted down from the Public DNS info, and invokes the private key file stored on your dev box file system.

After accepting the new host, I was in.

Setting up the LAMP stack

I simply ate my own dog food from my own blog, and that worked out fine for the most part: https://awebfactory.com/node/444 . Here’s exactly what I did (/etc/apt/sources.list was already fine, and I accepted default suggestions in all cases, including providing a root password for MySql):

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo rm -f /bin/sh
$ sudo ln -s /bin/bash /bin/sh
$ sudo apt-get install postfix
$ sudo apt-get install mysql-server mysql-client libmysqlclient15-dev
$ sudo apt-get install imagemagick
$ sudo apt-get install libapache2-mod-php5 php5 php5-common php5-curl php5-dev php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-mysql php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
$ sudo grep memory_limit /etc/php5/apache2/php.ini
memory_limit = 128M      ; Maximum amount of memory a script may consume (16MB)
$ sudo grep memory_limit /etc/php5/cli/php.ini
memory_limit = 128M      ; Maximum amount of memory a script may consume (32MB)
$ sudo head -24 /etc/apache2/sites-enabled/000-default
NameVirtualHost *
<VirtualHost *>
	ServerAdmin webmaster@localhost
	
	DocumentRoot /var/www/
	<Directory />
		Options FollowSymLinks
		AllowOverride None
	</Directory>
	<Directory /var/www/>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride All
		Order allow,deny
		allow from all
	</Directory>

	ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
	<Directory "/usr/lib/cgi-bin">
		AllowOverride None
		Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
		Order allow,deny
		Allow from all
	</Directory>
$ sudo cat /var/www/info.php
<?php phpinfo(); ?>
$ sudo a2enmod rewrite
Module rewrite installed; run /etc/init.d/apache2 force-reload to enable.
$ sudo /etc/init.d/apache2 restart

At this point http://ec2-50-17-169-206.compute-1.amazonaws.com/info.php shows php and mysql installed, and that we have a 5.2.x php LAMP server stack set up.

Setting up Acquia Commons

Downloading and installing Drupal Commons:

$ sudo apt-get install phpmyadmin

Now use phpmyadmin at http://myserver/phpmyadmin to create a database and user for Acquia Commons

Then create download directory for user mycommons, download Acquia Commons and untar it.

$ cd
$ pwd
/home/ubuntu
$ mkdir download 
$ cd download
$ wget http://network.acquia.com/files/marketing/commons/commons-6.x-2.3.tar.gz 
$ cd /var
$ sudo mv www www-ori
$ sudo tar xvzf ~/download/commons-6.x-2.3.tar.gz
$ sudo ln -s commons-6.x-2.3/ www
$ cd www/sites/default/
$ sudo cp default.settings.php settings.php 
$ sudo chmod 666 settings.php
$ sudo chown -R www-data files

Run install script as usual!

Check it out at http://myserver

That’s it, you have Acquia Commons running on your own cloud!

Create a private AMI as a “backup”

Right click on the Name field of the instance in Instances and click on Create Image (EBS AMI).

In the Create Image dialog, enter an Image Name and Image Description.

Amazon informs in the dialog:

The instance you're using as a template for a new image has the following volumes:
/dev/sda1, vol-xxxxxxx (15 GiB), will delete on termination
Total size of EBS volumes: 15 GiB.
When you create an EBS image an EBS snapshot will also be created for each of the above volumes.

Click on Create this Image.

Amazon informs:

 Create Image request received.
View pending image: ami-xxxxxxxxx.
Any snapshots backing your new EBS image can be managed on the snapshots screen after successful image creation.

Road Map

  • Follow the steps outlined here (based on a referenced Amazon article at ) to store the database as a persistent storage volume

  • Clean up and create public AMI

  • See if the whole process wouldn’t be easier just setting it up on Pantheon 🙂 at a fraction of the cost even at the one hundred bucks a plunk rate; or, alternatively, on Acquia’s own Developer Cloud Hosting.

Main helpful Articles

AWS Documentation: http://aws.amazon.com/documentation/

EC2 Documentation (Getting started (recommended), user’s guide, etc.): http://aws.amazon.com/documentation/ec2/

Most down to earth, except don’t use ubuntu drupal6 package or install LAMP via tasksel install lamp-server:

http://10jumps.com/blog/setup-your-own-drupal-amazon-ec2

EBS usage explained here

http://aws.amazon.com/ebs/

… and here …

http://aws.amazon.com/articles/1663?_encoding=UTF8&jiveRedirect=1

Firefox plugin

http://aws.amazon.com/developertools/609?_encoding=UTF8&jiveRedirect=1

Command line API tool

http://aws.amazon.com/developertools/351?_encoding=UTF8&jiveRedirect=1

http://docs.amazonwebservices.com/AWSEC2/latest/UserGuide/index.html?SettingUp_CommandLine.html

Persistent storage volume for database:

http://10jumps.com/blog/setup-your-own-drupal-amazon-ec2

http://www.sunsetlakesoftware.com/2008/09/13/running-drupal-website-amazon-ec2