How to Install Asterisk 10 on Ubuntu Server 11.10

Howdi!

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:

[bash]

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

[/bash]

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:

[bash]
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

[/bash]

5. Install libxml2-dev by doing:

[bash]apt-get install libxml2-dev[/bash]

6. Install ncurses-dev by doing:

[bash]apt-get install ncurses-dev[/bash]

You could try: apt-get install libncurses5-dev

If you need to install ncurses, try:

[bash]apt-get install libncurses5[/bash]

or:

[bash]

$ wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.7.tar.gz
$ tar xzf ncurses-5.7.tar.gz
$ cd ncurses-5.7
$ ./configure –prefix=/opt/ncurses
$ make && make install
$ ls -la /opt/ncurses
[/bash]

7. Install sqlite3 and the dev by doing:

[bash]apt-get install sqlite3 libsqlite3-dev[/bash]

8. Install the following also:

[bash]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[/bash]

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:

[bash]
# 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/
./get_ilbc_source.sh
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 ..

[/bash]

10. In the asterisk source directory, run:

[bash]./configure[/bash]

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

[bash]make menuconfig[/bash]

12. Run:

[bash]make[/bash]

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

[bash]make install[/bash]

14. Do:

[bash]make samples[/bash]

15. Upon successfull installation, run:

[bash]asterisk -vvvvvvcgp[/bash]

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

[bash]asterisk -r[/bash]

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]

[bash]

#then do the following:

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

[/bash]

#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.
    [bash]sudo cp /usr/local/src/asterisk-10.1.2/contrib/init.d/rc.debian.asterisk /etc/init.d/asterisk[/bash]
  2. Modify /etc/init.d/asterisk thus:
    [bash]sudo nano /etc/init.d/asterisk[/bash]
    [bash]

    DAEMON=/usr/sbin/asterisk #__ASTERISK_SBIN_DIR__/asterisk
    ASTVARRUNDIR=/var/run/asterisk #__ASTERISK_VARRUN_DIR__
    ASTETCDIR=/etc/asterisk #__ASTERISK_ETC_DIR__

    [/bash]

  3. Install the sysv-rc-config tool
    [bash]
    sudo apt-get install sysv-rc-conf
    [/bash]

    [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:
    [bash]
    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
    [/bash]
  2. Edit asterisk config.
    [bash]
    sudo nano /etc/asterisk/asterisk.conf
    [bash]
    Uncomment lines 61, 62 and change as below
    [bash]
    runuser = dayo
    rungroup = dayo
    [/bash]

    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:
      [bash]
      sudo apt-get install iodbc
      [/bash]
    2. Install libmyodbc:
      [bash]
      sudo apt-get install libmyodbc
      [/bash]
    3. Create odbc.ini, if it does not exist:
      [bash]
      cd /etc/
      touch odbc.ini
      [/bash]
    4. Edit as such:sudo nano odbc.ini[bash]
      [ODBC Data Sources]
      odbcname = MyODBC 3.51 Driver DSN

      [Default]
      Driver = /usr/lib/odbc/libmyodbc.so
      Description = MyODBC 3.51 Driver DSN
      SERVER = localhost
      PORT = 3306
      USER = user
      Password = password
      Database = database
      OPTION = 3
      SOCKET =
      [/bash]

    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

      [bash]
      [asterisk]
      Driver = /usr/lib/odbc/libmyodbc.so
      SERVER = localhost
      PORT = 3306
      DATABASE = database
      OPTION = 3
      USER = user
      PASSWORD = password
      [/bash]

      odbcinst -i -s -l -f gregtest_dsn

      #query systems dsn
      odbcinst -q -s

      #connect
      isql -v asterisk

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

Leave a Reply