How to build and customize your own PBX with Asterisk

A very interesting guide to build your very own PBX system and with the lowest cost.

Article Source


This article demonstrates how easy it is to roll your own PBX in about an hour or two. Provided that the instructions herein are followed carefully, you too should be able to set up your very own switchboard/PBX system and all for the cost of the target hardware of your choice.

What is a PBX and why set one up?
A PBX or “Private Branch Exchange” is like a miniature phone company/switch in your own office/house. The PBX is responsible for making sure calls are routed properly. Situation: when Joe wants to dial Suzy in the office down the hall or downstairs in the TV room, he just picks up the phone in his room/office and dials a local extension just a few digits long. If he wants to call someone across town or around the world, he dials an “outside line” prefix (usually a 9) plus the desired number and the PBX routes his call to the PSTN (Public Switched Telephone Network) just like any other dialed call. Also, if Joe has four teenaged kids, instead of answering their calls and acting as the house receptionist, he can just setup a menu that allows callers to dial the person they want and then needs not be disturbed.

Most people are familiar with PBXs because they’ve used them in an office environment, but what if you wanted to use one in your house? Enter Asterisk.

The beauty of Asterisk ( is that it is free and offers all this functionality right out of the box. Asterisk is a software implementation of a hardware PBX and can run on a variety of hardware platforms. The features and benefits of owning an Asterisk PBX are numerous, and seemingly only limited by the imagination of the person who sets up and uses an Asterisk PBX. Listed on the project page are just some of the many features that can be implemented. I encourage anyone to explore these features as it will give you some idea for setting up your system in a way that makes it more than worth your while.

Prepare for setting up your PBX
There are many ways of setting up an Asterisk PBX, with some being easier than others. The easiest manner in which to set up a fully functional Asterisk PBX is to download and install a precompiled/tuned distribution such as Trixbox, PBX in a flash, Asterisk NOW, etc. Just take your pick of those. These are great if you don’t care to learn about how your PBX operates or need to do a mindless “click and drool” install. The problem with precompiled asterisk distributions is, while they are simple, they are not as flexible and extensible as a home-brewed Asterisk installation from the source code. When you install one of these “distros”, it is quite often that important decisions are already made for you, and you must work within the framework of the distribution to keep the box “happy”. When you roll your own Asterisk from the sources, you get more say in what goes into the build and how it is customized/extended at the expense of a slightly more complicated planning and installation process. However, it’s not as hard as you might think and it’s quite worth it in the end to “roll your own”.

Asterisk installed from the source code enables you to pick your choice of underlying OS (Debian, Ubuntu, Fedora, Mandrake, SuSE, etc) and also fine tune the installation for your OS environment and your hardware for best possible performance. In this article I will cover the steps needed to install Asterisk for the Ubuntu Linux operating system. This article assumes you know how to do a minimal command line only base system install of Ubuntu Linux. You certainly don’t want to run a GUI on your Asterisk box as it would consume unnecessary resources.

Step 1: prepare a minimal Ubuntu machine, wiht a command line only install

Step 2: download source packages
After you’ve prepared your minimal Ubuntu machine, you will need to download a few source packages from Digium (the maker of Asterisk). Please perform the following steps on your command line as the root user. (NOTE: on Ubuntu systems, the root account password needs to be set in order to login as root) To set your root password, log in as your regular user account you created during installation and type the following commands:

sudo passwd root

when asked for your password enter your regular USER password, hit ENTER, followed by the desired root password and then hit ENTER, confirm the desired password once more and then you’re done.

Logged in as the root user we’ll download the needed packages by running the following script in your terminal screen. If you are familiar with Putty, you can also do this remotely via a windows desktop or SSH into the box as root from any other Linux/Mac machine.


NOTE: we will be using Asterisk 1.4 NOT 1.6 as 1.6 is the unstable release.

Source packages needed from Digium:


I have written a script file to simplify the process on an Ubuntu 8.04 system. Copy and paste the following code into a new file in a terminal window and save the file as “”. Then when you save the file, make it executable by running this command: chmod +x

######## Prepare Build Environment

apt-get install build-essential speex libspeex-dev gsm-utils \
libgsm1-dev libgsmme-dev libgsm1 libgsm-tools \
libncurses5-dev ncurses-term linux-headers-2.6.24-19-generic \
libncurses5-dbg doxygen subversion

######## Download Digium (Asterisk) Source Packages

svn co asterisk-gui

######## Extract all packages for building

tar -zxvf asterisk- && tar -zxvf zaptel-1.4.11.tar.gz \
&& tar -zxvf asterisk-addons-1.4.7.tar.gz && tar -zxvf libpri-1.4.5.tar.gz

######## Begin Building and Installing Source Packages

cd libpri-1.4.5
make install
cd ../zaptel-1.4.11
make clean
make menuselect
make install
make config
cd ../asterisk-
make clean
make menuselect
make install
make samples
make progdocs
cd ../asterisk-addons-1.4.7
make clean
make menuselect
make install
make samples
cd ../asterisk-gui
make install
make samples
cd /root
mkdir packages
mv *.gz /root/packages/.


One final step remains in order to bring the GUI up and running. We must edit two files:

/etc/asterisk/http.conf and


enablestatic=yes ; without this, you can only send AMI commands, not display
; html content
bindaddr= ; address you want the Asterisk HTTP server to respond on
bindport=9000 ; port you want the Asterisk HTTP server to respond on
prefix=asterisk ; will form part of the URI, similar to a directory name


enabled=yes ; you may already have AMI enabled if you are using it for other things
webenabled=yes ; this enables the interaction between the Asterisk web server and AMI
[admin] ; This is the manager username. You can name the user whatever you want
secret = password
read = system,call,log,verbose,command,agent,user,config
write = system,call,log,verbose,command,agent,user,config


That’s it! Restart your PBX server and point your browser to:

http://ip-of-pbx:9000/asterisk/static/config/cfgbasic.html (where IP of PBX is the IP address of your PBX box)

You should then see the web GUI and should be able to logon and start creating extensions (users).



If you don’t see the GUI after restarting your PBX, login as root and just start Asterisk by typing asterisk on the command line. You can also set it to start at system boot by adding it to your /etc/rc.local startup script. Also, if you have an account with a VOIP service provider, you can setup your PBX to be the “gateway” to your office/home with ease.

Asterisk is very flexible, scalable, and limitless in its scope of use, so there is no way I can tell you everything that can be done with this amazing piece of software. It’s use is not just limited to communication and phone management and there are thousands of hacks that can be applied to Asterisk. Some of them are:

  • Home Automation using X10 addressable switches
  • Remote home/office alarm/lock control
  • Remote environmental/audio monitoring
  • Conference Rooms
  • E-mail reader (text to speech access to any email account)
  • Remote Dictation
  • Voice Recognition
  • Ability to run system commands by phone - Remote Control

Additional Materials
Because of the power and limitless flexibility of Asterisk, there is no available text that comes close to covering the broad scope of this software. The best guide I can recommend is the O’Reilly self-titled book “Asterisk”. That is a good step to begin to understand much of the power available to this platform. I would suggest this as the first guide to begin to learn additional features.

Phones and Extension Types
Asterisk supports any standards based SIP or IAX compatible voip phone. One of the best well known suppliers is and they sell a wide range of voip phones that work with asterisk. Softphones and VOIP ATAs (Analog Telephone Adaptors) are also another way to interface with your Asterisk system. With an ATA you can turn your existing analog corded or cordless phones into VOIP phones. I have an old Western Electric Model 302 from the late 1920s that is now setup as a voip extension and it is a ROTARY phone! NOTE: Not all voip ata units understand pulse dialing, so be sure before you buy if you intend to use a rotary phone for nostalgic purposes. Good deals for voip phones and voip ATAs can be had online at various sites, but don’t overlook the possibilities that may exist at your local swapfest. Near where I live, MIT holds a swapfest during the summer season on the 3rd Sunday of the month and I’ve scored some real bargains there! Look for swapfests in your area, or even check Craig’s List.

Voip Service Providers/PSTN
Asterisk can connect with the world either directly with a voip service provider that allows a “byod” (Bring Your Own Device) plan, or directly with the PSTN (Public Switched Telephone Network) via a Digium interface card. The Digium card is not required to interface with a voip provider over the internet though. Some voip providers that welcome Asterisk (and other devices) are: Broadvoice and Teliax. If you want to interface with Ma Bell, you might be interested in Digium’s line of cards. These can interface with standard POTS PSTN lines and provide outbound calling from extensions on your Asterisk system. Most of these cards feature built-in echo cancellation for best call quality. If you’re a business user, you can connect Asterisk to a T1/E1 or PRI digital telco offering via their digital cards.

Community Support
Asterisk is supported by Digium and the Asterisk Open Source community. There are numerous resources available for the taking on the internet that allow you to extend the flexibility and functionality of your Asterisk PBX. is one of many public voip forums where a wealth of information is available. Available resources can be anything from example configurations, scripts, feature enhancements, function modules, advice, and troubleshooting.

The intended purpose of this feature was to simplify a nice and lean sourcecode installation of Asterisk onto a pupular Ubuntu (or any other Linux) host system and to ease the new user or experimenter in wading into a huge pool of possibilities that are only limited by the imagination of the user. The door is open, just take your step through!


Post a Comment