Installing Asterisk
Module 3
Module Goals: Learn about Asterisk version numbers and how Asterisk releases work Talk about various ways of installing Asterisk Learn to download, compile, and install Asterisk and related components from source code Learn the various methods of starting and stopping Asterisk Learn to connect with the Asterisk commandline interface Learn how to set Asterisk to automatically start when Linux boots
Copyright 2009 Digium, Inc.
Source Code Control
Asterisk developers use a source code control tool known as Subversion This allows them to keep track of the source code
who, when, where, and why
Subversion uses a model of a trunk and branches Different release versions of Asterisk are branches on the development tree
Copyright 2009 Digium, Inc.
Asterisk Development Tree
TRUNK
1.6.2 Branch 1.6.1 Branch
1.6.0 Branch
Copyright 2009 Digium, Inc.
Versions & Releases
Development version (trunk):
This is where new features are added Changes daily, always in a state of flux
Release versions:
For use in production environments Asterisk 1.6.2 is current release branch Bug fixes are the only changes that happen in release branches. Any new features are added to trunk.
Copyright 2009 Digium, Inc.
Asterisk Components
libpri
PRI ISDN library for T1/E1/J1 interfaces Really only needed for PRI connections, but usually installed for completeness
DAHDI
Kernel drivers for analog and digital cards Also provides system timing in the absence of a hardware card
Asterisk
source code of Asterisk itself
Copyright 2009 Digium, Inc.
Asterisk Sound Prompts
Sound prompts by Allison Smith, the voice of Asterisk Over 1,000 words and phrases, many of which where donated by the community Including phrases like:
Please enter the extension of the person you'd like to reach Will you marry me? Press 1 for yes or 2 for no. To dial by name, press... Weasels have eaten our phone system
You can choose which sound packages to install
Copyright 2009 Digium, Inc.
Getting ready to install Asterisk
Make sure your system is ready to install Asterisk You'll need the GCC compiler System Libraries and Applications
OpenSSL and its development libraries ncurses and ncurses-devel (for the CLI) Zlib (compression library) newt and newt-devel libraries (for DAHDI utilities)
Other considerations:
Curl (for allowing Asterisk to interact with web sites) Sendmail or Postfix (for sending voicemail to your email)
Copyright 2009 Digium, Inc.
Ways of Installing Asterisk
From packages
Packages make installation easy, and help with dependency resolution, and are available for most major Linux distributions
From source
More complicated than installing from packages, but gives you complete control of which modules are included We'll install from source in the next lab
As part of an Asterisk-based distribution
There are many Linux distributions built around Asterisk, which take care of installing Linux, Asterisk, and other tools all at once
Copyright 2009 Digium, Inc.
How to get the Source Code
Two methods:
HTTP
http://downloads.digium.com/pub/telephony/ Gives you a file browser with all dowloadable files Current releases, as well as past releases in the old-releases or releases subdirectories
SVN
Point the Subversion utility at http://svn.digium.com/svn/ View the web interface at http://svn.digium.com/view/ any version or revision or branch, including developer branches
Copyright 2009 Digium, Inc.
10
What Source Code to Get
libpri-1.4.X.Y.tar.gz dahdi-linux-complete-2.X.Y.tar.gz asterisk-1.6.X.Y.tar.gz (replace the .X.Y with the current version)
Copyright 2009 Digium, Inc.
11
Compile the Code
Compile in the following order:
libpri, DAHDI, then Asterisk
Compiling will follow the following steps:
Extract the source code Run the configure script
This will check your system for any missing items
Run the menuselect script
This allows you to choose which modules to compile, and which other options to set
Compile the code Install the program Install any sample files or initscripts (if necessary)
Copyright 2009 Digium, Inc.
12
Extracting the source code If you get the code via HTTP you will be downloading tarballs
.tar.gz or .tgz files are called tarballs They're similar to zip files
To extract the source code from the tarball:
Don't forget to replace the X with the current version
tar -zxvf libpri-1.4.X.tar.gz tar -zxvf dahdi-linux-complete-2.X.tar.gz tar -zxvf asterisk-1.6.X.tar.gz
Each tarball will create a directory with the source code inside that directory
Copyright 2009 Digium, Inc.
13
Steps for compiling
Most of the components follow this same format:
# # # # # # # # tar -zxvf tarball.tar.gz cd directory ./configure (not needed for libpri) make menuselect (not needed for libpri) make make install make samples (only needed for asterisk) make config (not needed for libpri)
Copyright 2009 Digium, Inc.
14
Requirements: Missing Items
If youre missing a vital system library, the build system will complain Some modules may depend on libraries you're missing from your system You can always install the missing library and then recompile, and the build system will adjust accordingly
Copyright 2009 Digium, Inc.
15
Asterisk Files and Directories /usr/sbin/asterisk
The Asterisk binary
/etc/asterisk/
contains the Asterisk configuration files
/usr/lib/asterisk/modules/
has the Asterisk loadable modules
/var/lib/asterisk/sounds/
Asterisk sound prompts
/var/lib/asterisk/moh/
Contains hold music Asterisk comes with hold music under license from Freeplay Music Corporation for use in conjunction with Asterisk only.
Copyright 2009 Digium, Inc.
16
What you get: Asterisk
/var/lib/asterisk/
The AstDB database
/var/spool/asterisk/
call information as well as voicemail and user greetings
/var/log/asterisk/
Asterisk logs
/var/log/asterisk/cdr-csv/
Call Detail Records in comma-separated value format
Copyright 2009 Digium, Inc.
17
Starting Asterisk & DAHDI on Boot
Initialization scripts are installed if you do the make config On CentOS, simply type:
service dahdi start|stop|restart service asterisk start|stop|restart
You will be using these commands to stop and start Asterisk during some of the labs in this course Always start DAHDI before Asterisk, and always stop Asterisk before DAHDI
Copyright 2009 Digium, Inc.
18
Starting Asterisk Manually Starting the daemon directly:
# /usr/sbin/asterisk Runs as a daemon in the background
Start in console mode
# asterisk -c normally used only for debugging startup problems
Using Linux startup scripts:
# service asterisk start
Automatically restarts if it fails:
# safe_asterisk Note that the initscripts run Asterisk from the safe_asterisk script so that Asterisk will automatically restart on most error conditions
Copyright 2009 Digium, Inc.
19
Connecting to Asterisk's CLI When Asterisk is already running, you must connect to the CLI to issue commands To connect to the Asterisk CLI: # asterisk -vvvr The -r is the option which actually connects to the CLI. Typing -vvvr is a good habit to get into, because it ensures that the verbosity level is at least 3 You will get an Asterisk CLI prompt CLI>
Copyright 2009 Digium, Inc.
20
Starting Asterisk: Other Options
# /usr/sbin/asterisk -h -r -c
List all options.
Re-connect to the running daemon Start in console mode instead of as a daemon
-v
Set the verbosity level
-d
Set the debug level
-rx restart now
Execute the restart now command
Copyright 2009 Digium, Inc.
21
Common CLI> Commands help quit core stop now core set verbose 5
Almost the same as # asterisk -rvvvvv
core set debug 5
Almost the same as # asterisk -rddddd
!
spawn to the Unix shell. Use CTRL-D or exit to return to the Asterisk CLI
! unix command
execute a single Unix shell command and return to the Asterisk CLI
22
Copyright 2009 Digium, Inc.
Help
From the CLI> prompt try:
help help core stop core show applications core show application dial core show functions core show function LEN ! ls
Copyright 2009 Digium, Inc.
23
Module 3 Recap:
Asterisk version numbers and releases Requirements for installing Asterisk Compiling libpri, DAHDI, Asterisk Starting Asterisk Connecting to the Asterisk CLI Getting help from the CLI
Copyright 2009 Digium, Inc.
24
Installing Asterisk
Now we're going to do our first Asterisk lab
Installing LibPRI, DAHDI, and Asterisk
This is discovery learning
You might be seeing some things for the first time Be sure to read all the text, not just type the commands Ask the trainer, or discuss with other participants
We will review after you have Asterisk up and running
Copyright 2009 Digium, Inc.
25
Installing LibOpenR2 (depois de DAHDI)
# cd /usr/src Descargar con wget DAHDI Complete 2.4.1.2+2.4.1 Source Tarball de sitio de asterisk, descomprimir, ingresar al directorio y ejecutarlo con make y make install. Lo mismo para libpri. LibPRI 1.4.11.5 Source Tarball # wget http://openr2.googlecode.com/files/openr21.3.0.tar.gz
# # # # #
tar -zxvf openr2-1.3.0.tar.gz cd openr2-1.3.0 ./configure -prefix=/usr make make install
Copyright 2009 Digium, Inc.
26
Lab: Installing Asterisk Lab
Lab 3-1: Installing Asterisk Time Limit: 40 Minutes Requirements:
Linux installed on your workstation Connection to the training network
Copyright 2009 Digium, Inc.
27