CentOS 5 and Asterisk 1.4.x installation
Base Install of Asterisk on an i386 CentOS
For reasons detailed elsewhere, you're best not using a GUI, so do the installation from the command line ('linux-text' at the GRUB prompt). When you select the packages, the only one you need is 'server'. Disk partitioning, networking etc. is all entirely up to you!
At your first login, you'll be presented with a simple administration screen. Disable SELinux and (for now) the firewall.
Dependencies
The first thing to do is to get your box up to date. If you have CentOS 5.1 or lower, you may want to upgrade to CentOS 5.2. Try:
yum -y upgrade
and then reboot. Otherwise, to update all the installed packages, at the shell, run
yum -y update
When you've done either of the above, reboot the machine when it's finished (as it'll install a new kernel) and then run
yum -y update
again and repeat until there are no more updates.
Quick method:
Do you trust me? If so, the line below will install all the dependencies you need (and then some!) - cut and paste from here if you're happy to install things you may or may not need. If not, then have a look at this page's history as some of the dependencies are listed separately.
yum -y install gcc gcc-c++ kernel-devel bison openssl-devel \
libtermcap-devel ncurses-devel doxygen curl-devel newt-devel \
mlocate lynx tar wget nmap bzip2 mod_ssl crontabs vixie-cron \
speex speex-devel unixODBC unixODBC-devel libtool-ltdl \
libtool-ltdl-devel mysql-connector-odbc mysql mysql-devel \
mysql-server php-mysql php-mbstring php-mcrypt flex screen \
libxml2 libxml2-devel libtiff libtiff-devel
libtermcap-devel ncurses-devel doxygen curl-devel newt-devel \
mlocate lynx tar wget nmap bzip2 mod_ssl crontabs vixie-cron \
speex speex-devel unixODBC unixODBC-devel libtool-ltdl \
libtool-ltdl-devel mysql-connector-odbc mysql mysql-devel \
mysql-server php-mysql php-mbstring php-mcrypt flex screen \
libxml2 libxml2-devel libtiff libtiff-devel
For Centos X86_64
yum -y install gcc.x86_64 gcc-c++.x86_64 kernel-devel.x86_64 bison.x86_64 openssl-devel.x86_64 \
libtermcap-devel.x86_64 ncurses-devel.x86_64 doxygen.x86_64 curl-devel.x86_64 newt-devel.x86_64 \
mlocate.x86_64 lynx.x86_64 tar.x86_64 wget.x86_64 nmap.x86_64 bzip2.x86_64 mod_ssl.x86_64 \
crontabs.x86_64 vixie-cron.x86_64 speex.x86_64 speex-devel.x86_64 unixODBC.x86_64 \
unixODBC-devel.x86_64 libtool-ltdl.x86_64 libtool-ltdl-devel.x86_64 mysql-connector-odbc.x86_64 \
mysql.x86_64 mysql-devel.x86_64 mysql-server.x86_64 php-mysql.x86_64 php-mbstring.x86_64 \
php-mcrypt.x86_64 flex.x86_64 screen.x86_64
yum -y install libidn-devel krb5-devel krb5-libs zlib-devel libidn-devel
ln -sf /lib64/libcom_err.so.2 /lib64/libcom_err.so
libtermcap-devel.x86_64 ncurses-devel.x86_64 doxygen.x86_64 curl-devel.x86_64 newt-devel.x86_64 \
mlocate.x86_64 lynx.x86_64 tar.x86_64 wget.x86_64 nmap.x86_64 bzip2.x86_64 mod_ssl.x86_64 \
crontabs.x86_64 vixie-cron.x86_64 speex.x86_64 speex-devel.x86_64 unixODBC.x86_64 \
unixODBC-devel.x86_64 libtool-ltdl.x86_64 libtool-ltdl-devel.x86_64 mysql-connector-odbc.x86_64 \
mysql.x86_64 mysql-devel.x86_64 mysql-server.x86_64 php-mysql.x86_64 php-mbstring.x86_64 \
php-mcrypt.x86_64 flex.x86_64 screen.x86_64
yum -y install libidn-devel krb5-devel krb5-libs zlib-devel libidn-devel
ln -sf /lib64/libcom_err.so.2 /lib64/libcom_err.so
Download and install Asterisk and components
Download
Download the latest asterisk version /usr/src/asterisk and untar the files as follows:
mkdir -p /usr/src/asterisk
cd /usr/src/asterisk
wget http://downloads.digium.com/pub/asterisk/asterisk-1.4-current.tar.gz
wget http://downloads.digium.com/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
wget http://downloads.digium.com/pub/libpri/libpri-1.4-current.tar.gz
wget http://soft-switch.org/downloads/spandsp/spandsp-0.0.5.tgz
tar -zxf dahdi-linux-complete-current.tar.gz
tar -zxf asterisk-1.4-current.tar.gz
tar -zxf libpri-1.4-current.tar.gz
tar -zxf spandsp-0.0.5.tgz
cd /usr/src/asterisk
wget http://downloads.digium.com/pub/asterisk/asterisk-1.4-current.tar.gz
wget http://downloads.digium.com/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
wget http://downloads.digium.com/pub/libpri/libpri-1.4-current.tar.gz
wget http://soft-switch.org/downloads/spandsp/spandsp-0.0.5.tgz
tar -zxf dahdi-linux-complete-current.tar.gz
tar -zxf asterisk-1.4-current.tar.gz
tar -zxf libpri-1.4-current.tar.gz
tar -zxf spandsp-0.0.5.tgz
You'll end up with four tar files and four directories in the directory '/usr/src/asterisk'.
SpanDSP (optional)
cd /usr/src/asterisk/spandsp-0.0.5
make clean
./configure
make
make install
cat > /etc/ld.so.conf.d/spandsp.conf << EOF
/usr/local
EOF
ldconfig
make clean
./configure
make
make install
cat > /etc/ld.so.conf.d/spandsp.conf << EOF
/usr/local
EOF
ldconfig
Libpri (optional)
If you are using E1 cards you need to install LIBPRI. If you do want to use LIBPRI, make sure you compile and install it before you compile Asterisk. Replace 'VERSION' with the correct details.
cd /usr/src/asterisk/libpri-VERSION
make clean
make
make install
make clean
make
make install
DAHDI
You're pretty much going to need DAHDI. If not for any hardware then for the dummy timer anyway. Note that the stock CentOS kernels come with a 1000HZ timer and so don't need recompiling (phew!). Replace 'VERSION' with the correct details.
cd /usr/src/asterisk/dahdi-linux-complete-VERSION
make all
make install
make config
make all
make install
make config
Edit /etc/dahdi/modules.conf, /etc/dahdi/system.conf and /etc/asterisk/chan_dahdi.conf for your site.
Set DAHDI to start automatically and then start it.
chkconfig dahdi on
service dahdi start
service dahdi start
Asterisk
cd /usr/src/asterisk/asterisk-VERSION
make clean
./configure
make clean
./configure
Choose which options to install (audio files, voicemail storage, codecs etc.)
make menuselect
make
make install
make
make install
Install sample files in /etc/asterisk, install docs/manpages and set to start on boot.
make samples
make progdocs
make config
chkconfig asterisk on
make progdocs
make config
chkconfig asterisk on
Check Asterisk starts properly:
asterisk -vvvvvvvvvvvvvvvvvvvc
stop now
stop now
If not, you've probably not been following these instructions carefully! Assuming it does start properly, you probably want to start it in the background:
service asterisk start
Then edit the following files in /etc/asterisk:
indications.conf - Change default country
modules.conf - Uncomment the line 'preload => res_odbc.so'
modules.conf - Add 'noload => pbx_ael.so' to bottom of file
modules.conf - Add 'noload => codec_dahdi.so' to the bottom of the file
modules.conf - Uncomment the line 'preload => res_odbc.so'
modules.conf - Add 'noload => pbx_ael.so' to bottom of file
modules.conf - Add 'noload => codec_dahdi.so' to the bottom of the file
Tidy up a bit (you can cut and paste all of this to the command line)
rm /etc/asterisk/extensions.ael
cat > /etc/asterisk/extensions.conf << EOF
[general]
static=yes
writeprotect=yes
autofallthrough=yes
extenpatternmatchnew=no
clearglobalvars=yes
priorityjumping=no
userscontext=default
[globals]
[default]
exten => _.,1,Goto(i,1)
exten => i,1,NoOp(Invalid)
exten => i,n,Congestion()
exten => i,n,Hangup()
exten => h,1,NoOp(Hanging up)
EOF
rm /etc/asterisk/extensions.lua
cat > /etc/asterisk/sip.conf << EOF
[general]
context=default
allowguest=yes
match_auth_username=yes
allowoverlap=no
allowtransfer=no
realm=pbx12.vitell.co.uk
udpbindaddr=0.0.0.0
tcpenable=no
tlsenable=no
srvlookup=yes
pedantic=no
tos_sip=cs3
tos_audio=ef
tos_video=af41
tos_text=af41
cos_sip=3
cos_audio=5
cos_video=4
cos_text=3
maxexpiry=3600
minexpiry=60
defaultexpiry=120
mwiexpiry=3600
qualifyfreq=60
qualifygap=100
qualifypeers=1
vmexten=voicemail
disallow=all
allow=alaw
mohinterpret=default
mohsuggest=default
parkinglot=plaza
language=en
relaxdtmf=yes
useragent=AsteriskPBX
sdpsession=AsteriskPBX
promiscredir=no
dtmfmode=rfc2833
videosupport=no
callevents=no
alwaysauthreject=yes
shrinkcallerid=no
allowsubscribe=yes
subscribecontext=default
notifyringing=yes
notifyhold=yes
notifycid=yes
callcounter=yes
t38pt_udptl=yes,fec,maxdatagram=400
faxdetect=no
nat=no
directmedia=no
directrtpsetup=no
EOF
cat > /etc/asterisk/extensions.conf << EOF
[general]
static=yes
writeprotect=yes
autofallthrough=yes
extenpatternmatchnew=no
clearglobalvars=yes
priorityjumping=no
userscontext=default
[globals]
[default]
exten => _.,1,Goto(i,1)
exten => i,1,NoOp(Invalid)
exten => i,n,Congestion()
exten => i,n,Hangup()
exten => h,1,NoOp(Hanging up)
EOF
rm /etc/asterisk/extensions.lua
cat > /etc/asterisk/sip.conf << EOF
[general]
context=default
allowguest=yes
match_auth_username=yes
allowoverlap=no
allowtransfer=no
realm=pbx12.vitell.co.uk
udpbindaddr=0.0.0.0
tcpenable=no
tlsenable=no
srvlookup=yes
pedantic=no
tos_sip=cs3
tos_audio=ef
tos_video=af41
tos_text=af41
cos_sip=3
cos_audio=5
cos_video=4
cos_text=3
maxexpiry=3600
minexpiry=60
defaultexpiry=120
mwiexpiry=3600
qualifyfreq=60
qualifygap=100
qualifypeers=1
vmexten=voicemail
disallow=all
allow=alaw
mohinterpret=default
mohsuggest=default
parkinglot=plaza
language=en
relaxdtmf=yes
useragent=AsteriskPBX
sdpsession=AsteriskPBX
promiscredir=no
dtmfmode=rfc2833
videosupport=no
callevents=no
alwaysauthreject=yes
shrinkcallerid=no
allowsubscribe=yes
subscribecontext=default
notifyringing=yes
notifyhold=yes
notifycid=yes
callcounter=yes
t38pt_udptl=yes,fec,maxdatagram=400
faxdetect=no
nat=no
directmedia=no
directrtpsetup=no
EOF
Configure MySQL (optional)
The information below shows table definitions for all of the tables Asterisk can use with MySQL or ODBC.
Notes
The UniqueID field in the CDR table is not necessarily unique! Due to the very very dodgy way Asterisk handles unique IDs, if you set the field to be the primary key (as advised elsewhere), you will lose data.
SQL
Note that the SIP 'qualify' field has a default value set to 'yes'. This is for two reasons. Firstly, I wrote these notes because it's how I use and want to use Asterisk. Secondly, whether qualification is enabled or not in realtime is controlled by the 'rtcachefriends' setting in sip.conf - if it's 'no', then whether 'qualify' is 'yes' or 'no' in the database is irrelevant. It makes sense therefore to enable it in the database and then turn it on or off with the 'rtcachefriends' setting.
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
##
##Database: `asterisk`
##
CREATE DATABASE `asterisk` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `asterisk`;
##########################################################
##
##Table structure for table `cdr`
##
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 ;
##########################################################
##
##Table structure for table `queue_members`
##
CREATE TABLE IF NOT EXISTS `queue_members` (
`queue_name` varchar(128) NOT NULL default '',
`interface` varchar(128) NOT NULL default '',
`penalty` int(11) default NULL,
PRIMARY KEY (`queue_name`,`interface`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
##########################################################
##
##Table structure for table `queues`
##
CREATE TABLE IF NOT EXISTS `queues` (
`name` varchar(128) NOT NULL,
`musiconhold` varchar(128) default 'default',
`announce` varchar(128) default NULL,
`context` varchar(128) default NULL,
`timeout` int(11) default '60',
`monitor_join` tinyint(1) default NULL,
`monitor_format` varchar(128) default NULL,
`queue_youarenext` varchar(128) default NULL,
`queue_thereare` varchar(128) default NULL,
`queue_callswaiting` varchar(128) default NULL,
`queue_holdtime` varchar(128) default NULL,
`queue_minutes` varchar(128) default NULL,
`queue_seconds` varchar(128) default NULL,
`queue_lessthan` varchar(128) default NULL,
`queue_thankyou` varchar(128) default NULL,
`queue_reporthold` varchar(128) default NULL,
`announce_frequency` int(11) default NULL,
`announce_round_seconds` int(11) default NULL,
`announce_holdtime` varchar(128) default NULL,
`periodic_announce` varchar(128) default NULL,
`periodic_announce_frequency` int(11) default NULL,
`retry` int(11) default '5',
`ringinuse` varchar(5) NOT NULL default 'no',
`autofill` varchar(5) NOT NULL default 'yes',
`autopause` varchar(5) NOT NULL default 'no',
`setinterfacevar` varchar(5) NOT NULL default 'yes',
`wrapuptime` int(11) default '30',
`maxlen` int(11) default NULL,
`servicelevel` int(11) default NULL,
`strategy` varchar(128) default 'ringall',
`joinempty` varchar(128) default 'no',
`leavewhenempty` varchar(128) default 'yes',
`eventmemberstatus` tinyint(1) default NULL,
`eventwhencalled` tinyint(1) default NULL,
`reportholdtime` tinyint(1) default NULL,
`memberdelay` int(11) default NULL,
`weight` int(11) default NULL,
`timeoutrestart` tinyint(1) default NULL,
PRIMARY KEY (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
##########################################################
##
##Table structure for table `sip`
##
CREATE TABLE IF NOT EXISTS `sip` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(80) NOT NULL,
`host` varchar(31) NOT NULL default 'dynamic',
`nat` varchar(5) NOT NULL default 'no',
`type` enum('user','peer','friend') NOT NULL default 'friend',
`accountcode` varchar(20) default 'ACCOUNT',
`amaflags` varchar(13) default NULL,
`callgroup` varchar(10) default NULL,
`callerid` varchar(80) default NULL,
`call-limit` varchar(6) NOT NULL default '10',
`cancallforward` char(3) default 'yes',
`canreinvite` char(3) default 'no',
`context` varchar(80) default 'from-sip',
`defaultip` varchar(15) default NULL,
`dtmfmode` varchar(7) default 'rfc2833',
`fromuser` varchar(80) default NULL,
`fromdomain` varchar(80) default NULL,
`insecure` varchar(4) default NULL,
`language` char(2) default 'en',
`mailbox` varchar(50) default NULL,
`md5secret` varchar(80) default NULL,
`deny` varchar(95) default '0.0.0.0/0.0.0.0',
`permit` varchar(95) default '0.0.0.0/0.0.0.0',
`mask` varchar(95) default NULL,
`musiconhold` varchar(100) default 'default',
`pickupgroup` varchar(10) default NULL,
`qualify` char(3) default 'yes',
`regexten` varchar(80) default NULL,
`restrictcid` char(3) default NULL,
`rtptimeout` char(3) default NULL,
`rtpholdtimeout` char(3) default NULL,
`secret` varchar(80) default 'SECRET',
`setvar` varchar(100) default NULL,
`disallow` varchar(100) default 'all',
`allow` varchar(100) default 'alaw',
`fullcontact` varchar(80) NOT NULL default '',
`ipaddr` varchar(15) NOT NULL default '',
`port` smallint(5) unsigned NOT NULL default '0',
`regserver` varchar(100) default NULL,
`regseconds` int(11) NOT NULL default '0',
`username` varchar(80) NOT NULL,
`defaultuser` varchar(80) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
KEY `name_2` (`name`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC AUTO_INCREMENT=301 ;
##########################################################
##
##Table structure for table `voicemail_messages`
##
CREATE TABLE IF NOT EXISTS `voicemail_messages` (
`id` int(11) NOT NULL auto_increment,
`msgnum` int(11) NOT NULL default '0',
`dir` varchar(80) default '',
`context` varchar(80) default '',
`macrocontext` varchar(80) default '',
`callerid` varchar(40) default '',
`origtime` varchar(40) default '',
`duration` varchar(20) default '',
`mailboxuser` varchar(80) default '',
`mailboxcontext` varchar(80) default '',
`recording` longblob,
PRIMARY KEY (`id`),
KEY `dir` (`dir`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1088 ;
##########################################################
##
##Table structure for table `voicemail_users`
##
CREATE TABLE IF NOT EXISTS `voicemail_users` (
`uniqueid` int(11) NOT NULL auto_increment,
`customer_id` varchar(11) NOT NULL default '0',
`context` varchar(50) NOT NULL default 'default',
`mailbox` varchar(11) NOT NULL default '0',
`password` varchar(5) NOT NULL default '6666',
`fullname` varchar(150) NOT NULL,
`email` varchar(50) NOT NULL,
`pager` varchar(50) NOT NULL,
`tz` varchar(10) NOT NULL default 'en',
`attach` varchar(4) NOT NULL default 'yes',
`saycid` varchar(4) NOT NULL default 'yes',
`dialout` varchar(10) NOT NULL,
`callback` varchar(10) NOT NULL,
`review` varchar(4) NOT NULL default 'no',
`operator` varchar(4) NOT NULL default 'no',
`envelope` varchar(4) NOT NULL default 'no',
`sayduration` varchar(4) NOT NULL default 'no',
`saydurationm` tinyint(4) NOT NULL default '1',
`sendvoicemail` varchar(4) NOT NULL default 'no',
`delete` varchar(4) NOT NULL default 'no',
`nextaftercmd` varchar(4) NOT NULL default 'yes',
`forcename` varchar(4) NOT NULL default 'no',
`forcegreetings` varchar(4) NOT NULL default 'no',
`hidefromdir` varchar(4) NOT NULL default 'yes',
`stamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
PRIMARY KEY (`uniqueid`),
KEY `mailbox_context` (`mailbox`,`context`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=101 ;
## ########################################################
##
##Create realtime user with approximately the right privs.
##
CREATE USER 'astrealtime'@'localhost' IDENTIFIED BY 'MYPASS';
GRANT FILE ON * . * TO 'astrealtime'@'localhost' IDENTIFIED BY 'MYPASS' 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 'astrealtime'@'localhost';
GRANT SELECT , INSERT , UPDATE , DELETE ON `asterisk`.`queue_members` TO 'astrealtime'@'localhost';
GRANT SELECT , UPDATE ON `asterisk`.`queues` TO 'astrealtime'@'localhost';
GRANT SELECT , UPDATE ON `asterisk`.`sip` TO 'astrealtime'@'localhost';
GRANT SELECT , UPDATE ON `asterisk`.`voicemail_users` TO 'astrealtime'@'localhost';
GRANT SELECT , UPDATE , INSERT , DELETE ON `asterisk`.`voicemail_messages` TO 'astrealtime'@'localhost';
Configure various files
Set up CDR to ODBC (MySQL)
Edit /etc/asterisk/cdr_odbc.conf
[global]
dsn=astrealtime
username=astrealtime
password=MYPASS
loguniqueid=yes
dispositionstring=yes
table=cdr
usegmtime=yes
Set up realtime
Edit /etc/asterisk/extconfig.conf
[settings]
queues => odbc,astrealtime,queues
queue_members => odbc,astrealtime,queue_members
sippeers => odbc,astrealtime,sip
sipusers => odbc,astrealtime,sip
voicemail => odbc,astrealtime,voicemail_users
ODBC configuration (using settings from above)
/etc/odbcinst.ini
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib/libmyodbc3.so
Setup = /usr/lib/libodbcmyS.so
FileUsage = 1
(Note the '3' which isn't in the original sample file!)
/etc/odbc.ini
; DSN definitions
[astrealtime]
Description = Asterisk realtime and other FUNC_ODBC access
Driver = MySQL
Socket = /var/lib/mysql/mysql.sock
Server = localhost
User = astrealtime
Pass = MYPASS
Database = asterisk
Option = 3
/etc/asterisk/res_odbc.conf
; Environment variables
[ENV]
; Connections
[astrealtime]
enabled => yes
dsn => astrealtime
username => astrealtime
password => MYPASS
pre-connect => yes
idlecheck => 3600
/etc/asterisk/func_odbc.conf
This really depends on why you need database access from the dialplan!
Referance Website
http://www.voip-info.org/wiki/view/CentOS+5+and+Asterisk+1.4.x+installation
No comments:
Post a Comment