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 extension=apc.so > /etc/php.d/apc.ini

Install memcached

  • yum install libevent libevent-devel
  • curl -O http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz
  • cd memcached-1.4.5
  • ./configure
  • make ; make install
  • /usr/local/bin/memcached -u nobody -d -m 30 -l 127.0.0.1 -p 11211

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>
   ServerAdmin support@domain.net
   ServerName domain.net
   ServerAlias domain.net&nbsp;*.domain.net
   DocumentRoot /var/www/
   ErrorLog logs/domain-error_log
   CustomLog logs/domain-access_log common
</VirtualHost>

Change the httpd conf to AllowOverride All

2 thoughts on “Configuring Amazon Linux For Web Services

  1. I just did this to move my blog over to an Amazon EC2 instance. (I could have used your cookbook about five days ago.) One thing to add to your cookbook is to change the MaxClients parameter in the httpd config file. The httpd package supplied in the repo precompiles the prefork MPM, and 256 clients is too large for a mere 613MB of RAM.

Comments are closed.