How to setup Asterisk 1.6.2 on Centos 5.4

Posted by Warren Selby on Jan 20, 2010 in asterisk, Blog, linux | 75 comments

UPDATE 05/20/2011 – An updated version of this post, detailing How to setup Asterisk 1.8, has been posted. Check it out if you want to move to the latest and greatest version of asterisk. If you’d prefer to stay with version 1.6.2, please, read on!

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.4). 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.

75 Responses to “How to setup Asterisk 1.6.2 on Centos 5.4”

  1. dunghoang says:

    hi, I fined with erorr: “You do not appear to have the sources for the 2.6.18-194.el5 kernel installed.”
    When install package Asterisk
    ># make clean ->0k
    >#./configure ->ok
    >#make menuselect -> choose all
    >#make
    -> erorr: /usr/src/asterisk/asterisk-1.6.2.10/include/asterisk/lock.h:1173: undefined reference to `ast_bt_get_addresses’
    collect2: ld returned 1 exit status
    make[1]: *** [aelparse] Error 1
    make: *** [utils] Error 2

    Please hepl me!

  2. dunghoang says:

    [root@asteris_test asterisk-1.6.2.10]# gcc –version
    gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-48)
    Copyright (C) 2006 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions. There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

  3. dunghoang says:

    [root@localhost asterisk]# make
    CC=”cc” CXX=”" LD=”" AR=”" RANLIB=”" CFLAGS=”" make -C menuselect CONFIGURE_SILENT=”–silent” makeopts
    make[1]: Entering directory `/usr/src/asterisk/asterisk-1.6.2.10/menuselect’
    make[1]: `makeopts’ is up to date.
    make[1]: Leaving directory `/usr/src/asterisk/asterisk-1.6.2.10/menuselect’
    [LD] aelparse.o aelbison.o pbx_ael.o hashtab.o ael_main.o ast_expr2f.o ast_expr2.o strcompat.o pval.o extconf.o -> aelparse
    hashtab.o: In function `_ast_rwlock_wrlock’:
    /usr/src/asterisk/asterisk-1.6.2.10/include/asterisk/lock.h:1281: undefined reference to `ast_bt_get_addresses’
    hashtab.o: In function `_ast_rwlock_rdlock’:
    /usr/src/asterisk/asterisk-1.6.2.10/include/asterisk/lock.h:1173: undefined reference to `ast_bt_get_addresses’
    collect2: ld returned 1 exit status
    [CC] conf2ael.c -> conf2ael.o
    [LD] conf2ael.o ast_expr2f.o ast_expr2.o hashtab.o aelbison.o aelparse.o pbx_ael.o pval.o extconf.o strcompat.o -> conf2ael
    hashtab.o: In function `_ast_rwlock_wrlock’:
    /usr/src/asterisk/asterisk-1.6.2.10/include/asterisk/lock.h:1281: undefined reference to `ast_bt_get_addresses’
    hashtab.o: In function `_ast_rwlock_rdlock’:
    /usr/src/asterisk/asterisk-1.6.2.10/include/asterisk/lock.h:1173: undefined reference to `ast_bt_get_addresses’

    Please , help meee………..

  4. maybe you forget the #yum update, i did forget, and after see this page http://www.astblog.com/2010/07/17/you-do-not-appear-to-have-the-sources-for-the-uname-r-kernel-installed/ i could fix the problem with that command

  5. Tanks, fantasti document. tank you

  6. i’m facing problem unable to receive voicemail to email.
    please guide me. TQ

  7. hello,

    I really enjoyed the tutorial. I’m installing a system like everything went well, but displays the following information:

    [Aug 30 10:51:23] WARNING[13096]: utils.c:1536 __ast_string_field_init: trying to reset empty pool
    [Aug 30 10:51:23] WARNING[13096]: utils.c:1536 __ast_string_field_init: trying to reset empty pool
    [Aug 30 10:51:23] WARNING[13096]: utils.c:1536 __ast_string_field_init: trying to reset empty pool
    [Aug 30 10:51:23] WARNING[13096]: chan_dahdi.c:17138 process_dahdi: Ignoring any changes to ‘userbase’ (on reload) at line 23.
    [Aug 30 10:51:23] WARNING[13096]: chan_dahdi.c:17138 process_dahdi: Ignoring any changes to ‘vmsecret’ (on reload) at line 31.
    [Aug 30 10:51:23] WARNING[13096]: chan_dahdi.c:17138 process_dahdi: Ignoring any changes to ‘hassip’ (on reload) at line 35.
    [Aug 30 10:51:23] WARNING[13096]: chan_dahdi.c:17138 process_dahdi: Ignoring any changes to ‘hasiax’ (on reload) at line 39.
    [Aug 30 10:51:23] WARNING[13096]: chan_dahdi.c:17138 process_dahdi: Ignoring any changes to ‘hasmanager’ (on reload) at line 47.

    Does any mistake?

    When I do:

    service asterisk start OK
    but if I come back to make it displays the following information

    Asterisk ended with exit status 1
    Asterisk died with code 1.
    Automatically restarting Asterisk.

    Knows what might be happening?

    Greetings and thanks in advance.

    Doug

  8. for “You do not appear to have the sources for the 2.6.18-194.el5 kernel installed.” …. this error

    Do
    yum update kernel

  9. Bankruptcy lawyer las vegas enterprise features decided to carry out an IVR answer, there are many of things to watch out for. The actual IVR will be quite a few callers’ 1st reference to your company. Nonetheless, any inadequately developed technique may execute a good deal to which makes it his or her very last.

  10. its really helpfull.

  11. Atati mtandika says:

    Thanks. This has been very helpful

  12. Things have changed in unix (sco!!!) in over 30 years now. Great instructions, I think I will pull it thru and will amke a couple phone ring in the house! I am excited, again GREAT JOB. THANKS.

  13. how running sendsms, voicemail? reply to my email… help me

    regards,
    Zolboo

  14. The error is at the bottom i receive this error when i do the command make install for asterisk please help?

    .$$$$$$$$$$$$$$$=..
    .$7$7.. .7$$7:.
    .$$:. ,$7.7
    .$7. 7$$$$ .$$77
    ..$$. $$$$$ .$$$7
    ..7$ .?. $$$$$ .?. 7$$$.
    $.$. .$$$7. $$$$7 .7$$$. .$$$.
    .777. .$$$$$$77$$$77$$$$$7. $$$,
    $$$~ .7$$$$$$$$$$$$$7. .$$$.
    .$$7 .7$$$$$$$7: ?$$$.
    $$$ ?7$$$$$$$$$$I .$$$7
    $$$ .7$$$$$$$$$$$$$$$$ :$$$.
    $$$ $$$$$$7$$$$$$$$$$$$ .$$$.
    $$$ $$$ 7$$$7 .$$$ .$$$.
    $$$$ $$$$7 .$$$.
    7$$$7 7$$$$ 7$$$
    $$$$$ $$$
    $$$$7. $$ (TM)
    $$$$$$$. .7$$$$$$ $$
    $$$$$$$$$$$$7$$$$$$$$$.$$$$$$
    $$$$$$$$$$$$$$$$.

    configure: Package configured for:
    configure: OS type : linux-gnu
    configure: Host CPU : x86_64
    configure: build-cpu:vendor:os: x86_64 : unknown : linux-gnu :
    configure: host-cpu:vendor:os: x86_64 : unknown : linux-gnu :
    [root@zocopub1 asterisk-1.6.2.0]# make install
    CC=”cc” CXX=”g++” LD=”" AR=”" RANLIB=”" CFLAGS=”" make -C menuselect CONFIGURE_SILENT=”–silent” makeopts
    make[1]: Entering directory `/usr/src/asterisk/asterisk-1.6.2.0/menuselect’
    make[1]: `makeopts’ is up to date.
    make[1]: Leaving directory `/usr/src/asterisk/asterisk-1.6.2.0/menuselect’
    menuselect/menuselect –check-deps menuselect.makeopts
    Generating embedded module rules …
    [LD] aelparse.o aelbison.o pbx_ael.o hashtab.o ael_main.o ast_expr2f.o ast_expr2.o strcompat.o pval.o extconf.o -> aelparse
    hashtab.o: In function `_ast_rwlock_wrlock’:
    /usr/src/asterisk/asterisk-1.6.2.0/include/asterisk/lock.h:1285: undefined reference to `ast_bt_get_addresses’
    hashtab.o: In function `_ast_rwlock_rdlock’:
    /usr/src/asterisk/asterisk-1.6.2.0/include/asterisk/lock.h:1177: undefined reference to `ast_bt_get_addresses’
    /usr/src/asterisk/asterisk-1.6.2.0/include/asterisk/lock.h:1177: undefined reference to `ast_bt_get_addresses’
    hashtab.o: In function `_ast_rwlock_wrlock’:
    /usr/src/asterisk/asterisk-1.6.2.0/include/asterisk/lock.h:1285: undefined reference to `ast_bt_get_addresses’
    /usr/src/asterisk/asterisk-1.6.2.0/include/asterisk/lock.h:1285: undefined reference to `ast_bt_get_addresses’
    hashtab.o:/usr/src/asterisk/asterisk-1.6.2.0/include/asterisk/lock.h:1285: more undefined references to `ast_bt_get_addresses’ follow
    collect2: ld returned 1 exit status
    make[1]: *** [aelparse] Error 1
    make: *** [utils] Error 2
    [root@zocopub1 asterisk-1.6.2.0]#

  15. I feel like I’m often looking for interesting things to read about a variety of subjects, but I manage to include your site among my reads every day because you have honest entries that I look forward to. Here’s hoping there’s a lot more amazing material coming!

  16. I’m really impressed with your writing skills as well as with the layout on your blog. Is this a paid theme or did you customize it yourself? Either way keep up the excellent quality writing, it’s rare to see a nice blog like this one nowadays..

  17. Genuinely educational appreciate it, I’m sure your current readers would probably want a lot more information like this maintain the excellent effort.

  18. Arctic Solution says:

    Great Post, just wanted to add to it that when doing menuselect donot add embedding in your installation as this will force the installation to crash while making asterisk.

  19. Arctic Solution says:

    I want to ask one more thing after doing this installation do I need asterisknow? if asterisknow is able to install everything in 20 minutes why does one follow these steps?

  20. Great review! You actually overviewed some curious things on your blog. I came across it by using Yahoo and I’ve got to admit that I already subscribed to the RSS, it’s very great :)

  21. great read you always have great post keep up the good work a real good read plz check out my music page when you have time

  22. Excellent! This was really helpful, and just wanted to thank you. When I was looking for the best web hosting, I read reviews to find the best one.

  23. I’d like to see a post of the top 10 VPS suppliers and get real peoples thoughts of their products and services.

  24. You are actually a excellent webmaster. The website loading pace is amazing. It sort of feels that you’re doing any unique trick. Moreover, The contents are masterwork. you’ve performed a great process on this topic!

Trackbacks/Pingbacks

Leave a Reply