Configuring Amazon Linux For Web Services

UPDATED: an updated installation cookbook is available.

Amazon has introduced their own distribution of linux with tweaks to optimize it for their Elastic Compute Cloud platform. Like CentOS, it appears to be based on Red Hat Enterprise Linux, though unlike the current versions of RHEL and CentOS, the packaged applications are up to date with current expectations. That’s refreshing news for those comfortable with RHEL, but uncomfortable its ancient packages. MySQL 5.0 was released in 2003 and 5.1 two years ago, after all, and PHP 5.1.6 feels positively ancient now that 5.3 is common.

Getting a new virtual machine up and running from the default AMI is easy.  Here’s my cookbook:

Install basic services

  • yum install mysql mysql-server mysql-devel
  • yum install httpd httpd-devel
  • yum install php php-devel php-mysql php-gd php-dom php-pear php-json
  • yum install svn

Configure those services to start at boot

  • chkconfig –level 345 httpd on
  • chkconfig –level 345 mysqld on
  • chkconfig –list

Install APC

I couldn’t find a package, and this bug report explains why we have to use the beta.

  • yum install gcc pcre-devel
  • pecl install apc-beta
  • echo > /etc/php.d/apc.ini

Install memcached

Create a database and user for it

  • CREATE DATABASE db_name CHARACTER SET utf8 COLLATE utf8_general_ci;
  • CREATE USER ‘user_name’@’localhost’ IDENTIFIED BY ‘user_name’;
  • GRANT ALL ON db_name.* TO ‘user_name’@’localhost’;

Create a virtualhost file

<VirtualHost *:80>
   ServerAlias *
   DocumentRoot /var/www/
   ErrorLog logs/domain-error_log
   CustomLog logs/domain-access_log common

Change the httpd conf to AllowOverride All