Deploy VoIP Services with Asterisk and FreePBX on Ubuntu 9.10 (Karmic)
Updated by Linode
This guide has been deprecated and is no longer being maintained.
Asterisk is an open source telephone solution that runs over the internet instead of running through copper lines like a normal phone would. It offers a variety of features such as voice mail and conference calling, much like a land line telephone can.
Before you begin, you need to make sure a few things are in order. We assume you have followed the getting started guide and have set the hostname, timezone, and configured networking. These last steps are of particular importance for ensuring your Asterisk installation functions normally. If you plan on using Asterisk’s email features, you may also wish to add an A record for your domain.
Please note: Because of the special configuration options required for this setup, you should not run other services on the Linode you intend to use Asterisk on. It is also worth noting that this guide will walk you through using pv_grub. Any alterations to the steps in this guide will fall outside the scope of support.
This guide is based largely on Ryan Tucker’s guide, with some modification to the procedures and software used.
There are quite a few prerequisites to satisfy before you can begin installing Asterisk and FreePBX. Most notably, you will need to install a kernel module and change your Linode’s configuration profile. We’re going to outline the instructions for doing so in this document, however you may wish to take a look at the in-depth information contained in the pv-grub guide.
Edit Sources List
You will need to enable the universe repositories in order to install Asterisk. To do so, edit
/etc/apt/sources.list so that it looks like the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
## main & restricted repositories deb http://us.archive.ubuntu.com/ubuntu/ karmic main restricted deb-src http://us.archive.ubuntu.com/ubuntu/ karmic main restricted deb http://security.ubuntu.com/ubuntu karmic-security main restricted deb-src http://security.ubuntu.com/ubuntu karmic-security main restricted ## universe repositories deb http://us.archive.ubuntu.com/ubuntu/ karmic universe deb-src http://us.archive.ubuntu.com/ubuntu/ karmic universe deb http://us.archive.ubuntu.com/ubuntu/ karmic-updates universe deb-src http://us.archive.ubuntu.com/ubuntu/ karmic-updates universe deb http://security.ubuntu.com/ubuntu karmic-security universe deb-src http://security.ubuntu.com/ubuntu karmic-security universe
Issue the following commands to update your package lists and upgrade packages on your Linode:
apt-get update apt-get upgrade
Create Asterisk User
We’re going to create a user to run Asterisk as so that we’re not running everything as root. Issue the following command:
You will be prompted for a password and some details for the user such as name and phone number. You need to fill out the password, but you may safely hit “Enter” for the other entries.
Configure the Kernel
You will need to use the “pv-grub” kernel provided by Linode. This method works, however any kernel problems that arise from editing the kernel beyond the steps outlined in this document will not be supported by Linode support. You’ll need to prepare your Linode before updating your configuration profile by following the commands below.
Asterisk uses the “dahdi_dummy” kernel module, which requires you to edit a few things in the kernel as well as your Linode’s configuration profile. You will need to use the EC2 image in order to use Asterisk without compiling your own kernel. This is a straightforward process; issue the following command:
apt-get install linux-image-ec2
Install and Configure Grub
GRUB is a bootloader that will allow you to boot the kernel we’re setting up. You will need to install and create a default configuration file for it. Issue the following commands:
apt-get install grub update-grub
You will receive a warning about the
/boot/grub/menu.lst file not existing and be asked if you would like to create one. Enter “y” to create a new file. You will now need to edit the
/boot/grub/menu.lst file, particularly the “groot” line. Please note: Directives in this file look like the are commented out. Leave the hash marks (“#”) as they are.
Change the groot line to resemble the following:
1 2 3
## default grub root device ## e.g. groot=(hd0,0) # groot=(hd0)
You will also want to change the indomU line to resemble the following:
You will now need to update grub again in order to apply the changes. Issue the following command:
Edit Configuration Profile
You will now need to log in to the Linode Manager in order to change your Linode’s configuration profile. To do so, navigate to the Dashboard page of the Linode you are going to use for Asterisk. Click the profile you are currently using and select “pv-grub-x86_32” (or “pv-grub-x86_64” if you are using a 64 bit system) from the kernel drop down. Save this configuration profile. You may wish to change the name of it to indicate that this is no longer a default profile.
Reboot your system to make sure that these changes are applied. You will need to do this before you can proceed. It is a good idea to watch the shutdown and reboot phases via Lish to see if there are any errors.
It’s very important that you follow the steps outlined above carefully or your system may not boot. It is highly recommended that you watch the console during the shutdown and reboot phases via Lish. If your Linode does not boot and you get an error, change your configuration profile back to the latest Paravirt kernel and read over this guide to make sure you have not missed any steps.
Install the Dahdi Module
You now need to install the Dahdi module to allow features like conference calling. Issue the following commands:
1 2 3 4 5
apt-get install build-essential module-assistant module-assistant -t update module-assistant -t prepare apt-get install gawk apt-get install dahdi dahdi-dkms dahdi-linux
You’re now ready to install Asterisk. There are a few packages related to Asterisk that you may not need, however we’ve included them below. Unless you know what you will need, it’s wise to install these packages.
Install Asterisk and some extra features with the following command:
apt-get install asterisk asterisk-config asterisk-doc asterisk-mp3 asterisk-mysql asterisk-sounds-main asterisk-sounds-extra
If you plan on having a US telephone number, enter “1” for the ITU-T telephone code. If you would like to use a number in another country, please select the corresponding code for your country.
By default, Asterisk includes voice prompts in English. However, support for other languages can be installed using the command(s) below:
1 2 3 4 5 6 7
apt-get install asterisk-prompt-de # German voice prompts for the Asterisk PBX apt-get install asterisk-prompt-es-co # Colombian Spanish voice prompts for Asterisk apt-get install asterisk-prompt-fr-armelle # French voice prompts for Asterisk by Armelle Desjardins apt-get install asterisk-prompt-fr-proformatique # French voice prompts for Asterisk apt-get install asterisk-prompt-fr # French voice prompts for Asterisk apt-get install asterisk-prompt-it # Italian voice prompts for the Asterisk PBX apt-get install asterisk-prompt-se # Swedish voice prompts for Asterisk
To start Asterisk, issue the following command:
Now check to see if asterisk is running by issuing:
You will be connected to the Command Line Interface (CLI) for Asterisk; you can disconnect from this process by typing
exit. If you would like to view available commands, type
At this time, you will want to reboot your Linode to see that everything functions normally. In particular, check that Asterisk has started by issuing the
asterisk -r command. You are encouraged to use the Linode Manager to reboot your Linode.
FreePBX is a PHP application that allows you to control your Asterisk installation through a web interface.
Set Up LAMP Stack
Before you can use FreePBX, you will need to set up a LAMP stack. An overview is provided here, but you may wish to consult our LAMP documentation for more information. To begin installing Apache, issue the following command:
apt-get install apache2
By default, Apache listens on all IP addresses available to it. We must configure it to listen only on addresses we specify.
Begin by modifying the
NameVirtualHost entry in
/etc/apache2/ports.conf as follows:
Be sure to replace “18.104.22.168” with your Linode’s public IP address.
Now, modify the default site’s virtual hosting in the file
/etc/apache2/sites-available/default so that the
<VirtualHost > entry reads:
You will now need to install MySQL. To begin the installation, issue the following command:
apt-get install mysql-server
After this completes, you will want to secure the default installation by issuing the following command:
You will need to create some databases, which we will use later on. Issue the following commands:
You will be asked for the password you created when you installed MySQL, then you will be taken to the MySQL command line interface. Be sure to change the password (“CHANGEME”) to something secure that you will remember.
1 2 3 4 5 6
create database asterisk; create database asteriskcdr; GRANT ALL PRIVILEGES ON asteriskcdr.* TO asterisk@localhost IDENTIFIED BY 'CHANGEME'; GRANT ALL PRIVILEGES ON asterisk.* TO asterisk@localhost IDENTIFIED BY 'CHANGEME'; flush privileges; exit
Next, you will need to install PHP. Issue the following commands:
apt-get install php5 php-pear php5-mysql php5-suhosin php5-cgi php-pear php-db
You will need to edit PHP’s configuration file in order to ensure FreePBX can function properly. In particular you need to ensure that the “memory_limit” directive is set to “100M” or else you may run into problems.
1 2 3 4 5 6 7
max_execution_time = 30 memory_limit = 100M error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR display_errors = Off log_errors = On error_log = /var/log/php.log register_globals = Off
FreePBX requires you to disable “magic quotes” in PHP. Find the following directives in your php.ini file and change them to reflect the example below:
magic_quotes_gpc = Off
For this installation, we want Apache to run as the Asterisk user. This will allow Apache to access all of the files it needs in order to run FreePBX. Make sure your
/etc/apache2/envvars file resembles the following:
export APACHE_RUN_USER=asterisk export APACHE_RUN_GROUP=asterisk
Finally, restart Apache to make sure everything is loaded correctly:
Download and Extract FreePBX
Obtain FreePBX and unpack it by issuing the following commands:
1 2 3 4 5 6
cd /opt wget http://mirror.freepbx.org/freepbx-2.6.0.tar.gz tar -xvf freepbx-2.6.0.tar.gz chown -R asterisk:asterisk freepbx* su - asterisk cd /opt/freepbx-2.6.0
The FreePBX directory contains SQL files that you can insert into the database that we created previously. Issue the following commands to insert this data:
1 2 3
mysql -p asterisk < SQL/newinstall.sql mysql -p asteriskcdr < SQL/cdr_mysql_table.sql exit
The FreePBX configuration process will ask you a series of questions that you will want to pay attention to. Some of the default values are fine for a production system, however you will want to change the passwords to prevent someone from accessing the system while you are setting it up.
You need to pass the credentials of the MySQL user and database you created above to the configuration script. Issue the following command, making sure to change the password (“CHANGEME”) to the password you created when you created the MySQL users and databases:
./install_amp --username=asterisk --password=CHANGEME
Before you continue your FreePBX installation, you will want to configure a
VirtualHost for the web interface. You will also want to secure your installation using SSL and .htaccess.
You will need to create a
VirtualHost for your FreePBX installation. By default, FreePBX installs files to
/var/www/html/; you may leave this as it is. Your
VirtualHost may resemble the following:
- VirtualHost Entry
1 2 3 4 5 6
<VirtualHost 22.214.171.124:80> ServerAdmin email@example.com ServerName pbx.e-cabi.net ServerAlias pbx.e-cabi.net DocumentRoot /var/www/html </VirtualHost>
To update your Apache configuration, you will need to restart the server. Issue the following command:
You will also need to edit your
nano /etc/rc.local file to enable some features of FreePBX on boot. You will need to add the “perl /var/www/html/panel/op_server.pl -d” line to this file. Please note: You need to add this line before any lines that way “exit”, as follows:
1 2 3 4
# [..] perl /var/www/html/panel/op_server.pl -d exit 0
You should now be able to visit your Linode’s IP address or the A record you have pointed at your Linode in your web browser. You will need to log in using the
asterisk username, and the password you selected for the FreePBX installation above. Once you have successfully logged in, you will be able to control your Asterisk installation through FreePBX!
You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.
This guide is published under a CC BY-ND 4.0 license.