A.1. Installing Asterisk 1.4.x on Debian Linux 4.0 (Etch)

Following these instructions will install the components necessary to use all the features covered in this book (except where otherwise indicated). As a result, it is a little more comprehensive than a typical installation but offers the advantage that you won't have to install additional components in future.
We assume a freshly installed Debian GNU/Linux 4.0 (a.k.a Etch). You can obtain an ISO image for the net-based install of x86 Debian Linux at http://www.debian.org/releases/etch/debian-installer/. A Debian GNU/Linux installation manual may be found at http://www.debian.org/releases/etch/i386/.
Before starting, please log in as root.

Note

For the sake of brevity, verbose output has been trimmed. Editorial omissions are indicated with [...].
Update the Debian package listing with apt-get update:
debian:~# apt-get update
Ign cdrom://[Debian GNU/Linux 4.0 r0 _Etch_ - Official i386 NETINST Binary-1 20070407-11:29] etch Release.gpg
Ign cdrom://[Debian GNU/Linux 4.0 r0 _Etch_ - Official i386 NETINST Binary-1 20070407-11:29] etch Release
Ign cdrom://[Debian GNU/Linux 4.0 r0 _Etch_ - Official i386 NETINST Binary-1 20070407-11:29] etch/contrib Packages/DiffIndex
Ign cdrom://[Debian GNU/Linux 4.0 r0 _Etch_ - Official i386 NETINST Binary-1 20070407-11:29] etch/main Packages/DiffIndex
Get:1 http://security.debian.org etch/updates Release.gpg [189B]      
Get:2 http://ftp.debian.org etch Release.gpg [378B]   
Hit http://security.debian.org etch/updates Release
Hit http://ftp.debian.org etch Release        
Ign http://security.debian.org etch/updates/main Packages/DiffIndex
Ign http://ftp.debian.org etch/main Packages/DiffIndex
Ign http://security.debian.org etch/updates/contrib Packages/DiffIndex
Ign http://security.debian.org etch/updates/main Sources/DiffIndex
Ign http://ftp.debian.org etch/main Sources/DiffIndex
Ign http://security.debian.org etch/updates/contrib Sources/DiffIndex
Hit http://security.debian.org etch/updates/main Packages
Hit http://ftp.debian.org etch/main Packages   
Hit http://security.debian.org etch/updates/contrib Packages
Hit http://ftp.debian.org etch/main Sources    
Hit http://security.debian.org etch/updates/main Sources
Hit http://security.debian.org etch/updates/contrib Sources
Fetched 2B in 1s (1B/s)  
Reading package lists... Done
debian:~# 
Now update all the currently installed packages with apt-get -y upgrade:
debian:~# apt-get -y upgrade
Reading package lists... Done
Building dependency tree... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
debian:~# 
Just for the case the the upgrade installed a new kernel we have to reboot the system with shutdown -r now
debian:~# shutdown -r now

Broadcast message from root@debian (pts/0) (Fri May  4 19:43:09 2007):

The system is going down for reboot NOW!
After the reboot we have to login again as root.
A few more packages are needed to satisfy Asterisk build dependencies. Do apt-get -y install build-essential libncurses5-dev libcurl3-dev libvorbis-dev libspeex-dev unixodbc unixodbc-dev libiksemel-dev linux-headers-`uname -r`.
debian:~# apt-get -y install build-essential libncurses5-dev libcurl3-dev libvorbis-dev libspeex-dev unixodbc unixodbc-dev libiksemel-dev linux-headers-`uname -r`
Reading package lists... Done
Building dependency tree... Done
The following extra packages will be installed:
  binutils ca-certificates comerr-dev cpp cpp-4.1 defoma dpkg-dev fontconfig
  fontconfig-config g++ g++-4.1 gcc gcc-4.1 libaudio2 libc6-dev libcurl3
  libcurl3-openssl-dev libexpat1 libfontconfig1 libfreetype6 libice6
  libidn11-dev libiksemel3 libjpeg62 libkadm55 libkrb5-dev liblcms1 libltdl3
  libltdl3-dev libmng1 libodbcinstq1c2 libogg-dev libogg0 libpng12-0 libqt3-mt
  libsm6 libspeex1 libssl-dev libssp0 libstdc++6-4.1-dev libvorbis0a
  libvorbisenc2 libvorbisfile3 libx11-6 libx11-data libxau6 libxcursor1
  libxdmcp6 libxext6 libxfixes3 libxft2 libxi6 libxinerama1 libxrandr2
  libxrender1 libxt6 linux-headers-2.6.18-4 linux-kbuild-2.6.18
  linux-kernel-headers make odbcinst1debian1 openssl pkg-config ttf-dejavu
  x11-common zlib1g-dev
Suggested packages:
  binutils-doc doc-base cpp-doc gcc-4.1-locales defoma-doc psfontmgr
  x-ttcidfont-conf dfontmgr debian-keyring gcc-4.1-doc lib64stdc++6
  manpages-dev autoconf automake1.9 libtool flex bison gdb gcc-doc
  libc6-dev-amd64 lib64gcc1 lib64ssp0 nas glibc-doc libcurl3-dbg
  libfreetype6-dev krb5-doc liblcms-utils libtool-doc libqt3-mt-psql
  libqt3-mt-mysql libqt3-mt-odbc speex libstdc++6-4.1-doc make-doc-non-dfsg
  libgnome-dev libmyodbc odbc-postgresql libct1 libqt3-mt-dev
Recommended packages:
  libft-perl bzip2 libmudflap0-dev libgl1-mesa-glx libgl1 libglu1-mesa libglu1
  libxmu6
The following NEW packages will be installed:
  binutils build-essential ca-certificates comerr-dev cpp cpp-4.1 defoma
  dpkg-dev fontconfig fontconfig-config g++ g++-4.1 gcc gcc-4.1 libaudio2
  libc6-dev libcurl3 libcurl3-dev libcurl3-openssl-dev libexpat1
  libfontconfig1 libfreetype6 libice6 libidn11-dev libiksemel-dev libiksemel3
  libjpeg62 libkadm55 libkrb5-dev liblcms1 libltdl3 libltdl3-dev libmng1
  libncurses5-dev libodbcinstq1c2 libogg-dev libogg0 libpng12-0 libqt3-mt
  libsm6 libspeex-dev libspeex1 libssl-dev libssp0 libstdc++6-4.1-dev
  libvorbis-dev libvorbis0a libvorbisenc2 libvorbisfile3 libx11-6 libx11-data
  libxau6 libxcursor1 libxdmcp6 libxext6 libxfixes3 libxft2 libxi6
  libxinerama1 libxrandr2 libxrender1 libxt6 linux-headers-2.6.18-4
  linux-headers-2.6.18-4-686 linux-kbuild-2.6.18 linux-kernel-headers make
  odbcinst1debian1 openssl pkg-config ttf-dejavu unixodbc unixodbc-dev
  x11-common zlib1g-dev
0 upgraded, 75 newly installed, 0 to remove and 0 not upgraded.
Need to get 23.1MB/38.1MB of archives.
After unpacking 137MB of additional disk space will be used.
Get:1 http://ftp.debian.org etch/main libice6 1:1.0.1-2 [42.6kB]
Get:2 http://ftp.debian.org etch/main libsm6 1:1.0.1-3 [18.0kB]

[...]

Setting up libvorbis-dev (1.1.2.dfsg-1.2) ...
Setting up linux-headers-2.6.18-4 (2.6.18.dfsg.1-12) ...
Setting up linux-kbuild-2.6.18 (2.6.18-1) ...
Setting up linux-headers-2.6.18-4-686 (2.6.18.dfsg.1-12) ...
Setting up unixodbc-dev (2.2.11-13) ...
Setting up libstdc++6-4.1-dev (4.1.1-21) ...
Setting up g++-4.1 (4.1.1-21) ...
Setting up g++ (4.1.1-15) ...

Setting up build-essential (11.3) ...
debian:~# 
Now change into the /usr/src directory with cd /usr/src:
debian:~# cd /usr/src
debian:/usr/src#
Find the Asterisk sources you need at the official homepage: http://www.asterisk.org/. Take care to use only a stable, current version and not a development version. Download it to /usr/src with wget http://downloads.digium.com/pub/asterisk/asterisk-1.4-current.tar.gz:
debian:/usr/src# wget http://downloads.digium.com/pub/asterisk/asterisk-1.4-current.tar.gz
--13:03:47--  http://downloads.digium.com/pub/asterisk/asterisk-1.4-current.tar.gz
           => `asterisk-1.4-current.tar.gz'
Resolving downloads.digium.com... 216.27.40.102, 69.16.138.164
Connecting to downloads.digium.com|216.27.40.102|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 17,081,631 (16M) [application/x-gzip]

100%[====================================>] 17,081,631   263.92K/s    ETA 00:00

13:04:56 (244.60 KB/s) - `asterisk-1.4-current.tar.gz' saved [17081631/17081631]

debian:/usr/src#
You will need the current Zaptel drivers as well. Get them with wget http://downloads.digium.com/pub/zaptel/zaptel-1.4-current.tar.gz:
debian:/usr/src# wget http://downloads.digium.com/pub/zaptel/zaptel-1.4-current.tar.gz
--13:06:49--  http://downloads.digium.com/pub/zaptel/zaptel-1.4-current.tar.gz
           => `zaptel-1.4-current.tar.gz'
Resolving downloads.digium.com... 216.27.40.102, 69.16.138.164
Connecting to downloads.digium.com|216.27.40.102|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2,839,262 (2.7M) [application/x-gzip]

100%[====================================>] 2,839,262    263.92K/s    ETA 00:00

13:06:59 (260.09 KB/s) - `zaptel-1.4-current.tar.gz' saved [2839262/2839262]

debian:/usr/src#
Unpack the compressed tar archives with tar xvzf asterisk-1.4-current.tar.gz && tar xvzf zaptel-1.4-current.tar.gz:
debian:/usr/src# tar xvzf asterisk-1.4-current.tar.gz && tar xvzf zaptel-1.4-current.tar.gz
asterisk-1.4.2/
asterisk-1.4.2/build_tools/
asterisk-1.4.2/build_tools/menuselect-deps.in
asterisk-1.4.2/build_tools/get_moduleinfo
asterisk-1.4.2/build_tools/mkpkgconfig
asterisk-1.4.2/build_tools/embed_modules.xml
asterisk-1.4.2/build_tools/get_makeopts
asterisk-1.4.2/build_tools/make_version

[...]

zaptel-1.4.1/timertest.c
zaptel-1.4.1/mec3-float.h
zaptel-1.4.1/zaptel.init
zaptel-1.4.1/hdlcverify.c
zaptel-1.4.1/fxstest.c
zaptel-1.4.1/zaptel-base.c
debian:/usr/src#  

Important

Asterisk is a very dynamic project; as such, the version numbers in the examples depicted below will increase frequently and over time. Documentation is by its nature static and it is not always possible to keep version numbers current. We ask that you keep this in mind and notify us of changes.
We build the Zaptel drivers first. Change into the Zaptel directory with cd zaptel-1.4.1 and build it with ./configure && make && make install:
debian:/usr/src# cd zaptel-1.4.1
debian:/usr/src/zaptel-1.4.1# ./configure && make && make install
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o

[...]

/usr/bin/install -c -m 644 doc/zttool.8 /usr/share/man/man8
[ `id -u` = 0 ] && /sbin/depmod -a 2.6.18-4-686 || :
[ -f /etc/zaptel.conf ] || /usr/bin/install -c -D -m 644 zaptel.conf.sample /etc/zaptel.conf
build_tools/genmodconf linux26 "" "pciradio tor2 torisa wcfxo wct1xxp wctdm wctdm24xxp wcte11xp wcusb ztd-eth ztd-loc wcte12xp wct4xxp wctc4xxp wcfxs wctdm8xxp wct2xxp"
Building /etc/modprobe.d/zaptel...
***
*** WARNING:
*** If you had custom settings in /etc/modprobe.d/zaptel,
*** they have been moved to /etc/modprobe.d/zaptel.bak.
***
*** In the future, do not edit /etc/modprobe.d/zaptel, but
*** instead put your changes in another file
*** in the same directory so that they will not
*** be overwritten by future Zaptel updates.
***
debian:/usr/src/zaptel-1.4.1#
Asterisk MeetMe conferences require a timing source. In the absence of a hardware timing source, we use the software timing source contained in the ztdummy kernel module. Load the module with modprobe ztdummy:
debian:/usr/src/zaptel-1.4.1# modprobe ztdummy
debian:/usr/src/zaptel-1.4.1#
Now we can build Asterisk. Enter the Asterisk source directory with cd /usr/src/asterisk-1.4.2 and build it with ./configure && make && make install:
debian:/usr/src/zaptel-1.4.1# cd /usr/src/asterisk-1.4.2
debian:/usr/src/asterisk-1.4.2# ./configure && make && make install
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes

[...]

for x in ; do /usr/bin/install -c -m 755 $x /usr/lib/asterisk/modules ; done
make[1]: Leaving directory `/usr/src/asterisk-1.4.2/main'
 +---- Asterisk Installation Complete -------+
 +                                           +
 +    YOU MUST READ THE SECURITY DOCUMENT    +
 +                                           +
 + Asterisk has successfully been installed. +
 + If you would like to install the sample   +
 + configuration files (overwriting any      +
 + existing config files), run:              +
 +                                           +
 +               make samples                +
 +                                           +
 +-----------------  or ---------------------+
 +                                           +
 + You can go ahead and install the asterisk +
 + program documentation now or later run:   +
 +                                           +
 +              make progdocs                +
 +                                           +
 + **Note** This requires that you have      +
 + doxygen installed on your local system    +
 +-------------------------------------------+
debian:/usr/src/asterisk-1.4.2#
Asterisk is now installed, but we're not finished yet. Essential configuration files in /etc/asterisk do not yet exist. Rather than start from scratch, we install a set of sample configuration files with make samples:
debian:/usr/src/asterisk-1.4.2# make samples
mkdir -p /etc/asterisk
for x in configs/*.adsi; do \
        if [ ! -f /etc/asterisk/$x ]; then \
                /usr/bin/install -c -m 644 $x /etc/asterisk/`/usr/bin/basename $x` ; \
        fi ; \

[...]

for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isonphone; do \
        cat /var/lib/asterisk/sounds/$x.gsm >> /var/spool/asterisk/voicemail/default/1234/busy.gsm ; \
done
debian:/usr/src/asterisk-1.4.2# 
Done! Asterisk is ready to go! Check the installed version with asterisk -V (uppercase V):
debian:/usr/src/asterisk-1.4.2# asterisk -V
Asterisk 1.4.2
debian:/usr/src/asterisk-1.4.2# 

Start-up and shutdown scripts

To make sure that Asterisk starts automatically at boot time and shuts down cleanly during shutdown or reboot, we need init scripts. Install them from the /usr/src/asterisk-1.4.2 directory with make config:
debian:/usr/src/asterisk-1.4.2# make config
 Adding system startup for /etc/init.d/asterisk ...
   /etc/rc2.d/K91asterisk -> ../init.d/asterisk
   /etc/rc3.d/K91asterisk -> ../init.d/asterisk
   /etc/rc4.d/K91asterisk -> ../init.d/asterisk
   /etc/rc5.d/K91asterisk -> ../init.d/asterisk
   /etc/rc2.d/S10asterisk -> ../init.d/asterisk
   /etc/rc3.d/S10asterisk -> ../init.d/asterisk
   /etc/rc4.d/S10asterisk -> ../init.d/asterisk
   /etc/rc5.d/S10asterisk -> ../init.d/asterisk
debian:/usr/src/asterisk-1.4.2#
The ztdummy kernel module must also start at boot time; add it to /etc/modules with echo "ztdummy" >> /etc/modules:
debian:/usr/src/asterisk-1.4.2# echo "ztdummy" >> /etc/modules
debian:/usr/src/asterisk-1.4.2#