Installing Drupal on AWS

NOTE: The really easy way to create Drupal instances on AWS would be to use an Amazon Cloud Formation template (e.g. one that uses a local MySQL instance or Amazon RDS, or a high-availability version that uses Amazon RDS + S3). Alternatively, you can use a BitNami AMI.

But if you really want to do it manually, here’s a brief tutorial on installing Drupal on AWS.

Deploying your server at Amazon and connecting to it

  1. Sign up for Amazon Web Services.
  2. Go to the EC2 console page.
  3. On the left navbar, select an appropriate region, such as US-East.
  4. On the left navbar, click “Security Groups.”
    1. Click the button to “Create Security Group.”
    2. Name your security group something like “webservers.”
    3. Describe your security group as “HTTP + SSH.”
    4. Make sure “No VPC” is selected.
    5. Click to create the security group.
  5. On the security groups screen, select your new security group.  A panel should appear at the bottom of the page.
    1. Click the “Inbound” tab.
    2. Select SSH and click “Add Rule,” and then do the same for HTTP.
    3. Click the “Apply Rule Changes” button.
  6. On the left navbar, select EC2 dashboard.
  7. Click the large “Launch Instance” button.  That starts the Quick Launch Wizard.
    1. Name your instance–perhaps something like “Drupal 1.”
    2. For your key pair, select “Create New” and name it–perhaps something like “AMI Key Pair 1.”
    3. Beside the key pair input area, click the “Download” button and save your key pair to somewhere you’ll remember it, such as your Documents folder.  You will need to know the complete directory path to the file in text form, not just how to find it by clicking.
    4. Select the default 64-bit Amazon Linux AMI (EBS-backed for persistent storage).
    5. Click “Continue,” and on the next screen, click “Edit Details.”
    6. Note that t1.micro, the free option, is selected for the machine size.  A small instance is probably the minimum for Drupal, and you may need a larger instance: both have some cost.
    7. Open the “Security Settings” sub-panel, and select the security group you created earlier.
    8. Click “Save Details,” and on the next screen, “Launch.”
  8. On the left navbar, select “Instances.”
  9. Click the checkbox on the far left of your new instance.
  10. On the “Instance Actions” drop-down list, select “Connect.”
    1. Click “Connect from your browser using the Java SSH Client.”
    2. Type in the path to the key you created, above.
    3. Click “Launch SSH Client.”
    4. You probably need to grant the application permission to run in your browser, and you may need to ensure your Java installation is working and try again.
    5. The SSH client will ask about several things–just click “Yes.”

Configuring your web server and installing Drupal

  1. sudo yum update
  2. sudo yum install -y httpd perl gd php php-pear mysql mysql-server php-common php-dba php-pdo php-mysql php-xml php-xmlrpc php-gd
  3. sudo chkconfig –level 2345 httpd on
  4. sudo chkconfig –level 2345 mysqld on
  5. Get a little better MySQL config by following these instructions.  For production servers, you will probably want to configure either additional or larger EBS volumes and set up snapshots by following these instructions.
  6. sudo /etc/init.d/mysqld start
  7. sudo /etc/init.d/httpd start
  8. mysql -u root mysql
    1. (On production servers, follow these instructions to set up new passwords for mysql’s root account.)
    2. create database drupal;
    3. grant all privileges on drupal.* to ‘drupal’@’localhost’;
    4. set password for ‘drupal’@’localhost’ = password(‘dfsdfsdfsdfsfetc.etc.’);
    5. flush privileges;
  9. sudo useradd drupal
  10. sudo chown drupal /var/www/html
  11. sudo su drupal
  12. pear config-create $HOME $HOME/.pearrc
  13. pear channel-discover pear.drush.org
  14. pear install drush/drush
  15. In /home/drupal/.bash_profile, add ‘PATH=”/home/drupal/pear/:$PATH”‘ and ‘export PATH’; then source /home/drupal/.bash_profile
  16. cd /var/www/html
  17. curl http://ftp.drupal.org/files/projects/drupal-7.12.tar.gz > drupal-7.12.tar.gz
  18. gunzip drupal-7.12.tar.gz
  19. tar -xvf drupal-7.12.tar
  20. mv drupal-7.12 demo
  21. rm drupal-7.12.tar
  22. Leave your command prompt open and ready.

Working with your new Drupal site

  1. Go back to the EC2 admin console and find the “Public DNS” setting for your Drupal instance (for production, allocate an Elastic IP and use your DNS provider to point an A record at that).
  2. Copy/paste that setting as a URL (http://) plus /demo on the end, e.g. http://ec2-50-16-169-128.compute-1.amazonaws.com/demo