You are on page 1of 10

You will be presented with a list of countries.

Once you’ve found your country and


highlighted it, press Enter .
You will then be asked if you would like to use the keyboard layout detector. If you
know which keyboard type you have, you can select No and then pick it from a list of
formats.
If you are utilizing the keyboard layout detector, you will be prompted to press a series
of keys. If you use the keyboard detector and it does not detect your keyboard correctly
(typical when installing into a virtual machine via a remote console), you can go back
and select from a list manually.
Once you’ve picked your keyboard, the installation will continue by attempting to set
up your network automatically. If all goes well, you will be prompted to enter a host-
name for your system. You can pick anything you want here, unless your network
requires your system to a have a specific hostname. Input it now and then press
Enter .
The installer will attempt to contact a Network Time Protocol (NTP) server to syn-
chronize your clock. Ubuntu will then try to autodetect your time zone and present
you with its choice. If correct, select Yes , otherwise, select No and you’ll be presented
with a list of time zones to select from. Select your time zone, or select from the world-
wide list if your time zone is not shown. Once you’ve selected your time zone, press
Enter to continue.
The installer will then ask you some questions about partitioning your system. Typically
the default is fine, which is to use the guided system, utilizing the entire disk, and to
set up the Logical Volume Manager (LVM). Press Enter once you’ve made your selec-
tion. Then you’ll be asked which partition to install to, which likely is the only one on
your system. Press Enter to continue, at which point you’ll be asked to confirm the
changes to the partition table. Select Yes and press Enter to continue.
You will now be asked how much space to use (the default value will be to use the
entire disk). Press Enter once you’ve entered and confirmed the amount of space you
want to use. The installer will then request one last confirmation before making the
changes to the disk. Select Yes to write the changes to disk. The installer will now
format the hard disk, write the partitioning scheme to disk, copy the files, and perform
the file installation.
When the file installation is complete, you’ll be asked to enter the Full name of the new
user, from which a username will be generated. The system will suggest a username,
but you are free to change the username to whatever you like.

Distribution Installation | 41
After entering your username, you’ll be asked to supply a password, and then asked to
confirm the password you’ve entered. Ubuntu does a good job of providing a secure
system by not providing direct access to root, but rather using the sudo application,
which allows you to run commands as root without being the root user. Enter a user-
name,# such as asteriskpbx, and a secure password to continue. You’ll use these to log
into the system once the installer ends. The installer will then ask you if you want to
encrypt your home directory. This is not necessary and will add CPU overhead.

The rest of the installation instructions will assume that asteriskpbx was
chosen as the username.

If your system is behind a web proxy, enter the proxy information now. If you’re not
behind a proxy, or don’t know if you are, simply press Enter .
You will then be asked if you want to install updates automatically. The default is to
perform no automatic updates, which is what we recommend. Should a system reboot
occur, an update to the kernel will render Asterisk nonstartable until you recompile
it* (which won’t make you popular). It is better practice to identify updates on a regular
basis and perform them manually in a controlled manner. Normally, you would want
to advise your users of the expected downtime and schedule the downtime to happen
after business hours (or while a redundant system is running). Select No automatic
updates and press Enter .
Since we’ll be installing our dependencies with apt-get, we only need to select one
package during the install: OpenSSH server. SSH is essential if you wish to perform
remote work on the system. However, if your local policy states that your server needs
to be managed directly, you may not want to install the OpenSSH server.

Pressing the Enter key will accept the current selections and move on
with the install. You need to use space bar to toggle your selections.

After you’ve selected OpenSSH server, press Enter .


If this is the only operating system on the machine (which it likely is), Ubuntu will give
you the option to install the GRUB bootloader on your system. It provides this prompt
in order to give you the option of skipping the GRUB installation, as it will modify the
master boot record (MBR) on your system. If there is another operating system it has

#Ubuntu has reserved the username asterisk internally.


* While we say Asterisk here, specifically it is DAHDI that is the problem. DAHDI is a set of Linux kernel
modules used with Asterisk.

42 | Chapter 3: Installing Asterisk


failed to detect that has information loaded into the MBR, it’s nice to be able to skip
modifying it. If this is the only operating system installed on your server, select Yes .
When the system has finished the install, you’ll be asked to remove any media in the
drives and to reboot the system by selecting Continue, at which point the installation
will be complete and the system will reboot.

Base system update


Now that we’ve completed installing Ubuntu Server, we need to perform a system
update with apt-get to make sure we have the latest packages installed. You’ll be pre-
sented with a login prompt where you’ll log in with the username and password you
created in the installer (e.g., asteriskpbx). Once logged in, run the following command:
$ sudo apt-get update
[sudo] password for asteriskpbx:
...
Reading package lists... Done

$ sudo apt-get upgrade


Reading state information... Done
...
Do you want to continue [Y/n]? y

The password that sudo wants is the password you just logged in with.

Press Enter when prompted to continue, at which point the latest package updates will
be installed. When complete, reboot the system for the changes to take effect as the
kernel has probably been updated.
$ sudo reboot

Congratulations! You’ve successfully installed and updated the base Ubuntu Server
system.

Enable NTP for accurate system time


Keeping accurate time is essential on your Asterisk system, both for maintaining accu-
rate call detail records as well as for synchronization with your other programs. You
don’t want the times of your voicemail notifications to be off by 10 or 20 minutes, as
this can lead to confusion and panic from those who might think their voicemail noti-
fication took too long to be delivered:
$ sudo apt-get install ntp

Distribution Installation | 43
The default on Ubuntu is to run a time sync server without ever changing the time on
your own machine. This won’t work for our needs, so we’ll need to change the
configuration file slightly. Because of this, we need to guide you through using a com-
mand line editor. The nano editor is already installed on your Ubuntu machine and is
remarkably easy to use†:
$ sudo nano /etc/ntp.conf

Your terminal will switch to full-screen output.


Use your arrow keys to move down to the section that looks like
# By default, exchange time with everybody, but don't allow configuration.
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery

Add two new lines after this section, to allow ntpd to synchronize your time with the
outside world, such that the above section now looks like
# By default, exchange time with everybody, but don't allow configuration.
restrict -4 default kod notrap nomodify nopeer noquery
restrict -6 default kod notrap nomodify nopeer noquery

restrict -4 127.0.0.1
restrict -6 ::1

That’s everything we need to change, so exit the editor by pressing Ctrl + X . When
prompted whether to save the modifications, press Y ; nano will additionally ask you
for the filename. Just hit Enter to confirm the default /etc/ntp.conf.
Now restart the NTP daemon:
$ sudo /etc/init.d/ntp restart

With the operating system installed, you’re ready to install the dependencies required
for Asterisk. The next section provides an in-depth review of the installation process.
If you’ve already reviewed the information in “Software Dependencies” on page 44,
you may want to refer back to “Installation Cheat Sheet” on page 31 for a high-level
review of how to install Asterisk.

Software Dependencies
The first thing you need to do once you’ve completed the installation of your operating
system is to install the software dependencies required by Asterisk. The commands
listed in Table 3-1 have been split into two columns, for Ubuntu Server and CentOS
Server. These packages will allow you to build a basic Asterisk system, along with
DAHDI and LibPRI. Not every module will be available at compile time with these

† If you’re already familiar with another editor, go ahead and use it. The nano editor has been selected for its
ease of use and its handy on-screen instructions. We even know a developer at Digium who uses it while
writing code for Asterisk, though most people tend to use more complex editors such as emacs or vim.

44 | Chapter 3: Installing Asterisk


dependencies; only the most commonly used modules will be built. If additional
dependencies are required for other modules used later in the book, instructions will
be provided as necessary.

Please be aware that the dependency information on CentOS 64-bit does


not take into account that 32-bit libraries should not be installed. If such
libraries are installed, you will end up with additional packages that use
disk space and can cause conflicts if the system attempts to compile
against a 32-bit library instead of its 64-bit counterpart. In order to re-
solve this problem, add .x86_64 to the end of each package name when
installing it. So, for example, instead of executing yum install ncurses-
devel, you will execute yum install ncurses-devel.x86_64. This is not
necessary on a 32-bit platform.

Table 3-1. Software dependencies for Asterisk on Ubuntu Server and CentOS Server
Ubuntu CentOS
sudo apt-get install build-essential \ sudo yum install gcc gcc-c++ make wget \
subversion libncurses5-dev libssl-dev \ subversion libxml2-devel ncurses-devel \
libxml2-dev vim-nox openssl-devel vim-enhanced

These packages will get you most of what you’ll need to get started with installing
Asterisk, DAHDI, and LibPRI. Note that you will also require the software dependen-
cies for each package that we indicate needs to be installed. These will be resolved
automatically for you when you use either yum or apt-get.
We have also included the OpenSSL development libraries, which are not strictly nec-
essary to compile Asterisk, but are good to have: they enable key support and other
encryption functionality.
We have installed vim as our editor, but you can choose anything you want, such as
nano, joe, or emacs.
Asterisk contains a script that will install the dependencies for all features in Asterisk.
At this time it is complete for Ubuntu but does not list all required packages for CentOS.
Once you have downloaded Asterisk using the instructions in “Downloading What
You Need” on page 46, use the following commands if you would like to run it:
$ cd ~/src/asterisk-complete/asterisk/1.8
$ sudo ./contrib/scripts/install_prereq install
$ sudo ./contrib/scripts/install_prereq install-unpackaged

Software Dependencies | 45
Third-Party Repositories
For certain software dependencies, a third-party repository may be necessary. This
appears to be most often the case when using CentOS. A couple of repositories that
seem to be able to provide all the extra dependencies required are RPMforge (http://dag
.wieers.com/rpm/) and EPEL (Extra Packages for Enterprise Linux, http://fedoraproject
.org/wiki/EPEL).
We may occasionally refer to these third-party repositories when they are required to
obtain a dependency for a module we are trying to build and use.

Downloading What You Need


There are several methods of getting Asterisk: via the Subversion code repository, via
wget from the downloads site, or via a package-management system such as apt-get or
yum. We’re only going to cover the first two methods, since we’re interested in building
the latest version of Asterisk from source. Typically, package-management systems will
have versions that are older than those available from Subversion or the downloads
site, and we want to make sure we have the most recent fixes available to us, so we tend
to avoid them.

The official packages from Digium do tend to stay up to date. There are
currently packages for CentOS/RHEL available at http://www.asterisk
.org/downloads/yum.

Before we start getting the source files, let’s create a directory structure to house the
downloaded code. We’re going to create the directory structure within the home di-
rectory for the asteriskpbx user on the system. Once everything is built, it will be in-
stalled with the sudo command. We’ll then go back and change the permissions and
ownership of the installed files in order to build a secure system. To begin, issue the
following command:
$ mkdir -p ~/src/asterisk-complete/asterisk

Now that we’ve created a directory structure to hold everything, let’s get the source
code. Choose one of the following two methods to get your files:
1. Subversion
2. wget

46 | Chapter 3: Installing Asterisk


Getting the Latest Version
Asterisk is a constantly evolving project, and there are many different versions of the
software that you can implement.
In Chapter 2, we talked about Asterisk versioning. The concept of how Asterisk is
versioned is important to understand because the versioning system for Asterisk has
undergone a few changes of methodology over the years. So, if you’re not up to speed
on Asterisk versioning, we strongly recommend that you go back and read “Asterisk
Versioning” on page 26.
Having said all that, in most cases all you need to do is grab the latest version from the
http://www.asterisk.org/downloads website. We will be installing and using Asterisk 1.8
throughout this book.

Getting the Source via Subversion


Subversion is a version control system that is used by developers to track changes to
code over a period of time. Each time the code is modified, it must first be checked out
of the repository; then it must be checked back in, at which point the changes are
logged. Thus, if a change creates a regression, the developers can go back to that change
and remove it if necessary. This is a powerful and robust system for development work.
It also happens to be useful for Asterisk administrators seeking to retrieve the software.
To download the source code to the latest version of Asterisk 1.8, use these commands:
$ cd ~/src/asterisk-complete/asterisk
$ svn co http://svn.asterisk.org/svn/asterisk/branches/1.8

You can now skip directly to “How to Install It” on page 48.

The preceding commands will retrieve the latest changes to the source
in that particular branch, which are changes that have been made after
the latest release. If you would prefer to use a released version, please
refer to the next section.

Getting the Source via wget


To obtain the latest released versions of DAHDI, LibPRI, and Asterisk using the wget
application, issue the following commands:
$ cd ~/src/asterisk-complete/asterisk
$ wget \
http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-1.8-current.tar.gz
$ tar zxvf asterisk-1.8-current.tar.gz

The next step is to compile and install the software, so onward to the next section.

Downloading What You Need | 47


How to Install It
With the source files downloaded you can compile the software and install it. The order
for installing is:
1. LibPRI‡
2. DAHDI§
3. Asterisk‖
Installing in this order ensures that any dependencies for DAHDI and Asterisk are
installed prior to running the configuration scripts, which will subsequently ensure that
any modules dependent on LibPRI or DAHDI will be built.
So, let’s get started.

LibPRI
LibPRI is a library that adds support for ISDN (PRI and BRI). The use of LibPRI is
optional, but since it takes very little time to install, doesn’t interfere with anything,
and will come in handy if you ever want to add cards to a system at a later point, we
recommend that you install it now.
Check out the latest version of LibPRI and compile it like so:
$ cd ~/src/asterisk-complete/
$ mkdir libpri
$ cd libpri/
$ svn co http://svn.asterisk.org/svn/libpri/tags/1.4.<your version number>
$ cd 1.4.<your version number>
$ make
$ sudo make install

You can also download the source via wget from http://downloads.aster
isk.org/pub/telephony/libpri/.

With LibPRI installed, we can now install DAHDI.

‡ Strictly speaking, if you are not going to be using any ISDN connections (BRI and PRI), you can install Asterisk
without LibPRI. However, we are going to install it for the sake of completeness.
§ This package contains the kernel drivers to allow Asterisk to connect to traditional PSTN circuits. It is also
required for the MeetMe() conferencing application. Again, we will install this for completeness.
‖ If you don’t install this, none of the examples in this book will work, but it could still make a great bathroom
reader. Just sayin’.

48 | Chapter 3: Installing Asterisk


DAHDI
The Digium Asterisk Hardware Device Interface, or DAHDI (formerly known as Zaptel),
is the software Asterisk uses to interface with telephony hardware. We recommend that
you install it even if you have no hardware installed, because DAHDI is a dependency
required for building the timing module res_timing_dahdi and is used for Asterisk
dialplan applications such as MeetMe().

DAHDI-tools and DAHDI-linux


DAHDI is actually a combination of two separate code bases: DAHDI-tools, which
provides various administrator tools such as dahdi_cfg, dahdi_scan, etc.; and DAHDI-
linux, which provides the kernel drivers. Unless you’re only updating one or the other,
you’ll be installing both at the same time, which is referred to as DAHDI-linux-com-
plete. The version numbering for DAHDI-linux-complete will look something like
2.4.0+2.4.0, where the number to the left of the plus sign is the version of DAHDI-
linux included, and the version number to the right of the plus sign is the DAHDI-
tools version included.
There are also FreeBSD drivers for DAHDI, which are maintained by the community.
These drivers are available at http://downloads.asterisk.org/pub/telephony/dahdi-freebsd
-complete/.

Another dependency is required for installing DAHDI, and that is the kernel source. It
is important that the kernel version being used match exactly that of the kernel source
being installed. You can use uname -a to verify the currently running kernel version:
• CentOS: sudo yum install kernel-devel-`uname -r`
• Ubuntu: sudo apt-get install linux-headers-`uname -r`
The use of uname -r surrounded by backticks (`) is for filling in the currently running
kernel version so the appropriate package is installed.
The following commands show how to install DAHDI-linux-complete 2.4.0+2.4.0.
There may be a newer version available by the time you are reading this, so check
downloads.asterisk.org first. If there is a newer version available, just replace the version
number in the commands:
$ cd ~/src/asterisk-complete/
$ mkdir dahdi
$ cd dahdi/
$ svn co http://svn.asterisk.org/svn/dahdi/linux-complete/tags/2.4.0+2.4.0
$ cd 2.4.0+2.4.0
$ make
$ sudo make install
$ sudo make config

How to Install It | 49
You will need to have Internet access when running the make all com-
mand, as it will attempt to download the latest hardware firmware from
the Digium servers.

After installing DAHDI, we can move on to installing Asterisk.

You can also download the source via wget from http://downloads.aster
isk.org/pub/telephony/dahdi-linux-complete/.

Asterisk
With both DAHDI and LibPRI installed, we can now install Asterisk:
$ cd ~/src/asterisk-complete/asterisk/1.8
$ ./configure
$ make
$ sudo make install
$ sudo make config

With the files now installed in their default locations, we need to modify the permis-
sions of the directories and their contents.

There is an additional step that is not strictly required, but is quite com-
mon (and arguably important): the make menuselect command, which
provides a graphical interface that allows detailed selection of which
modules and features will be compiled. We will discuss this in “make
menuselect” on page 59.

Setting File Permissions


In order to run our system more securely, we’ll be installing Asterisk and then running
it as the asteriskpbx user. After installing the files into their default locations, we need
to change the file permissions to match those of the user we’re going to be running as.
Execute the following commands after running make install (which we did previously):
$ sudo chown -R asteriskpbx:asteriskpbx /usr/lib/asterisk/
$ sudo chown -R asteriskpbx:asteriskpbx /var/lib/asterisk/
$ sudo chown -R asteriskpbx:asteriskpbx /var/spool/asterisk/
$ sudo chown -R asteriskpbx:asteriskpbx /var/log/asterisk/
$ sudo chown -R asteriskpbx:asteriskpbx /var/run/asterisk
$ sudo chown asteriskpbx:asteriskpbx /usr/sbin/asterisk

In order to use MeetMe() and DAHDI with Asterisk as non-root, you must change
the /etc/udev/rules.d/dahdi.rules so that the OWNER and GROUP fields match the non-root
user Asterisk will be running as. In this case, we’re using the asteriskpbx user.

50 | Chapter 3: Installing Asterisk

You might also like