Build a Drupal installation on Amazon EC2 - Enterprise Servers & Storage - Techguide

Build a Drupal installation on Amazon EC2

 

Summary

Nick Hardiman performs a Drupal install on his Amazon EC2 machine and provides a cheat sheet of the steps and commands that he used to do it.

Events

IBM Technology Conference & Expo 2012
May 22, 2012

One World Hotel, First Avenue, Bandar Utama City Centre, 47800 Petaling Jaya, Selangor

Echelon 2012
June 11 and 12, 2012

University Cultural Centre, National University of Singapore

Startup Asia Jakarta 2012
June 7 and 8, 2012

12th Floor, Annex Building, Wisma Nusantara Complex, Jl. M.H. Thamrin No. 59 Jakarta 10350, Indonesia

MMA Forum Singapore
April 23-25, 2012

Grand Hyatt Singapore

Here's a holiday recipe for infrastructure nerds like me: how to build a working Drupal install on an EC2 machine. I build Drupal on my Amazon Basic Linux micro-instance, and not the more popular Ubuntu-flavoured AMIs. I'll cut straight to the action here, then explain why I've done it this way in a later post.

Below are the couple dozen commands required to make Drupal go, in the form of a cheat sheet. I have included very few explanations of the commands, config or anything else to make it easy to learn. This is all CLI voodoo, only understood by Linux sysadmins and other computer nerds.

The three key ingredients are PHP, MySQL, and Drupal. It should not be followed by anyone unwilling to spend time researching what on earth is going on and to waste time troubleshooting. In fact, a web developer could spend his entire career getting to know these ingredients.

Time taken to complete is wildly variable. If everything goes smoothly, this process can take minutes. If something goes wrong there is no end to the time that can get sucked up in troubleshooting. There is a huge amount that can go wrong here. I have made one simple mistake and wasted days trying to find it. Computers are unforgiving.

Install PHP
The first thing to cook up is a PHP processor. Follow these four steps (I often use four steps to build an enterprise application).

  1. Install. The command is yum install php
  2. Configure. The most common change is tweaking the memory limit.
  3. Run. The web server needs a restart to pick up the new PHP processor module.
  4. Check. php -v
  5. The next thing to do is spice up PHP with a selection of optional extras:
    yum install php-mysql  php-xml  php-mcrypt  php-mbstring php-gd
    Each of these packages depends on other packages. Installing php-mysql also installs mysql-libs and php-pdo; php-xml depends on libxslt; and php-mcrypt needs libmcrypt and libtool-ltdl. The yum package install system takes care of working all this out automatically.
  6. I need a few tools to help me get even more PHP extras: PEAR (PHP Extension and Application Repository), PECL (PHP Extension Community Library) and files needed for building PHP extensions:
    yum install php-pear
    yum install php-devel
  7. Drupal can seem a little slow. I can speed it up with APC (Alternative PHP Cache):
    yum install php-pecl-apc

Install MySQL

  1. Install. yum install mysql-server
  2. Run. /etc/init.d/mysqld start
  3. Configure. mysqladmin -u root password 'Pa55word'
  4. Check. mysql -u root -p

Install a compiler
A compiler is used to build tools from source code. Not every optional extra is available as a binary installation package in Amazon's repository. Sometimes I need to compile code.

Security experts don't like the taste of a compiler on a production machine. They will not allow a compiler near the general public because of a history of abuse: in the right hands, it could give full system privileges.

yum install gcc

Install Drupal Copy

  1. wget http://ftp.drupal.org/files/projects/drupal-7.10.tar.gz
  2. gunzip drupal-7.10.tar.gz
  3. tar xf drupal-7.10.tar
  4. mv drupal-7.10/* /var/www/html/
  5. mv drupal-7.10/.*  /var/www/html/

Configure

  1. cd /var/www/html/sites/default/
  2. cp default.settings.php settings.php
  3. chmod 666 settings.php
  4. vi settings.php (this is where I tell Drupal where the database is)
  5. chmod 777 .

Clean up

  1. cd
  2. rm -rf drupal-7.10/
  3. gzip drupal-7.10.tar

Create a database and user

These are SQL commands, not shell commands.

  1. GRANT usage ON *.* TO drupal7user@localhost IDENTIFIED BY 'Pa55w0rd';
  2. CREATE DATABASE drupal7db;
  3. GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES, CREATE TEMPORARY TABLES ON `drupal7db`.* TO 'drupal7user'@'localhost' IDENTIFIED BY 'Pa55w0rd';

The final piece of command line work is a restart of the Apache HTTP Server.

  1. /etc/init.d/httpd stop
  2. /etc/init.d/httpd start

The next part involves configuring Drupal using a web browser.

The last part of the install process takes place in the new Drupal web site so it's time to stop using the command line and start using a web browser. The URL to use is along the lines of 'http://ec2-1-2-3-4.eu-west-1.compute.amazonaws.com/install.php". Typing this URL into a web  browser instructs the web server to run a script named "install.php". This script guides you through the final steps.

Note: This install URL is an example, not a real one. The DNS name for your EC2 machine will definitely not contain the text "1-2-3-4″, and it may not have "eu-west-1″ either. If you copy this example URL into a web browser, it will fail to find the web site and display an error along the lines of "can't find ec2-1-2-3-4.eu-west-1.compute.amazonaws.com".

Test Drupal
View the resulting example homepage at http://ec2-1-2-3-4.eu-west-1.compute.amazonaws.com/.

Cool and serve
I've built it. Now the editors need to add content and I need to maintain it.

System administration will be ongoing. For instance, my Drupal site does not have much memory to play with, so if the site gets popular, that will need to be managed. If customers perceive my site as slow, I can speed it up by adding a cache, optimising the database, and complaining to editors about their page sizes.

Nick Hardiman works as a hands-on techie in the UK.

Talkback

Add your opinion

In order to post a comment, you need to be registered. (Sign In or register below)

Post your comment

ZDNet Asia Live

Pakistan lifts block on Twitter - ZDNet Asia: Pakistan lifts block on TwitterZDNet Asia59 Jakarta 10350, Indones... http://t.co/61n85ajh

Pakistan lifts block on Twitter http://t.co/WHqoJOqm http://t.co/erFX4aVv #arcavir

http://t.co/VNaZtseV Pakistan lifts block on Twitter: Country restores access after briefly ... http://t.co/5gqegFWK http://t.co/wiqY9ktt

Pakistan lifts block on Twitter. http://t.co/y0arswpE

Mac users' indifference toward security 'worrying'. http://t.co/i7gZ8WVn

Mac users' indifference toward security 'worrying' - ZDNet Asia: Mac users' indifference toward security 'worryi... http://t.co/CD9pvW08

RT @zdnetasia: Mac users' indifference toward security 'worrying'. http://t.co/i7gZ8WVn

Mac users' indifference toward security 'worrying' - ZDNet Asia: USA TODAYMac users' indifference toward securit... http://t.co/4EUVidiO

Mac consumers indifferent about security, security vendors warn such mindset is "worrying" http://t.co/ZGIxdg67 #In

Mac users take note! RT @zdnetasia: Mac users' indifference toward security 'worrying'. http://t.co/YrLB9btb #mac #apple

RT @zdnetasia: Mac users' indifference toward security 'worrying'. http://t.co/i7gZ8WVn

Mac users' indifference toward security 'worrying': However, Mac users ZDNet Asia spoke to expressed indifferenc... http://t.co/15DulmWS

RT @jolintan: Mac users take note! RT @zdnetasia: Mac users' indifference toward security 'worrying'. http://t.co/2RQkfCKt #mac #apple

APAC tech merger and acquisition in Q1 down but value up: http://t.co/V7UkMABl

Mac users' indifference toward security 'worrying' - ZDNet Asia: Mac users' indifference toward security 'worryi... http://t.co/PINqvJxT

I reckon your view: "CRM is strategy, not software", if a company replicating the approach uses in ERP implementation into CRM, what they...

2 hours ago by wykoong on Gartner: Mobile CRM gives better ROI than social

This video will teach you about the Excel fill handle but also provide you with a workook to download... http://www.youtube.com/watch?v=...

19 hours ago by TradeBrother on A quick fill handle trick for Microsoft Excel

waiting...

2 days ago by eapete on What should count in a company's market value?

Boy, you've opened a can of worms now.

Wait for the rants & raves.

2 days ago by eapete on What should count in a company's market value?

I was puzzling before this whether to replicate the success formula we executed for a financial institute, and come out with a standard s...

3 days ago by wykoong on Drop the egos, copy ideas, then innovate