Asterisk is a software-based Private_branch_exchange. It can be used to manage voice communications in a wide variety of ways. On a small scale, it can be used as a deluxe home answering machine, giving each person his/her own extension. On a larger scale, it can handle hundreds of simultaneous inbound and outbound calls, applying different rules to each call. This guide does not explain those more complex setups. It simply walks the reader thru a basic home use scenario (installation and configuration). It assumes the reader is using Linux. The process for other operating systems should be similar.
There are two main ways to install asterisk: from a pre-built package (the easy way), or from source code (the fun and more flexible way). I'll look at each option.
Some Linux distributions are repository-based. This means that programs are already compiled and waiting for you to select and download with your operating system's management tool. In Debian-based distributions (like Ubuntu), the
synaptic tool can be used on a graphical desktop. It allows you to search for Asterisk by name, and select it. When selecting it, a small dialog will appear asking you to confirm the installation of several other dependent packages. Click OK on that dialog, then click “Apply” on the main
Synaptic dialog. This will cause the installation to happen as desired. The image to the right shows Synaptic in use.
For those who prefer a command-line approach, the same distributions include the
apt-get tool. It performs the same actions without a graphical interface. The following command can be executed at the command line. (I'm using sudo so I can run a root-only command with my current user ID).
me@mymachine:~$ sudo apt-get install asterisk
Once either of the above commands completes, Asterisk will be installed on the operating system.
Installing Asterisk from source is a great way for new enthusiasts to understand how Linux software is built. And for more experienced users, its a great way to streamline Asterisk towards an intended use.
Linux software is normally built in the
/usr/src/ folder. So the first step is to download the Asterisk source and untar/unzip it in the right place.
cd /usr/src wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-1.4.25.tar.gz wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-addons-1.4.8.tar.gz wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-sounds-1.2.1.tar.gz tar xzvf asterisk-1.4.25.tar.gz tar xzvf asterisk-addons-1.4.8.tar.gz tar xzvf asterisk-sounds-1.2.1.tar.gz
This will produce three folders in the
/usr/src directory: one for asterisk, one for addons, and one for sounds. The projects need to be build in a certain sequence, as detailed here:
cd asterisk-1.4.25 ./configure make menuconfig <--optional, see text below make make install make samples make progdocs cd ..
make menuconfig step is too advanced to explain here. It lets you customize what parts of
asterisk are built, and whether they are statically or dynamically linked. I recommend skipping this step the first time around, and come back to it if you have unexplainable runtime problems later on.
Now asterisk should be built. Lets move on to the addons:
cd asterisk-addons-1.4.8 ./configure make make install make samples cd ..
And continue with the sounds:
cd asterisk-sounds-1.2.1 make make install cd ..
At this point, everything should be built. Start
asterisk with this command:
sudo /etc/init.d/asterisk start
We can check that
asterisk is running with this command:
ps aux | grep asterisk
If you see a process ID for
safe_asterisk, then everything is good. But if not, you need to check the logs to see what went wrong. Places to check (depending on your system configuration):
Look for the word
asterisk (or both) in the logs. Here are a few of my favorite techniques for searching the logs:
cat /var/log/asterisk/messages | grep -i errorshows lines from the asterisk log that contain the word
cat /var/log/messages | grep asteriskshows lines from the system log that contain the word
tail -n 100 /var/log/asterisk/messagesshows the last 100 lines from the asterisk log
tail -f /var/log/asterisk/messageswill cause the console to “follow” the log as new lines are added to it. This means you will need to open another console window to type commands since this one is not occupied. Press <cntl>-c to break out of the
Oh, and be sure to pay attention to the timestamps in the logs…no sense in solving an old problem.