Chapter 3. Installing Asterisk

I long to accomplish great and noble tasks, but it is my chief duty to accomplish humble tasks as though they were great and noble. The world is moved along, not only by the mighty shoves of its heroes, but also by the aggregate of the tiny pushes of each honest worker.

—Helen Keller

In the previous chapter, we discussed preparing a system to install Asterisk. Now it's time to obtain, extract, compile, and install the software.

Although a large number of Linux distributions and PC architectures are excellent candidates for Asterisk[44], we have chosen to focus on a single distribution in order to maintain brevity and clarity throughout the book. The instructions that follow have been made as generic as possible, but you will notice a leaning toward CentOS directory structure and system utilities. We have chosen to focus on CentOS because its command set, directory structure, and so forth are likely to be familiar to a larger percentage of readers (we have found that many Linux administrators are familiar with CentOS, even if they don't prefer it). This doesn't mean that CentOS is the only choice, or even the best one for you. A question that often appears on the mailing lists is: "Which distribution of Linux is the best to use with Asterisk?" The multitude of answers generally boils down to "the one you like the best." Arguably, the most popular distro for Asterisk is CentOS, which is a free distro based on Red Hat Enterprise Linux, so we have chosen it as our reference platform[45].

3.1. What Packages Do I Need?

Most Asterisk configurations are composed of three main packages : the main Asterisk program (asterisk), the Zapata telephony drivers (zaptel), and the PRI libraries (libpri). If you plan on a pure VoIP network, the only real requirement is the asterisk package, but we recommend installing all three packages; you can choose what modules to activate later. The zaptel drivers are required if you are using analog or digital hardware, or if you're using the ztdummy driver (discussed later in this chapter) as a timing source. The libpri library is optional unless you're using ISDN PRI interfaces, and you may save a small amount of RAM if you don't load it, but we recommend that it be installed in conjunction with the zaptel package for completeness.

In the previous version of this book, we recommended that you installed the additional asterisk-sounds package. This was a separate compressed archive that you would download, extract, and then install. As of Asterisk version 1.4.0, there are now two sets of sounds packages; the Core sounds package, and the Extra sounds package. Since Asterisk supports several different audio formats, these packages can be obtained in a number of different sound formats, such as G.729 and GSM. The reason for all the different formats is that Asterisk can use the sound format that requires the least amount of CPU transcode. For example, if you have a lot of connections coming in on VoIP channels that are running GSM, you would want to have GSM version of the sound files. You can select one or more sound prompt types in the menuselect screen (discussed later in this chapter). We recommend that you install at least one type of sounds file from both the Core Sounds Packages and Extras Sound Packages menu items. Since we may make use of some of the Extra sound files throughout this book, we will assume you have at least one of the formats installed.

3.1.1. Linux Package Requirements

To compile Asterisk, you must have the GCC compiler (Version 3.x or later) and its dependencies on your system. Asterisk also requires bison, a parser generator program that replaces yacc, and ncurses for CLI functionality. The cryptographic library in Asterisk requires OpenSSL and its development packages.

Zaptel requires libnewt and its development packages for the zttool program (see "Using ztcfg and zttool," below). If you're using PRI interfaces, Zaptel also requires the libpri package (again, even if you aren't using PRI circuits, we recommend that you install libpri along with zaptel).

If you install the Software Development packages in CentOS, you will have all of these tools. If you are looking to keep things trim, and wish to install the bare minimum to compile Asterisk and its related packages, the following table will prove useful.

Package name Installation command Note Used by
GCC 3.x yum install -y gcc Required to compile Zaptel, libpri, and Asterisk libpri, Zaptel, Asterisk
ncurses-devel yum install -y ncurses-devel Required by menuselect menuselect
libtermcap-devel yum install -y libtermcap-devel Required by Asterisk Asterisk
Kernel Development Headers yum install -y kernel-devel Required to compile Zaptel Zaptel
Kernel Development Headers (SMP) yum install -y kernel-smp-devel Required to compile Zaptel Zaptel
GCC C++ 3.x yum install -y gcc-c++ Required by Asterisk Asterisk
OpenSSL (optional) yum install -y openssl-devel Dependency of OSP, IAX2 encryption, res_crypto (RSA key support) Asterisk
newt-devel (optional) yum install -y newt-devel Dependency of zttool Zaptel
zlib-devel (optional) yum install -y zlib-devel Dependency of DUNDi Asterisk
unixODBC; unixODBC-devel (optional) yum install -y unixODBC-devel Dependency of func_odbc, cdr_odbc, res_config_odbc, res_odbc, ODBC_STORAGE Asterisk
libtool (optional; recommended) yum install -y libtool Dependency of ODBC related modules Asterisk
GNU make (version 3.80[a] or higher) yum install -y make Required to compile Zaptel and Asterisk Asterisk

[a] It is a common problem among new installs on some Linux distributions to see GNU make versions of 3.79 or lower. Note that Asterisk will no longer build correctly unless you have at least version 3.80 of GNU make.

Table 3.1. List of packages required to compile libpri, Zaptel, and Asterisk


[Note] Note

In the previous table, we utilize the -y switch to the yum application means to answer yes to all prompts, thus it will install the application and all dependencies without prompting you. If this is not what you want, omit the -y switch.

If you just want to install all of the above packages in one go, you can specify more than one package on the command line, e.g.

# yum install -y gcc ncurses-devel libtermcap-devel [...]



[44] And some non-Linux operating systems as well, such as Solaris, *BSD, and OS X. You should note that while people have managed to successfully run Asterisk on these alternative systems, Asterisk was, and continues to be, actively developed for Linux.

[45] We will be using CentOS Server 4.4 in this book, which we usually install with nothing except the Editors package selected. If you are not sure what distribution to choose, CentOS is an excellent choice. CentOS can be obtained from http://www.centos.org.