Asterisk Installation On Linux

Asterisk Installation On Linux

About Asterisk :
Asterisk is a software implementation of a telephone private branch exchange (PBX); it allows attached telephones to make calls to one another, and to connect to other telephone services, such as the public switched telephone network (PSTN) and Voice over Internet Protocol (VoIP) services.

Here are the installation steps of Asterisk on Ubuntu  :

Step 1: For installing Asterisk you have to update and upgrade your ubuntu to the latest version, by following commands:

root@ linux :~# apt-get update && apt-get upgrade -y && reboot

Step 2: After this what we have to do is to resolve the basic dependencies.

root@ linux :~# apt-get install build-essential wget libssl-dev libncurses5-dev libnewt-dev libxml2-dev linux-headers-$(uname -r) ibsqlite3-dev uuid-dev

Step 3: After resolving dependencies, we have to download the source tarballs. These commands will get the current version of DAHDI, libpri and Asterisk. Dahdi and Libpri are to be configured before configuring Asterisk.

Note: Run the below commands in the source directory:

root@ linux :~# cd /usr/src/
root@ linux :/usr/src# wget
root@ linux :/usr/src# wget
root@ linux :/usr/src# wget

Step 4: Extract the tar files with following commands:

root@ linux :/usr/src# tar zxvf dahdi-linux-complete*
root@ linux :/usr/src# tar zxvf libpri*
root@ linux :/usr/src# tar zxvf asterisk*

Step 5: First Dahdi is installed, so to configure dahdi use the following commands:

root@ linux :/usr/src/dahdi-linux-complete-VERSION# cd /usr/src/dahdi-linux-complete*
root@ linux :/usr/src/dahdi-linux-complete-VERSION# make && make install && make config

The make, make install and make config commands will install the basic configuration files of the Dahdi. && is used to run the commands one by one.

Step 6: After Dahdi is installed you have to Install libpri

root@ linux :/usr/src/libpri-VERSION# cd /usr/src/libpri*
root@ linux :/usr/src/libpri-VERSION# make && make install

Note: If the above command give an error like pritest.c:71…. . Then you have to do the following changes

root@ linux :/usr/src//usr/src/libpri-VERSION# vim pritest.patch
  • And paste the below lines in it
--- a/pritest.c

+++ b/pritest.c

@@ -64,11 +64,16 @@ static void do_channel(int fd)


/* This is the part that runs on a given channel */

char buf[READ_SIZE];

-       int res;

+       int res, res_write;

int i=0;


while ((res = read(fd, buf, READ_SIZE)) > 0 && (i++ < 1000)) {

-               write(fd, buf, res);

+               res_write = write(fd, buf, res);

+               if (res_write == -1) {

+                       fprintf(stderr, "--!! %s: Failed write: %d\n",

+                                       __func__, errno);

+                       break;

+               }



Save and exit the editor

  • Run the below command:
root@ linux :/usr/src/libpri-VERSION# patch pritest.c pritest.patch
  • After these steps run the make && make install command again.
  • If you dosen’t get anuy error refer to the next step.

Step 7: After installing Dahdi, libpri, you have to install Asterisk.

root@ linux :/usr/src/libpri-VERSION# cd /usr/src/asterisk*
root@ linux :/usr/src/asterisk-VERSION# ./configure && make menuselect
  • After running the above command a select menu will open. Just save and exit that option. Don’t change any option. Save and exit that section with default settings.

Step 8: After that run the below commands:

root@ linux :/usr/src/asterisk-VERSION# make && make install && make config && make samples
  • These commands will install Asterisk on your pc.

Step 9: Now you have to start dahdi first and then Asterisk.

root@ linux :/usr/src/asterisk-VERSION# /etc/init.d/dahdi start
root@ linux :/usr/src/asterisk-VERSION# /etc/init.d/asterisk start

Step 10: Once dahdi and asterisk are running you can access the asterisk CLI by below command:

root@ linux :/usr/src/asterisk-VERSION# asterisk -rvvv

Step 11: Verify your installation by checking for the DAHDI and libpri versions on the Asterisk CLI

For Dahdi:

root@ linux :/usr/src/asterisk-VERSION# dahdi show version

O/P will be something like this:

DAHDI Version: Echo Canceller:

For Libpri:

root@ linux :/usr/src/asterisk-VERSION# pri show version

O/P will be something like this:

libpri version: 1.4.15
  • With the above steps your asterisk is installed, now what you have to do is to configure the sip and extension files to make a test call.
  • Asterisk works with a SIP telephone configured to it or with Zoiper tool.
  • We will configure it with Zoiper.

Step 12: To get started, go ahead and move to the /etc/asterisk/ directory where the files are located.

root@ linux :/usr/src/asterisk-VERSION# cd /etc/asterisk/


  • Here we will make changes in the sip.conf file and extension.conf file.

Step 13: First the the backup of the sample extensions.conf  and sip.conf file and create a new one.

root@ linux :/etc/asterisk# mv extensions.conf extensions.sample
root@ linux :/etc/asterisk# mv sip.conf sip.sample

Step 14: First edit the sip.conf file as:

root@ linux :/etc/asterisk# vim sip.conf
  • Paste the below lines in the file
transport = udp
subscribecontext = default

type = friend
host = dynamic
context = from-internal
disallow = all
allow = ulaw

secret = password

secret = password

Save and Exit the file.

  • In the above lines the above commands have the below functioning

friends_internal: is the default profile, you can rename it.

667,668: Are the extension numbers.

transport= udp: sets the general transport used by all chan_sip accounts defined in configuration if  they don’t have their own transport defined. We want to use UDP

type=friend: we are using the friend type to make things easy. See the sip.conf.sample for more explanation on the section types available in sip.conf

host=dynamic: our phones will register to Asterisk. Otherwise we would define the IP address of the phone here.

context=from-internal: When Asterisk receives a call from this phone, it’ll look for the dialed  extension number inside this context within dial plan

(/etc/asterisk/extensions.conf typically)

disallow=all; Don’t allow any codecs to be used except what is set in ‘allow’

allow=ulaw; Only allow the ulaw codec to be used.

secret=verysecretpassword: This is the authentication password the phone needs to use when authenticating against Asterisk.

Step 15: After editing the sip.conf file edit the extension.conf file

root@ linux :/etc/asterisk# vim extension.conf

exten = 667,1,Dial(SIP/667,20)
same = n,Hangup()
exten = 668,1,Dial(SIP/668,20)
same = n,Hangup()
exten = 669,1,Dial(SIP/669,20)
same = n,Hangup()

Save and Exit the file

In above commands

exten = 667,1,Dial(SIP/667,20)

extn is the extension and 667 is the extension number. SIP  is used because we will configure the SIP account in Zoiper.

Step 16: After this you have to configure Zoiper.

Note: Configure Zoiper on other device, dont install Zoiper on the devce where Asterisk server is configured. So Install perform the below steps on two device other then the asterisk server with in a LAN.

Download Zoiper from the below link


Step 17: After downloading Zoiper extract the tar file with below commands:

root@ linux :/etc/asterisk# cd 
root@ linux :~# wget -c -O Zoiper_3.3_Linux.tar.bz2 
root@ linux :~# tar zxvf Zoiper_3.3_Linux*

Step 18: After extracting Zoiper run Zoiper by

root@ linux :~# ./

Step 19: After starting zoiper install zoiper and after installing do the following changes:

  • Click on Settings > Create a new account
  • Select SIP account > Next
  • Enter 6001 for the account name, click OK
  • In the user/user@host enter the user-name which you can given in the /etc/asterisk/conf file.
  • In the Password field enter the secret password which is defined in the /etc/asterisk/conf file.
  • In the Domain filed enter the Asterisk Server’s IP address. Where the Asterisk Server is running.
  • After the configuration of the SIP account click on Settings > Preferences
  • You can see here that you SIP account is registered.
  • Click on the codec option and drag the GSM option to left side.

Step 20: Now to start the asterisk server, run the following commands:

root@ linux :~# asterisk -rx "core restart now"
  • This command will restart the asterisk server to save the changes.
root@ linux :~# asterisk -rvvvvv
  • This command will connect you to the asterisk cli.

Now you can call from one pc to other. Dail the extension 668 from the extension 667. Your call will be connected.

Connecting To Asterisk GUI

Note: Asterisk GUI is not officially supported, but it can be installed by below configurations.

Step 21: Download the asterisk-gui-2.1.0-rc1.tar.gz file from the below link in the /usr/src/ directory

Step 20: After downloading the tar file extract the tar file

root@ linux :~# tar zxvf asterisk-gui-2.1.0-rc1.tar.gz

Step 21: After extracting you can install Asterisk GUI with below commands:

root@ linux :~# cd asterisk-gui-2.1.0-rc1
root@ linux :~/asterisk-gui-2.1.0-rc1# ./configure
root@ linux :~/asterisk-gui-2.1.0-rc1# make
root@ linux :~/asterisk-gui-2.1.0-rc1# make install
root@ linux :~/asterisk-gui-2.1.0-rc1# cd 

Step 22: You may install sample configuration files by doing “make samples”.  Also you will need to edit your Asterisk configuration files to enable the GUI properly,


  • In http.conf:

enabled = yes

enablestatic = yes
  • In manager.conf
enabled = yes
webenabled = yes
  • Create an appropriate entry in manager.conf for the administrative user

(PLEASE READ THE security.txt FILE!)

secret = password(enter the desired password here)
read = system,call,log,verbose,command,agent,config,read,write,originate
write = system,call,log,verbose,command,agent,config,read,write,originate

Step 23: Check your config permissions:

root@ linux :~# chown asterisk:asterisk /etc/asterisk/*.conf
root@ linux :~# chmod 644 /etc/asterisk/*.conf

Note: If you get an error saying no user asterisk fond, run the below commands:

Adduser asterisk

Give password to asterisk

Don’t fill the other fields except user-name and password. Simply keep on pressing enter.

Run the above commands again

root@ linux :~# chown asterisk:asterisk /etc/asterisk/*.conf
root@ linux :~# chmod 644 /etc/asterisk/*.conf

Now you can connect to the Asterisk GUI in browser ( Firefox, Chorme & etc ) :


No Comments

Comments are closed.

Enquiry Now