Install Asterisk from Source
After logging in to your Ubuntu Server as an user, issue following command to switch to root
sudo suNow you are root, but you need to set password with command
passwdNote that you still wont be able to ssh into your server as root, you would still need to ssh as user and then type su.
Next step would be to install initial dependencies for asterisk
apt-get install build-essential wget libssl-dev libncurses5-dev libnewt-dev libxml2-dev linux-headers-$(uname -r) libsqlite3-dev uuid-dev git subversionNow when we are root and dependencies are satisfied, we can move to /usr/src/ dir and download asterisk there
cd /usr/srcNext we unpack it.
wget downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz
tar zxvf asterisk-13-current.tar.gzNow we need to cd into the newly unpacked directory, but we don't really know what the directory is called. It starts with asterisk-13 and then there is minor version which is at the time of writing this article is 13.10.0 but might change down the road because wget command we have further up, always downloads latest version of Asterisk 13 from here. So we use * (yes, asterisk) to make this guide future proof:
cd asterisk-13*Before we actually compile the asterisk code, we need pjproject as asterisk 13 introduces the support for pjsip. So we will compile it first:
git clone git://github.com/asterisk/pjproject pjprojectAnd now we commence to configuring and compiling the Asterisk code
cd pjproject
./configure --prefix=/usr --enable-shared --disable-sound --disable-resample --disable-video --disable-opencore-amr CFLAGS='-O2 -DNDEBUG'
make dep
make && make install
ldconfig
ldconfig -p |grep pj
cd ..This will install mp3 tones and satisfy additional dependencies which might take some time and ask you for your country code. Following command will compile and install asterisk
contrib/scripts/get_mp3_source.sh
contrib/scripts/install_prereq install
./configure && make menuselect && make && make installWhen that is finished, to avoid making hundred of config files yourself, after install you normally want to run this command, which will make initial config for you:
make samplesAnd for having the start up script installed and enabled to start asterisk on every boot, we run make config, followed by ldconfig:
make configNow we can start asterisk for the first time and see if it actually works.
ldconfig
/etc/init.d/asterisk startand then we can enter asterisk console with command
asterisk -rvvvIf all went well, you should to the console running asterisk as root user. That is not what we want.
So we need to do additional steps to make it run as asterisk user. First we need to stop asterisk. We can now use systemd command systemctl for starting and stopping
systemctl stop asteriskThen we need to add group and user named asterisk.
groupadd asteriskAsterisk needs to be configured to start as the user we just created, we can edit /etc/default/asterisk by hand but it is more efficient to use following two sed commands
useradd -d /var/lib/asterisk -g asterisk asterisk
sed -i 's/#AST_USER="asterisk"/AST_USER="asterisk"/g' /etc/default/asteriskTo run properly, asterisk user needs to be assigned ownership to all essential asterisk directories
sed -i 's/#AST_GROUP="asterisk"/AST_GROUP="asterisk"/g' /etc/default/asterisk
chown -R asterisk:asterisk /var/spool/asterisk /var/run/asterisk /etc/asterisk /var/{lib,log,spool}/asterisk /usr/lib/asteriskThe asterisk.conf also needs to be edited to uncoment lines for runuser and rungroup:
sed -i 's/;runuser = asterisk/runuser = asterisk/g' /etc/asterisk/asterisk.confwhen this is done, reboot the server so Asterisk brings up automatically by systemd, and then type asterisk -rvvv to enter the asterisk console
sed -i 's/;rungroup = asterisk/rungroup = asterisk/g' /etc/asterisk/asterisk.conf
asterisk -rvvvIf you get similar output, mainly that it is running as user asterisk and group asterisk, it means all went well. Basic setup of Asterisk 13 is done and you need to add your dial-plans and extensions to start calling from your softphones.
Asterisk 13.10.0, Copyright (C) 1999 - 2014, Digium, Inc. and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Running as user 'asterisk'
Running under group 'asterisk'
Connected to Asterisk 13.10.0 currently running on ubuntu (pid = 2812)
ubuntu*CLI>
We have also recorded a video on how to install asterisk.
Comments
Post a Comment