I wanted to upgrade my PBX from 1.2 to 1.4, and during the process decided to format my box, and start fresh from Gentoo 2006.1. I’ve documented the process here for everyone to help with getting Asterisk 1.4 working, including the GUI if you want it. I run Asterisk from command line, with a local Apache Daemon, and MYSQL running for Callerid Storage. Readon!
Prerequisites:
- Gentoo Universal or Minimal Installation CD
- Computer
- Some Time
- Internet Connection
- Apache Web Server 2.0
- Unixish Operating System, In this case Gentoo Linux 2006.1
The Howto :
First I installed Gentoo the standard way. I started with
2006.1
and did a stage3 installation. Following that I sync’d world, installed the basic apps, and started sshd. If you need to know more information about this, check out Gentoo. Gentoo setup is beyond the scope of this document.I then entered the
/opt
directory and created my asterisk directory.# cd /opt # mkdir asterisk
Then I grabbed the Files required to install Asterisk
# wget http://ftp.digium.com/pub/asterisk/releases/asterisk-1.4.0-beta3.tar.gz # wget http://ftp.digium.com/pub/zaptel/releases/zaptel-1.4.0-beta2.tar.gz # wget http://ftp.digium.com/pub/asterisk/releases/asterisk-addons-1.4.0-beta2.tar.gz
I then Installed the pre-requisits
# emerge -uvD gnutls # echo "dev-libs/iksemel gnutls" >> /etc/portage/package.use # emerge -uvD iksemel # emerge -uvD newt # emerge -uvD uw-imap (for asterisk imap voicemail storage) # emerge -uvD mysql (for cdr storage and realtime if wanted later on) # emerge -uvD subversion (to download new asterisk GUI)
Since I will be using SpanDSP I got it Installed as well
# echo "media-libs/spandsp ~x86" >> /etc/portage/package.keywords # emerge -uvD spandsp
Now we can begin compiling zaptel, asterisk and asterisk addons.
# tar xzvf zaptel-1.4.0-beta2.tgz # cd zaptel-1.4.0-beta2 # ./configure # make menuselect # make # make install-udev # tar xzvf asterisk-1.4.0-beta3.tar.gz # cd asterisk-1.4.0-beta3 # ./configure # make menuselect # make # make install # make samples (will overwrite anything in /etc/asterisk) # tar xzvf asterisk-addons-1.4.0-beta2.tar.gz # cd asterisk-addons-1.4.0-beta2 # make samples (will overwrite anything in /etc/asterisk)
Next I enabled the modules I would be needing:
# modprobe zaptel # modprobe ztdummy
Now we must create some init scripts to start asterisk on reboot of the machine if that ever happens. Unlikely, but possible.
Then I added my own /etc/init.d/ since we won’t be using the portage tree for asterisk
#!/sbin/runscript MODULES="zaptel wcfxo wctdm" depend() { need net logger } start() { ebegin "Starting Zaptel" modprobe zaptel echo -n "Waiting for zap to come online" TMOUT=10 # max secs to wait while [ ! -d /dev/zap ] ; do sleep 1 TMOUT=`expr $TMOUT – 1` if [ $TMOUT -eq 0 ] ; then echo "Error: missing /dev/zap!" exit 1 fi done echo "OK" echo -n "Loading zaptel hardware modules:" for x in $MODULES; do if modprobe ${x} ${ARGS} >& /dev/null; then echo -n " $x" echo -n fi done echo "" echo -n "Running ztcfg: " /sbin/ztcfg -vv echo -n "OK" echo eend $? "Failed to start Zaptel" } stop() { ebegin "Stopping Zaptel" for x in $MODULES; do rmmod ${x} done rmmod zaptel eend $? "Failed to stop Asterisk" }
Then I added my own /etc/init.d/asterisk script since we won’t be using portage, just like zaptel.
#!/sbin/runscript depend() { need net logger zaptel } start() { ebegin "Starting Asterisk" /bin/sh /root/own_asterisk.sh /usr/sbin/asterisk -U asterisk -G asterisk -qg eend $? "Failed to start Asterisk" } stop() { ebegin "Stopping Asterisk" kill $(cat /var/run/asterisk/asterisk.pid) eend $? "Failed to stop Asterisk" }
Then I added the user and group asterisk
# groupadd asterisk # adduser -d /var/run/asterisk -g asterisk -m -s /sbin/nologin asterisk
Then I added my own “ownuser” script that ensures asterisk is owned properly by the correct user and group
# nano /root/own_asterisk.sh
put this in it
#!/bin/sh
chown –recursive asterisk:asterisk /var/lib/asterisk
chown –recursive asterisk:asterisk /var/log/asterisk
chown –recursive asterisk:asterisk /var/run/asterisk
chown –recursive asterisk:asterisk /var/spool/asterisk
chown –recursive asterisk:asterisk /var/spool/asterisk-fax
chown –recursive asterisk:asterisk /dev/zap
chmod –recursive u=rwX,g=rX,o= /var/lib/asterisk
chmod –recursive u=rwX,g=rX,o= /var/log/asterisk
chmod –recursive u=rwX,g=rX,o= /var/run/asterisk
chmod –recursive u=rwX,g=rX,o= /var/spool/asterisk
chmod –recursive u=rwX,g=rX,o= /dev/zap
chown –recursive root:asterisk /etc/asterisk
chmod –recursive u=rwX,g=rX,o= /etc/asterisk
# for alsa
#chown asterisk /dev/dsp
#chown –recursive asterisk /dev/sound
#chown –recursive asterisk /dev/snd
chmod g+w /etc/asterisk
make it executable
# chmod +x /root/own_asterisk.sh
Then I created
/var/run/asterisk
and owned it toasterisk:asterisk
# mkdir /var/run/asterisk # chown asterisk:asterisk /var/run/asterisk
Then I changed the run directory in
/etc/asterisk/asterisk.conf
# nano /etc/asterisk/asterisk.conf
make sure this is set
astrundir => /var/run/asterisk
Then I installed phpmyadmin, apache, mysql and php. I know this isn’t the best for a phone system, but we want mysql callerid records. And other fun database functionality. Having it all on one box keeps costs low and easy administration. Single point of failure, but since when does anyone care about that right! 🙂
# emerge apache # echo "dev-lang/php berkdb cli crypt gdbm iconv ncurses nls pcre readline reflection session spl ssl unicode zlib apache2 bzip2 calendar curl curlwrappers gd ftp imap mysql xml xsl zip" >> /etc/portage/package.use # emerge phpmyadmin
For my faxing, I then did this, you may not require this so just skip this as it hasn’t been tested yet anyway.
# emerge -upvD mimeconstruct # mkdir /var/spool/asterisk-fax
Then I configured phpmyadmin
# mysql -u root -p </usr/share/webapps/phpmyadmin/2.9.0.3/sqlscripts/mysql/2.9.0.3_create.sql
Then I made sure that php was started with apache
# nano /etc/conf.d/apache2 ensure that -D PHP5 is included on the options line
Then I started apache + added it to default runlevel
# rc-update add apache default # rc-update add mysql default
Then I changed apache to run as asterisk:asterisk
# nano /etc/apache/httpd.conf User asterisk Group asterisk
Next I downloaded the Asterisk GUI source code from SVN
# cd /opt # svn checkout http://svn.digium.com/svn/asterisk-gui/trunk asterisk-gui # cd asterisk-gui/ # make # make install # make samples
Next I modified the
/etc/asterisk/http.conf
to the following:[general] enabled=yes enablestatic=yes bindaddr=10.0.2.2 bindport=8088
Next I modified manager.conf and changed the following:
enabled = yes webenabled = yes bindaddr = 10.0.2.2
Next, I added this to the manager.conf:
[admin] secret = admin read = system,call,log,verbose,command,agent,user,config write = system,call,log,verbose,command,agent,user,config
Then I started asterisk up with debugging to see any warnings or errors
# asterisk -vvvvvvvvvvvvvvgc
I had a few warnings about empty contexts in extensions.ael, I simply commented them out.
Then I tried to connect to the new Asterisk GUI, logging in as the user you setup in manager.conf
http://<YOUR IPHERE>::8088/asterisk/static/config/cfgbasic.html
Great, it all seems to work. Now, what about Caller ID logging. First, ensure that mysql has been setup, then connect to it via phpmyadmin, and create yourself a database, and user. Below is the format for the table:
CREATE TABLE cdr ( 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 " );
Now, you must configure Asterisk to use this new database for callerid logging
# nano /etc/asterisk/cdr_mysql.conf [global] hostname=127.0.0.1 dbname=asterisk_cdr table=cdr password=<YOURDBPASSWRD> user=<YOURDBUSER> port=3306 sock=/tmp/mysql.sock userfield=1
Next, you can install Areski’s CallerID tool to view these records. Installation instructions are included in his file.
Reboot your box to ensure that everything started on reboot (Apache, Asterisk, Zaptel modules, Mysql). If something didn’t start, verify it’s in your startup scripts, and try again.
Congratulations, You should be finished with Asterisk 1.4, MYSQL CDR Logging, (Sorta) Faxing Capability and Asterisk 1.4 GUI. Look forward to a faxing howto coming soon.
Comments
Comment by Nick on 2005-04-21 00:01:54 -0500
You are everywhere..
Comment by Barry on 2006-11-27 08:28:10 -0500
Nicely done !!
I did much the same, but found quality dropped.
I would be keen to hear your experience on quality after a while.
Also I look forward to the faxing one, as I’m stuck there after having gone back to asterisk 1.2.13
Comment by Matt Gibson on 2006-11-27 16:03:31 -0500
Hi Barry,
No problem! Quality has been fine here so far, but I am using more ZAP than SIP or IAX extensions. Faxing should be coming along soon! 🙂
Matt
Comment by A Thomson on 2007-01-01 06:04:54 -0500
I didn’t do the full install, but i did use your startup script as i also compiled asterisk 1.4 from source.
Nicely written.
Thanks.
🙂
Comment by C. M. Mehl on 2008-06-18 15:13:15 -0500
Hi there,
came across your blog while doing a similar setup recently. Really useful.
I was doing the same setup, but with Debian etch. In order to get the asterisk add-ons, in particular cdr_addon_mysql.so installed, you need to do:
apt-get install libmysqlclient15-dev
And the areski CDR interface (which was the reason for me to set up all this) requires an additional mod:
apt-get install php5-gd
Anyway, thx for having posted your experiences and letting other users benefit from it 🙂 Feel free to add this mail as a comment, if you so want.
Cheers
Chris
Comment by Mimi on 2008-06-26 05:18:01 -0500
Hi Chris,
I am trying to install CDR interface, I installed asterisk-addons and libmysqlclient15-dev and created my table cdr, but still not have any recorded call in the table cdr.
I am in Debian and I am trying to create my own interface, in particular CDR intarface to get all the recording calls.
Would you help me plz.