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!


  • 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 :

  1. 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.

  2. I then entered the /opt directory and created my asterisk directory.

     # cd /opt
     # mkdir asterisk
  3. 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
  4. 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)
  5. Since I will be using SpanDSP I got it Installed as well

     # echo "media-libs/spandsp ~x86" >> /etc/portage/package.keywords
     # emerge -uvD spandsp
  6. 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)
  7. Next I enabled the modules I would be needing:

     # modprobe zaptel
     # modprobe ztdummy
  8. Now we must create some init scripts to start asterisk on reboot of the machine if that ever happens. Unlikely, but possible.

  9. Then I added my own /etc/init.d/ since we won’t be using the portage tree for asterisk

     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
     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
     echo ""
     echo -n "Running ztcfg: "
     /sbin/ztcfg -vv
     echo -n "OK"
     eend $? "Failed to start Zaptel"
     stop() {
     ebegin "Stopping Zaptel"
     for x in $MODULES; do
     rmmod ${x}
     rmmod zaptel
     eend $? "Failed to stop Asterisk"
  10. Then I added my own /etc/init.d/asterisk script since we won’t be using portage, just like zaptel.

    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"
  11. Then I added the user and group asterisk

    # groupadd asterisk
    # adduser -d /var/run/asterisk -g asterisk -m -s /sbin/nologin asterisk
  12. 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

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
  1. Then I created /var/run/asterisk and owned it to asterisk:asterisk

    # mkdir /var/run/asterisk
    # chown asterisk:asterisk /var/run/asterisk
  2. 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
  1. 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
  2. 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 
  3. Then I configured phpmyadmin

    # mysql -u root -p </usr/share/webapps/phpmyadmin/
  4. 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 
  5. Then I started apache + added it to default runlevel

    # rc-update add apache default
    # rc-update add mysql default
  6. Then I changed apache to run as asterisk:asterisk

    # nano /etc/apache/httpd.conf
    User asterisk
    Group asterisk
  7. 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
  8. Next I modified the /etc/asterisk/http.conf to the following:

  9. Next I modified manager.conf and changed the following:

    enabled = yes
    webenabled = yes
    bindaddr =
  10. Next, I added this to the manager.conf:

    secret = admin
    read = system,call,log,verbose,command,agent,user,config
    write = system,call,log,verbose,command,agent,user,config
  11. Then I started asterisk up with debugging to see any warnings or errors

    # asterisk -vvvvvvvvvvvvvvgc
  12. I had a few warnings about empty contexts in extensions.ael, I simply commented them out.

  13. 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
  14. 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 "
  15. Now, you must configure Asterisk to use this new database for callerid logging

    # nano /etc/asterisk/cdr_mysql.conf 
  16. Next, you can install Areski’s CallerID tool to view these records. Installation instructions are included in his file.

  17. 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.

  18. 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.


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! 🙂


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.



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.


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.