Some time ago, I wrote a short blog post explaining how to go about installing XCache on an Amazon EC2 instance to help with opcode caching.
More recently, we’ve begun using APC for similar reasons, with excellent results, including on Amazon EC2 Micro instances, which can be used under their free usage tier to run things like (for example) WordPress blogs, at rather high usage, when cached correctly! This conversation is for another time, though, so for now I’ll get on with explaining how you’ll want to go about installing and setting up APC.
Note that APC requires some additional configuration to get it “just so” which I shall not be going into. This is just a nuts and bolts tutorial for installing and getting it running!
First step, setting an Amazon EC2 instance on 64 bit Linux. We use the Amazon linux (which is, I believe, a mostly CentOS flavour), for which these instructions will work…
I am assuming you are starting from scratch. If not, you may like to skip the first few steps, which involve installing obvious dependencies!
Step 1 – Install Updates, GCC & Make
yum -y update
yum install -y gcc make
Install PHP & PHP Extensions
yum install -y php
yum install -y php-devel php-mysql php-pdo
yum install -y php-pear php-mbstring
pear install Log
yum install -y pcre-devel
Install PHP APC Module
yum -y install httpd-devel
pecl install apc-beta
echo "extension=apc.so" | sudo tee /etc/php.d/apc.ini
Note that this will install the latest beta version of APC on your setup. If you’d like a stable version of APC, please use “pecl install apc” instead of “pecl install apc-beta”.
The above should be enough to get APC installed and working. You’ll also likely need to install and configure MySQL, Apache and setup your PHP settings for optimal performance, but that, again, is for another time.
Leave a comment below if this has (or hasn’t) helped you to get APC installed.