[HowTo] Install Asterisk server on Debian-based system

In this post, I will explain how to install the popular Asterisk server on a Debian-based system.

How do we get started ?

Before beginning an installation of an Asterisk Server, you must be aware that there are 3 ways to install it.

  • Bundle : Often a ISO linux with Asterisk and a lot of tools already installed
  • Packages : Use the distribution’s repositories to install it. eg. apt-get install asterisk
  • Sources : From Asterisk’s site

In this post, I choose to install it from the sources because it is the better way to understand what we are doing.

Prerequisites: Freshly installation of Debian-based distribution and up to date and NTP service enabled. We assuming that the current system account is called “asteriskpbx”.

In my case, I will use a Linux Mint, 32 bits, release 17

apt-get update && apt-get upgrade && reboot
apt-get install ntp

Keeping accurate time is essential in your Asterisk system, both for maintaining accurate call detail records as well as for synchronization with your other programs. Just start the NTP service manually if it doesn’t start automatically.

/etc/init.d/ntp restart
What we need to download ?
  • Asterisk 12: It’s the current latest version but not LTS. [~ 33 MB]
  • libpri: To communicate with ISDN connection (optional). [~ 330 KB]
  • DAHDI: To communicate with PSTN, set of drivers and tools. [~ 7.1 MB]
    • dahdi-linux: Only the drivers
    • dahdi-tools: Only the tools
    • dahdi-linux-complete: The full package

For this first part, we need to download these 3 elements. You can choose to download another version of Asterisk if you want but I don’t know if the installation process is the same. Please note that all commands are executed with root access.

cd /usr/local/src
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-12-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-1.4-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz

After that, just decompress the 3 files.

tar -xvzf ./asterisk-12-current.tar.gz
tar -xvzf ./libpri-1.4-current.tar.gz
tar -xvzf ./dahdi-linux-complete-current.tar.gz

Now you must have 3 new folders with the same name that the archives (without .tar.gz).

Build and install DAHDI

DAHDI is mandatory and you must install it first if you plan to install libpri because libpri need DAHDI. The installation is very simple

cd /usr/local/src/dahdi-linux-complete-
make && make install && make config

In my case, I had an error when the “make” command. Simply install “g++” (sudo apt-get install g++) to solve it. Now you have the daemon installed under /etc/init.d/dahdi

Build and install libpri
cd /usr/local/src/libpri-1.4.15/
make && make install
 Build and install Asterisk
cd /usr/local/src/asterisk-12.4.0/

If this command fails, that mean that you don’t have minimal requirements. To install all dependencies, a tool (install_prereq) exists but it works partially (Works correctly in my Mint 17, but fails with Ubuntu Server 14.04 LTS).

cd /usr/local/src/asterisk-12.4.0/contrib/scripts/
./install_prereq test
## test: test mode.
## Use the commands here to install your system.
aptitude install -y binutils-dev build-essential doxygen freetds-dev git libasound2-dev 
libbluetooth-dev libcorosync-dev libcurl4-openssl-dev libedit-dev libgsm1-dev libgtk2.0-dev 
libical-dev libiksemel-dev libjack-dev libjansson-dev liblua5.1-0-dev libmysqlclient-dev 
libneon27-dev libnewt-dev libogg-dev libpopt-dev libpq-dev libradiusclient-ng-dev libsnmp-dev 
libspandsp-dev libspeex-dev libspeexdsp-dev libsqlite0-dev libsqlite3-dev libssl-dev libusb-dev 
libvorbis-dev libvpb-dev libxml2-dev libxslt1-dev lua5.1 portaudio19-dev subversion unixodbc-dev
uuid uuid-dev

This command just make a test and display the command to use to install the requirement. If you want to execute this command just replace “test” by “install”.

./install_prereq install

If this command works, all dependencies will be installed. If this tool doesn’t work, please use this next command to install the minimum dependencies.

apt-get install g++ libncurses5-dev libxml2-dev libsqlite3-dev

Now, you can re-run the first command

cd /usr/local/src/asterisk-12.4.0/

The result is successful if you see the ASCII’s Asterisk logo.

For the next step, we must select the options that we need. To do this, simple build menuselect tool like this:

make menuselect

You can navigate into the menu and select functions, codec, channel drivers… Just be sure that “chan_sip” is selected to be installed. By default, there are a lot of things selected depending of dependencies. In general, if you used “install_prereq” tool, you have a lot element selected.

Now we are ready to compile and install Asterisk 🙂

make && make install && make samples && make config

With these commands, the sources will be compiled, installed, various samples configurations files will be installed and “make config” will install the daemon as /etc/init.d/asterisk. The last step is to install logrotate to have a better management of the log (compression, rotation)

make install-logrotate

Just modify permissions on folders where asterisk is installed. In my case, my system account is called “asteriskpbx” but you must use your own of course.

chown -R asteriskpbx:asteriskpbx /var/lib/asterisk/
chown -R asteriskpbx:asteriskpbx /var/spool/asterisk/
chown -R asteriskpbx:asteriskpbx /var/log/asterisk/
chown -R asteriskpbx:asteriskpbx /var/run/asterisk/
chown -R asteriskpbx:asteriskpbx /etc/asterisk/

Now you can check if Asterisk is running and if not, start it.

/etc/init.d/asterisk status
* asterisk is not running
/etc/init.d/asterisk start
* Starting Asterisk PBX: asterisk                [ OK ]

You can access to Asterisk’s console with this command:

asterisk -rvvvvvv

So, this tutorial is finished and I hope that it will be useful for you. If you have remarks, questions, problems or something else, please write a comment on this post and I will contact you as soon as possible.

Bookmark the permalink.


  1. Great… thanks

  2. your tutorial works well with 13.60 , i tried static and mp3 settings but had errors…
    my trouble isto manage the asterisk server from a pc in the lan….
    plus i would like to install the Chan-SCCP channel driver for Asterisk for my cisco 7945 that i am not able to configure…

    • Hello Jc_geny, thank for your comment. How do you want to manage your asterisk from your LAN ? please give me more details. Concerning the chan-sccp, I have never tried it. Can you select all related chan_sccp before making ./configure and compilation ? I will be happy to help you if you send me more information 🙂 Best regards.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.