We recently received an enquiry asking us if we could help install Elastix onto an Amazon EC2 instance. It’s been a couple of years since I last installed Asterisk onto EC2, so I couldn’t help but give Elastix a try.
As usual, the first port of call is Google - a couple of relevant posts stand out:
ddto copy the image onto a mounted EBS device - followed by a number of steps to create an AMI.
The first method looked a bit laborious, so I decided to see if i could use the second method to get Elastix up and running on EC2 - limited credit to me here, for the most part I am following through the steps from the second blog linked to above, with slight tweaks. Also note I am running commands as root - so prefix with sudo where relevant for your usage.
Elastix 2.4 stable uses CentOS 5.9 - so find a Centos 5.9 based AMI (I used ami-a91e5dc0 which is a RightScale image - these are normally solid AMIs) - spin up an EC2 instance - the AMI I’m using is 64-bit so i started up a c3.large.
Sidenote: The last time I installed Asterisk on EC2 I ran into an issue with the kernel timing - by default it was set to 100Hz, giving poor quality, 1000Hz is better. The way to check is to run the following:
cat /boot/config-`uname -r` | grep HZ
I think the issue was prevalent on Ubuntu images, I’m not sure if CentOS was affected, but on checking the CentOS image I am using here it appears fine (i.e. it’s using 1000Hz).2. SSH into your new instance.
SSH into your new instance.
Fetch the EPEL repository definitions from the Fedora Project > Sidenote: the RightScale image I am using included some EPEL settings so I disabled them in favour of using the direct EPEL release - edit the file
/etc/yum.repos.d/CentOS-Base.repo - find the [epel] section and change enabled to 0 and then find [rightscale-epel] and again set enabled to 0. Clear the yum cache with
yum clean all
rpm -ivh http://www.mirrorservice.org/sites/dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
Update the box
yum -y update
Pull down the ISO image of Elastix - I’m using the latest stable 2.4 release and I’m using a 64-bit instance - (you can find the URL to download the ISO from the Elastix download page)
Mount the ISO locally
mkdir /mnt/iso mount -o loop Elastix-2.4.0-Stable-x86_64-bin-04feb2013.iso /mnt/iso cd /mnt/iso
Create a Yum repository file for the mounted ISO - gist here - and place into
wget https://gist.github.com/chrisanderton/8086953/raw/dacd4440e110ec0dab6ad65495f0fb9a5ee302e1/elastix-cd.repo -O /etc/yum.repos.d/elastix-cd.repo
yum -y install elastix
elastix-cd.repo file you created earlier and set enabled to equal 0 (to disable it, as it won’t be mounted when you reboot) - clear the yum cache with
yum clean all
service mysqld start
Run the Elastix startup script to setup your MySQL and Admin password
Reboot your instance
SSH back in to the machine and update the system (you could probably do this before rebooting - or you could probably initiate this through the web interface)
yum -y update
Reboot your instance (I’m not convinced this is necessary, the only time you should need to reboot is for kernel changes, but I’m not familiar enough with Elastix so am doing a reboot to be safe)
Make sure you have HTTP and HTTPS enabled in your Security Group and access your instance in a web browser.
Assuming you’ve followed everything above, and assuming it’s all worked, you should now be able to login to the admin interface using the username ‘admin’ and the password you chose above. Beyond this, all that should be left is to setup necessary port access in your security group - I’m also not sure if there is any benefit to using an Elastic IP. Enjoy!