Professional Documents
Culture Documents
User, From Which A Username Will Be Generated. The System Will Suggest A Username
User, From Which A Username Will Be Generated. The System Will Suggest A Username
User, From Which A Username Will Be Generated. The System Will Suggest A Username
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.
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.
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
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.
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.
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
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.
The next step is to compile and install the software, so onward to the next section.
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/.
‡ 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’.
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.
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.
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.