How to Install Asterisk 10 on Ubuntu Server 11.10


I’ve personally developed these installation instructions over time and this is me sharing some of ’em. If you run into any problems while installing, I’ll be more than willing to help. Just post in the comments below…

1. Install ubuntu server 11.10 including LAMP, SSH etc

2. fix broken GPG link by doing:

sudo apt-get clean
 cd /var/lib/apt
 sudo mv lists lists.old
 sudo mkdir -p lists/partial
 sudo apt-get clean
 sudo apt-get update

3. Run apt-get update && apt-get upgrade

4. In order to determine the dependencies required, fake an asterisk 1.8 install by doing [pre]apt-get install asterisk[/pre].

Copy the dependencies/requirement i.e all except asterisk-related programs. i.e:

 apt-get install binutils build-essential cpp cpp-4.6 debhelper dpkg-dev fakeroot freetds-common g++ g++-4.6 gcc gcc-4.6 gettext html2text intltool-debian libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasound2 libc-dev-bin libc6-dev libcorosync4 libcroco3 libcurl3 libdpkg-perl libflac8 libgmime-2.4-2 libgomp1 libgsm1 libical0 libiksemel3 libjack-jackd2-0 libjpeg62 libltdl7 liblua5.1-0 libmail-sendmail-perl libmpc2 libmpfr4 libneon27-gnutls libnspr4 libnss3 libogg0 libopenais3 libopencore-amrnb0 libopencore-amrwb0 libperl5.12 libpq5 libquadmath0 libradiusclient-ng2 libresample1 libsdl1.2debian libsdl1.2debian-alsa libsensors4 libsndfile1 libsnmp-base libsnmp15 libsox-fmt-alsa libsox-fmt-base libsox1b libspandsp2 libspeex1 libspeexdsp1 libsqlite0 libsrtp0 libstdc++6-4.6-dev libsybdb5 libsys-hostname-long-perl libtiff4 libunistring0 libvorbis0a libvorbisenc2 libvorbisfile3 libvpb0 libwavpack1 linux-libc-dev make manpages-dev module-assistant odbcinst odbcinst1debian2 po-debconf sox unixodbc vpb-driver-source

5. Install libxml2-dev by doing:

apt-get install libxml2-dev

6. Install ncurses-dev by doing:

apt-get install ncurses-dev

You could try: apt-get install libncurses5-dev

If you need to install ncurses, try:

apt-get install libncurses5


$ wget
 $ tar xzf ncurses-5.7.tar.gz
 $ cd ncurses-5.7
 $ ./configure --prefix=/opt/ncurses
 $ make && make install
 $ ls -la /opt/ncurses

7. Install sqlite3 and the dev by doing:

apt-get install sqlite3 libsqlite3-dev

8. Install the following also:

libssl-dev libosptk3 libosptk3-dev libmysqlclient-dev libfreeradius2 libfreeradius-dev freeradius unixodbc unixodbc-dev libltdl-dev libsrtp0-dev libcrypto++-dev libiksemel speex libspeex-dev libspeexdsp1 libspeexdsp-dev libvorbis-dev libcurl3-dev liblua5.1-0-dev liblua5.1 libgmime-2.4-2 libgmime-2.4-dev

9 Install ilbc (if you will be needing the codec). As it is no longer included in asterisk, do the following [update: I couldn’t get this to work so I simply disabled from menuconfig:

 # the following lines overcome a compile problem in
 # RedHat Enterprise Linux 4 where the iLBC source isn't
 # found by make, even after it is downloadeded.
 # Your distro might not need this, so skip down as needed
 # get the ILBC source
 cd contrib/scripts/
 cd ../..
 cd codecs
 #the codecs/ilbc directory is empty, so make it a symlink to
 #the contrib/scripts/codecs/ilbc directory
 rm -rf ilbc
 ln -s /usr/src/asterisk-10.1.2/contrib/scripts/codecs/ilbc ilbc
 cd ..

10. In the asterisk source directory, run:


11. Make sure your terminal is in full screen [>80×27] (if you are logged in by ssh), then run:

make menuconfig

12. Run:


13. Hopefully, there will be no errors- if there are, simply do steps 10 and 11 again, then:

make install

14. Do:

make samples

15. Upon successfull installation, run:

asterisk -vvvvvvcgp

16. Ensure you remove the “(!)” in the first line of /etc/asterisk/asterisk.conf so that the directories may be enabled

17. Do a Ctrl-C to quit asterisk. Then run

asterisk -r

18. DONE!

If asterisk does not run i.e the CLI displays
Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?) [update: upon doing asterisk -r it means that asterisk is not running]

#then do the following:

cd /var/run/asterisk
sudo mkdir asterisk
asterisk -&
asterisk -r
sudo reboot now</em></em>

#An alternative but untested solution is:
#chown asterisk:asterisk /var/run/asterisk/asterisk.ctl

************************ To make asterisk start at boot-time **********************

  1. Copy the init.d file for your distribution from the /contrib directory of the source.
    sudo cp /usr/local/src/asterisk-10.1.2/contrib/init.d/rc.debian.asterisk /etc/init.d/asterisk
  2. Modify /etc/init.d/asterisk thus:
    sudo nano /etc/init.d/asterisk
    DAEMON=/usr/sbin/asterisk #__ASTERISK_SBIN_DIR__/asterisk
     ASTVARRUNDIR=/var/run/asterisk #__ASTERISK_VARRUN_DIR__
     ASTETCDIR=/etc/asterisk #__ASTERISK_ETC_DIR__
  3. Install the sysv-rc-config tool
    sudo apt-get install sysv-rc-conf

    [I cannot stress this enough – do not play around with services/runlevels you do not understand. Doing so can prevent your server from booting]

  4. Run sudo sysv-rc-conf
  5. Use your arrow down to find asterisk in the list. Then move to position 2, 3, 4, and 5, pressing space on each to check it. Press q once you are done

******************** To change asterisk user to non-root ********************

  1. (Assuming the user is dayo), run:
    groupadd dayo
    useradd -d /var/lib/asterisk -c "Asterisk PBX" -g dayo dayo
    chown -R dayo:dayo /var/lib/asterisk
    chown -R dayo:dayo /var/log/asterisk
    chown -R dayo:dayo /var/run/asterisk
    chown -R dayo:dayo /var/spool/asterisk
    chown -R dayo:dayo /usr/lib/asterisk
    chown -R dayo:dayo /dev/dahdi
    chmod -R u=rwX,g=rX,o= /var/lib/asterisk
    chmod -R u=rwX,g=rX,o= /var/log/asterisk
    chmod -R u=rwX,g=rX,o= /var/run/asterisk
    chmod -R u=rwX,g=rX,o= /var/spool/asterisk
    chmod -R u=rwX,g=rX,o= /usr/lib/asterisk
    chmod -R u=rwX,g=rX,o= /dev/dahdi
    chown -R root:dayo /etc/asterisk
    chmod -R u=rwX,g=rX,o= /etc/asterisk
    chmod g+w /etc/asterisk/voicemail.conf
    chmod g+w,+t /etc/asterisk
  2. Edit asterisk config.
    sudo nano /etc/asterisk/asterisk.conf
    Uncomment lines 61, 62 and change as below
    runuser = dayo
    rungroup = dayo

    By default, you will observe there is a user and group asterisk******************* Getting CDR to work on Asterisk 10 **********************
    cdr_mysql has been deprecated, hence we will be using cdr_adaptive_odbc

    Configure odbc for the existing mysql database

    1. First, install iodbc:
      sudo apt-get install iodbc
    2. Install libmyodbc:
      sudo apt-get install libmyodbc
    3. Create odbc.ini, if it does not exist:
      cd /etc/
      touch odbc.ini
    4. Edit as such:sudo nano odbc.ini
      [ODBC Data Sources]
      odbcname = MyODBC 3.51 Driver DSN
      Driver = /usr/lib/odbc/
      Description = MyODBC 3.51 Driver DSN
      SERVER = localhost
      PORT = 3306
      USER = user
      Password = password
      Database = database
      OPTION = 3
      SOCKET =
    5. Set up odbc (asterisk) dsn using odbcinst
      cd /etc/ODBCDataSources#create
      touch asterisk_dsn#edit the asterisk_dsn file
      sudo nano asterisk_dsn#enter
      Driver = /usr/lib/odbc/
      SERVER = localhost
      PORT = 3306
      DATABASE = database
      OPTION = 3
      USER = user
      PASSWORD = password

      odbcinst -i -s -l -f gregtest_dsn

      #query systems dsn
      odbcinst -q -s

      isql -v asterisk

    6. modify res_odbc as it is central to the functioning of cdr
      sudo nano /etc/asterisk/res_odbc.conf
      enabled =&gt; yes
      dsn =&gt; asterisk
      username =&gt; username
      password =&gt; password
      pre-connect =&gt; yes
    7. Modify cdr_odbc
      sudo nano /etc/asterisk/cdr_odbc.conf
    8. Modify cdr_adaptive_odbc
      sudo nano /etc/asterisk/cdr_adaptive_odbc.conf