Friday, October 21, 2011

How to install Asterisk 1.8 on Ubuntu Server 11.04

It is easy to install and use an Asterisk  on Ubuntu New Server addition 11.04 – if you do it frequently. 
I use Asterisk on my 64 bit Ubuntu Server 11.04.
After the upgrade on a fresh install, we need three packages to build up our Asterisk. Let’s install the build-essential, libxml2-dev, and ncurses-dev packages. These package are not included by default and should be installed seperately as described below. 
apt-get install build-essential libxml2-dev ncurses-dev 
Pre-requisite : 
As these packages are not included by default, running them from the CD will generate errors.
Example : E:\ no packages found. So please # comment out the CD rom related settings rc.local file.


You can find all versions of the Asterisk at the download section. Download the latest version, and extract it!

Please right-click on the tar file on asterisk site and select copy link address
/usr/src is the most common place or directory to install this files
cd /usr/src
wget zxvf asterisk-

wget paste Link address
Then install the Asterisk, config, and the shamples.

cd asterisk-
make install
make config
make samples 
Without the above-mentioned additional packages, you will face with these error messages during the ./configure command run.
Lack of build-essential package:

configure: error: in `/root/asterisk-':
configure: error: no acceptable C compiler found in $PATH 
Lack of libxml2-dev package:

checking for xml2-config... no
configure: *** XML documentation will not be available because the 'libxml2' development package is missing.
configure: *** Please run the 'configure' script with the '--disable-xmldoc' parameter option
configure: *** or install the 'libxml2' development package. 
Lack of ncurses-dev package:

configure: error: *** termcap support not found (on modern systems, this typically means the ncurses development package is missing) 
When the installation finishes, we have a preconfigured Asterisk. To test the Asterisk with two softphones, let’s configure the sip.conf and the extensions.conf.
Here is the sip.conf file:

context = default
bindport = 5060
bindaddr =
tcpbindaddr =
tcpenable = yes 

type = friend
callerid = User One <1001>
secret = 1001
host = dynamic
canreinvite = no
dtmfmode = rfc2833
mailbox = 1001
disallow = all
allow = ulaw
transport = udp 

type = friend
callerid = User Two <1002>
secret = 1002
host = dynamic
canreinvite = no
dtmfmode = rfc2833
mailbox = 1002
disallow = all
allow = ulaw
transport = udp 
This config means that the Asterisk listen all IP, port 5060, and the TCP is enabled. It has two extensions defined for User One and User Two.
Here is the extensions.conf file:


exten => 1001,1,Answer()
exten => 1001,n,Dial(SIP/1001,20,tr)
exten => 1001,n,Hangup 

exten => 1002,1,Answer()
exten => 1002,n,Dial(SIP/1002,20,tr)
exten => 1002,n,Hangup. 
This config means that there are two accessible extensions existing.
After configuring the Asterisk, we need to start it.

/etc/init.d/asterisk start 
I use X-Lite to connect to the soft PBX. Let’s configure the X-Lite!
All data come from the sip.conf. The Account name, and the Display name are the callerid. The User ID and the Authorization name are the extension number – inside the square brackets. The Password is the sicret. The Domain is the IP address of the Asterisk server.
If all configurations are good, the X-Lite will inform you.
Let’s call from User One to User Two.
Here is the User One side:
Here is the User Two side:
Troubleshooting? We always need when we try a new thing. The firs tool is the tcpdump of course, but the asterisk have a good command line interface (Asterisk CLI) to debug the problem. To access the Asterisk CLI type

asterisk -vvvvvvr 
This screen shows a successful call from 1001 to 1002.
The Asterisk works now! Are you wondering why I configured my Asterisk to answer on TCP? Because I would like to test the Direct SIP feature of the Microsoft Communications Serverand the Lync. CU next time! ;-)