After looking around for a while, I noticed something – there’s some documentation out there, but not a lot, on how to do a fresh install / setup of the latest version of Asterisk (1.6.2) on the latest version of CentOS (5.5). So I thought I’d go ahead and go through the process myself and then post the steps I used. So let’s get started…

First things first, the server. I ordered a new dedicated server from my webhost that was running the latest 32-bit version of CentOS 5.4. I had nothing else installed on it, this was just a base vanilla server install. The first thing I did once I had access to the server was to install the latest versions of all installed software:

# yum update

A lot of guides out there use the -y switch with yum to auto-install whatever is found to be updated. You can do this if you like, however, I personally prefer to have to manually select Yes before I do the updates. That all comes down to personal preference.

Next, we need to install all of Asterisk’s dependencies. These are programs that are required to be installed before you can compile asterisk. This is the list I use, it includes the source compilers, some needed development libraries, as well as some dependencies for various asterisk modules I like to load.

# yum install gcc gcc-c++ make openssl-devel newt-devel ncurses-devel libtermcap-devel libxml2-devel kernel-devel perl curl curl-devel

Also, if you have a PAE-based kernel (like I do), which is becoming more and more common these days, you’ll need to load the PAE kernel headers:

# yum install kernel-PAE-devel

If you’re not sure if you have a PAE kernel, you can check using the “uname -r” command:

# uname -r
2.6.18-164.10.1.el5PAE

Next, we’ll install a MySQL database server to handle our CDR (call detail records) storage, and also to prepare the way for using the Asterisk Realtime Architecture (the ability to store our configuration parameters in a database as opposed to flat files). You can safely skip this step if you feel you’ll never make that transition, but it doesn’t hurt anything to go ahead and get this setup now as opposed to later.

# yum install libtool-ltdl libtool-ltdl-devel unixODBC-devel mysql mysql-devel mysql-server mysql-connector-odbc

Now, we’ve got all of the dependencies installed. It’s time to go ahead and get into the meat of the install. We’ll start by creating a new directory under /usr/src to keep everything nice and tidy. Then we’ll download all of the sources we’re going to need for this install.

# cd /usr/src
# mkdir asterisk
# cd asterisk
# wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-1.6.2.0.tar.gz
# wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-addons-1.6.2.0.tar.gz
# wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
# wget http://downloads.digium.com/pub/libpri/libpri-1.4-current.tar.gz
# tar zxvf asterisk-1.6.2.0.tar.gz
# tar zxvf asterisk-addons-1.6.2.0.tar.gz
# tar zxvf dahdi-linux-complete-current.tar.gz
# tar zxvf libpri-1.4-current.tar.gz

First, we’ll install LibPRI. LibPRI is a library used by TDM cards (T1 / E1 cards, etc). Even if you don’t have one of these cards, it’s safe to install LibPRI – it won’t have any negative effects on your system.

# cd /usr/src/asterisk/libpri-1.4.10.2
# make clean
# make
# make install

Next, we’ll install DAHDI. DAHDI means “Digium Asterisk Hardware Device Interface”, it’s pronounced “Daddy”, and it’s the replacement of the old Zaptel driver stack. DAHDI is the set of linux kernel modules and also a set of tools for interfacing with TDM cards. More importantly, DAHDI provides timing to several asterisk components, such as the MeetMe application as well as Music on Hold. If you don’t have a proper timing source installed, you’ll notice lots of stuttering pauses in any kind of audio playback (Music on Hold, IVR prompts, voicemail greetings) from asterisk. If you don’t have any TDM hardware installed in your server, DAHDI also provides a “dummy” driver that will provide a timing source to asterisk.

Now, starting with Asterisk 1.6.1, Digium introduced new internal timing options that can be used in place of the DAHDI timer, however, these are only available on systems running the latest kernels (2.6.25+) in the case of res_timing_timerfd, or on lightly loaded systems, as is the case with res_timing_pthread. If you would rather use one of these options instead of the DAHDI dummy driver, you may skip this step – just be sure to select one of the above mentioned res_timing resouces when you build asterisk later. IMPORTANT NOTE – if you do have a TDM card installed in your system, you may not skip this step!

# cd /usr/src/asterisk/dahdi-linux-complete-2.2.1-rc2+2.2.1-rc2/
# make all
# make install
# make config

Now that you’ve installed DAHDI, you need to configure it. You do that by editing the following files, based on your situation. The files themselves contain lots of documentation, so I won’t go over that in much detail here, except to say this – if you have no TDM cards and are only installing DAHDI for the dummy timing source, you can comment out every driver referenced in the modules file. I prefer to use vi, you can use whichever editor is your favorite. If you’re new to linux, I would suggest using nano with the -w switch.

# vi /etc/dahdi/modules
# vi /etc/dahdi/system.conf

Now that we’ve got DAHDI configured the way we need for our system, we need to set it to start at boot time, and then we need to start it.

# chkconfig dahdi on
# service dahdi start

Next, let’s setup our MySQL database for CDR storage. I’ll make another post detailing the settings needed for Asterisk Realtime later. Be sure to run the mysql_secure_installation script after you start MySQL in order to set up a root password to protect your SQL databases!

# chkconfig mysqld on
# service mysqld start
# /usr/bin/mysql_secure_installation
# mysql -p

SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
CREATE DATABASE `asterisk` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `asterisk`;
CREATE TABLE IF NOT EXISTS `cdr` (
`recid` mediumint(8) unsigned NOT NULL auto_increment COMMENT 'Record ID',
`calldate` datetime NOT NULL default '0000-00-00 00:00:00',
`clid` varchar(80) NOT NULL default '',
`src` varchar(80) NOT NULL default '',
`dst` varchar(80) NOT NULL default '',
`dcontext` varchar(80) NOT NULL default '',
`channel` varchar(80) NOT NULL default '',
`dstchannel` varchar(80) NOT NULL default '',
`lastapp` varchar(80) NOT NULL default '',
`lastdata` varchar(80) NOT NULL default '',
`duration` int(11) NOT NULL default '0',
`billsec` int(11) NOT NULL default '0',
`disposition` varchar(45) NOT NULL default '',
`amaflags` int(11) NOT NULL default '0',
`accountcode` varchar(20) NOT NULL default '',
`uniqueid` varchar(32) NOT NULL default '',
`userfield` varchar(255) NOT NULL default '',
PRIMARY KEY (`recid`),
KEY `calldate` (`calldate`),
KEY `dst` (`dst`),
KEY `accountcode` (`accountcode`),
KEY `src` (`src`),
KEY `disposition` (`disposition`),
KEY `uniqueid` (`uniqueid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
CREATE USER 'asterisk'@'localhost' IDENTIFIED BY 'PASSWORD';
GRANT FILE ON * . * TO 'asterisk'@'localhost' IDENTIFIED BY 'PASSWORD' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ;
GRANT INSERT ON `asterisk`.`cdr` TO 'asterisk'@'localhost';

Be sure to set your own password for the asterisk user (where I used ‘PASSWORD’ in the above block).

Now, we’ve got all the prerequisites installed. Let’s install Asterisk!

# cd /usr/src/asterisk/asterisk-1.6.2.0/
# make clean
# ./configure
# make menuselect

This is where you select all of the modules, applications, resource modules, codecs, sound pacakges, etc, that you want installed with Asterisk. Take a little time to go through the new menu system (much improved over the 1.4 branch) and select the options you want. Move through menus using the up and down arrow keys, go to the options pane using tab, move up and down through the options and select items using the enter key, and then when you’re ready to save your selections, tab to the “Save and Exit” button and press enter again. It’s really that simple! After you’ve finished with your selections, move on to the next step:

# make
# make install
# make samples
# make config
# chkconfig asterisk on

Next, we need to verify that asterisk installed correctly. We do this by manually starting asterisk from the command line. If everything starts up and there’s not too many errors or warrnings, we’re good to go:

# asterisk -vvvvc
*CLI> core stop now

Next, we need to install some of the options from the Asterisk-Addons download. Asterisk-addons contains additional applications, channel drivers, and resource modules that are useful for asterisk but not necessary. We’re going to install the mysql cdr addons for asterisk.

# cd /usr/src/asterisk/asterisk-addons-1.6.2.0
# make clean
# ./configure
# make menuselect

At this point, be sure to select at least the following items:

  • Applications – app_addon_sql_mysql
  • Call Detail Recording – cdr_addon_mysql
  • Resource Modules – res_config_mysql

After you’ve got those selected, save and exit. Then proceed with the following steps:

# make
# make install
# make samples

Once we’ve got that done, we need to edit the cdr_mysql.conf file to enter the mysql username and password, database, and table we setup earlier. What’s listed below should be all we need in this file, if there’s anything else in there, either comment it out or delete it.

# vi /etc/asterisk/cdr_mysql.conf
[global]
hostname=localhost
dbname=asterisk
table=cdr
password=PASSWORD
user=asterisk
port=3306
sock=/var/lib/mysql/mysql.sock
userfield=1
loguniqueid=yes

And that’s it! You should read through several of the key configuration files in order to learn what’s changed, and also how to customize Asterisk for your installation. The files to look into would be:

/etc/asterisk/asterisk.conf
/etc/asterisk/extensions.ael
/etc/asterisk/extensions.conf
/etc/asterisk/sip.conf
/etc/asterisk/iax.conf
/etc/asterisk/voicemail.conf
/etc/asterisk/users.conf

If you have any questions or run into any trouble, please feel free to leave a comment and I’ll help out where I can.