How to Install Asterisk on Ubuntu – Setting up Asterisk PBX

how to install asterisk on ubuntu
how to install asterisk on ubuntu

Asterisk on Ubuntu

Asterisk is one of the most popular free telephony solutions available as it is very simple to setup, has great community support and can be customized for any application. It also features easy to use GUI interface.

This hub will go through setting up asterisk from the packages instead of just downloading an already pre-made image of Asterisk like AsteriskNOW , Tribox or systems similar.Asterisk on ubuntu guide goes through version 1.4 I believe 1.6 recently came out as well as the changes to the packages.


Packages Required for Asterisk Installation

There are quite a few packages ubuntu will require in order to complete the installation of asterisk on ubuntu successfully, these include running kernel 2.6 of linux, and appropriate packages to execute C programs.

To install the required packages enter root mode using

Sudo su

 

Apt-get –y install linux-headers-$(uname -r) build-essential

automake autoconf bison flex libtool libncurses5-dev libssl-dev

subversion svn-buildpackage

apt-get –y install cvs build-essential automake autoconf bison flex libtool libncurses5-dev libssl-dev libgsm1 libgsm1-dev

apt-get –y install sysvconfig **required to start services**

Note: if packages fail to install try separating the packages and installing them individually.


Installation Steps

Extract Files – Configure each Package – Run Services

tar –xzf zaptel-1.4.12.1.tar.gz

tar –xzf libpri-1.4.10.1.tar.gz

tar -xzf asterisk-1.4.20.tar.gz

tar -xzf asterisk-sounds-1.2.1.tar.gz

tar -xzf asterisk-addons-1.4.7.tar.gz

  • cd zaptel-1.4.12.1
  • ./configure
  • make
  • make install
  • make config
  • service zaptel start
  • cd ..
  • cd libpri-1.4.10.1
  • make
  • make install
  • cd ..
  • cd asterisk-1.4.20
  • ./configure
  • make
  • make install
  • make samples
  • make config
  • cd ..
  • cd asterisk-sounds
  • make install
  • cd ..
  • cd asterisk-addons-1.4.7
  • ./configure
  • make
  • make install
  • service asterisk start


If asterisk fails to start try starting asterisk from directory /etc/asterisk
Asterisk start

Setting up Sip Extensions

Now that asterisk is installed its time to create some users so that we can register ourselves on the asterisk server with a soft phone and then start to make calls over the network.

Edit the file /etc/asterisk/sip.conf

Using “nano /etc/asterisk/sip.conf” or “vim /etc/asterisk/sip.conf”

Copy the following into your sip.conf, If you can’t copy and paste try connecting to your server with Putty once you have installed openssl

[common](!) ; this is template.
type=friend
context=internal
host=dynamic
disallow=all
allow=ulaw
allow=alaw
allow=g723
allow=g729
dtmfmode=rfc2833
 
;
[1000](common)
username=1000
secret=1000
 
;
[1001](common)
username=1001
secret=1001


Here we have setup two users with extensions 1000 and 1001 , you can now registry your softphone with the server using these two extensions and secrets.

Remember to reload your asterisk server when changes have been made. Enter the command line “asterisk –r” and type “reload”

X-lite softphone connected to Asterisk Ubuntu PBX
X-lite softphone connected to Asterisk Ubuntu PBX

Setting up Dialplan’s so we can make Call’s

We cannot make calls until we have setup the dialplan file which will specify how a particular number shall be interpreted and where the call should be sent.

Edit sip.conf to look like the following

[internal]
exten=> _XXXX,1,Dial(SIP/${EXTEN})

The above diaplan specifies anyone that dials 4 digits e.g 1001 , the number one priority will be to Dial, the Sip extension 1001.

X refers to any number from 0 – 9

That’s it for the basic’s in setting up your Asterisk PBX server on ubuntu, next time I will go through creating trunk’s to reach the PBX , setting up ENUM and a few other things.

Asterisk & Ubuntu :)
Asterisk & Ubuntu :)

More by this Author


Comments 34 comments

dusanotes profile image

dusanotes 6 years ago from Windermere, FL

WOW! Expectus, you outdid yourself. I'm going to save this for future reference. Your mind is so far more advanced than mine, it's not even possible for me to stay up with you. But I'm going to try. This kind of material is valuable. Have you thought of cataloging it and sharing it in the form of a book? Neat stuff. Don White


expectus profile image

expectus 6 years ago from Land Downunder Author

thanks for the very encouraging comments dusanotes :) I am still pretty new to asterisk but its great to write a hub to help people get started using it. The book idea sounds great as there's a lack of good clear info on asterisk on the web :)


ABTEODORO profile image

ABTEODORO 6 years ago

You surely have lots of informative hubs.


expectus profile image

expectus 6 years ago from Land Downunder Author

thanks ABTEODORO


Carl "Fitness" profile image

Carl "Fitness" 6 years ago from Boston, MA

This is great. I hadn't heard of Asterisk, but luckily I stumbled upon this awesome Hub. This is exactly the solution I need. Thanks!


expectus profile image

expectus 6 years ago from Land Downunder Author

thanks for the comment Carl :) glad you found it useful


Himanshu 6 years ago

Very clear and simple step to start the installation of Asterisk for new bigenners like me.


expectus profile image

expectus 6 years ago from Land Downunder Author

thanks Himanshu glad it helped you


Abu 6 years ago

Looks simple, will try it out, though i'm still new to Ubuntu. Any Words of advice?


expectus profile image

expectus 6 years ago from Land Downunder Author

its pretty straight forward really, just got to make sure all packages install properly or you'll have major problems when trying to run asterisk


save my system profile image

save my system 6 years ago from United Kingdom - London

Its really very well explained. I am waiting from so long for installing Asterisk on my Ubuntu system. Thanks, I found this hub really impressive and informative.In addition i appreciate for sharing web links too.


expectus profile image

expectus 6 years ago from Land Downunder Author

glad it helped you


Reem 6 years ago

Hi, I tried this but I got a few problems:

1- when trying to install sysvconfig I got error says sysvinit-utils can replace it, I have sysvinit-utils installed.

2- wget http://downloads.asterisk.org/pub/telephony/libpri... was not found so I tried libpri-1.4.10.2.tar.gz and it was OK.

3- in /usr/src/zaptel-1.4.12.1 when I try "make" I get errors like:

/usr/src/zaptel-1.4.12.1/kernel/ztdummy.c:202: error: ‘struct hrtimer’ has no member named ‘expires’

make[3]: *** [/usr/src/zaptel-1.4.12.1/kernel/ztdummy.o] Error 1

make[2]: *** [_module_/usr/src/zaptel-1.4.12.1/kernel] Error 2

make[2]: Leaving directory `/usr/src/linux-headers-2.6.31-21-generic'

make[1]: *** [modules] Error 2

make[1]: Leaving directory `/usr/src/zaptel-1.4.12.1'

make: *** [all] Error 2

4- make install shows the same errors too :(

5- when I try: service zaptel start

I get: ztcfg not executable

6- I tried the following commands with no errors but when I reached : service asterisk start

I got:

/etc/init.d/asterisk: 95: Bad substitution

*please can u help me? what's wrong? I installed all the packages well..


expectus profile image

expectus 6 years ago from Land Downunder Author

I remember having an error similar did you run

apt-get install update & upgrade

you have to make sure you system is up to date, let me know if that changes anything, and reinstall it again


bytecoders profile image

bytecoders 6 years ago from Spain

Hi! Nice post, well explained. Lot's of things to learn from you dude.

@Reem

If having problems compiling zaptel on Ubuntu or Debian-like distributions you can try using module assistant, that would do it in an "easy way":

sudo apt-get install module-assistant

sudo m-a a-i zaptel

If still having problems, ignore zaptel 1.4.12.1 which seems it's a little bit tricky on some setups. Try grabbing a different version from SVN.

That link helped me a lot:

https://www.saruman.biz/wiki/index.php/Installing_...


soner 6 years ago

http://downloads.asterisk.org/pub/telephony/libpri...

is not working... is there an alternative way to solve that problem ???



papatrimble profile image

papatrimble 5 years ago from Baltimore, MD

This was a great read! I'm starting a small office once my design firm takes off. Thanks to your article, I will have a solid solution for my sales reps.


Fernando 5 years ago

Hi, I am completely new to both Ubuntu/Linux and Asterisk.

Tried to run "automake autoconf ..." and no input files were found (autoconf,bison, etc.). How do I get them?

Tks

Fernando


Fernando 5 years ago

Solved that issue and was able to make it work! Tks for the great post!

On Reem's issue "95 Bad Distribution": doing the "Asterisk start" on etc/asterisk solved the issue for me. Rgs

Fernando


MrMintanet 5 years ago

Perhaps you could use some pastebin or code type boxes? Just a suggestion. It's a bit confusing for someone who is a novice to CLI.


ferragamo 5 years ago

hello, thank you so much for this site it really helps me a lot. May God Bless YOU Always & YOur family TOo...

from: ferragamo


Clarke 5 years ago

Hi, just came across your site, and enjoyed the simplicity. I will be trying this install, but had to comment after ready such great reviews. thanks for the great work, keep it up. After my system is up and running, I will update you all.


Sagar 5 years ago

@Fernando , How did you resolve the "no input files were found" error.I am facing the same issue.


xhavick profile image

xhavick 5 years ago from Mexico City, Mexico

Great! thanks a lot but i have an issue, when y call between extensions 1000 and 1001 (using the examples) the server replyes

[Sep 26 15:11:48] NOTICE[16115]: chan_sip.c:14033 handle_request_invite: Call from '1001' to extension '1000' rejected because extension not found.

how can i resolve this any ideas?


Deepak 4 years ago

@xhavick, The lines for the context,

[internal]

exten=> _XXXX,1,Dial(SIP/${EXTEN})

should be added in the file extensions.conf instead of sip.conf.

This should resolve the issue.


Teresa 4 years ago

Hello all, how can i hide my cli?


Casey Strouse profile image

Casey Strouse 4 years ago from Phoenix, Arizona

These days you're better off installing something like Trixbox to get an Asterisk system up and running. I know a lot of hardcore phone guys that do high-end consulting and swear by Trixbox vs. configuring your system the old way via text files.


supergirl 4 years ago

1) http://downloads.asterisk.org/pub/telephony/libpri

is not working... is there an alternative?????????

2) 3- in /usr/src/zaptel-1.4.12.1 when I try "make" I get errors like:

/usr/src/zaptel-1.4.12.1/kernel/ztdummy.c:202: error: ‘struct hrtimer’ has no member named ‘expires’

make[3]: *** [/usr/src/zaptel-1.4.12.1/kernel/ztdummy.o] Error 1

make[2]: *** [_module_/usr/src/zaptel-1.4.12.1/kernel] Error 2

make[2]: Leaving directory `/usr/src/linux-headers-2.6.31-21-generic'

make[1]: *** [modules] Error 2

make[1]: Leaving directory `/usr/src/zaptel-1.4.12.1'

make: *** [all] Error 2


supergirl 4 years ago

tell me the solution of above mentioned problem

regards..


James 4 years ago

Casey, I totally disagree, having run Asterisk for many businesses (including my own) I can say that installing a minimal install of Linux (CentOS or Ubuntu work will) with and building your own config files will give you a more stable system than a GUI install.

@supergirl - Supergirl, try following this guide for Asterisk 10 on Ubuntu http://linuxmoz.com/ubuntu-asterisk-10-install-gui...

@Teresa - Teresa if you start asterisk as a service you don't need to have the Asterisk console open (CLI). To do this type:

sudo /etc/init.d/asterisk restart

If it fails to start follow the guide in the link I posted above, hope that helps you two out :)


hemant 4 years ago

thank you very much


Louis 4 years ago

If you want all in one guides for asterisk including, the sip.conf,extension.conf, voicemail.conf & setting up a cisco ip phone check this out.

http://ubuntuserverhelp.com/category/asterisk/


Jamil 2 years ago

i facing problem in installing

apt-get –y install cvs build-essential automake autoconf bison flex libtool libncurses5-dev libssl-dev libgsm1 libgsm1-dev

i also try individually but give me error

what should i do now ,,,??

    Sign in or sign up and post using a HubPages Network account.

    0 of 8192 characters used
    Post Comment

    No HTML is allowed in comments, but URLs will be hyperlinked. Comments are not for promoting your articles or other sites.


    Click to Rate This Article
    working