Install Asterisk 16 with FreePBX 15 on Ubuntu 20.04/18.04/16.04 & Debian 9
source link: https://computingforgeeks.com/how-to-install-asterisk-16-with-freepbx-15-on-ubuntu-debian/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
This article is designed to help you Install Asterisk 16 on Ubuntu 20.04/18.04/16.04 & Debian 9 and manage it with FreePBX 15 GUI for administering Asterisk. Asterisk is an open source complete PBX system with features of most commercially available PBXes, for example, Conference calling, Direct Inward System Access, Call Parking, and Call Queues and many other features.
For a CentOS check:
How to Install Asterisk 16 LTS on CentOS 7 / Fedora
How to Install Asterisk 16 LTS on CentOS / RHEL 8
Install Asterisk 16 on Ubuntu 20.04/18.04/16.04 & Debian 9
As we start the installation, it is good practice to ensure all your system packages are latest to avoid any dependency issues:
sudo apt update && sudo apt -y upgrade
sudo reboot
Step 1: Install Asterisk 16 PBX dependencies
Once the system is online, proceed to install dependency packages for Asterisk PBX.
sudo apt-get install git curl wget \
libnewt-dev libssl-dev libncurses5-dev \
subversion libsqlite3-dev build-essential \
libjansson-dev libxml2-dev uuid-dev
If you get an error for subversion package on Ubuntu like below:
E: Package 'subversion' has no installation candidate
Then add universe repository and install subversion from it:
sudo add-apt-repository universe
sudo apt update
sudo apt install subversion
Step 2: Download Asterisk 16 source and Install dependencies
Since Asterisk 15 is not available from both Debian and Ubuntu upstream repositories, the installation will be done from source.
$ sudo apt policy asterisk
asterisk:
Installed: (none)
Candidate: 1:13.14.1~dfsg-2+deb9u3
Version table:
1:13.14.1~dfsg-2+deb9u3 500
...
$ sudo apt policy asterisk
asterisk:
Installed: (none)
Candidate: 1:13.18.3~dfsg-1ubuntu4
Download the latest release of Asterisk 15 to your local system for installation.
sudo su -
cd /usr/src/
curl -O http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-16-current.tar.gz
Then extract the file:
tar xvf asterisk-16-current.tar.gz
cd asterisk-16*/
.Run the following command to download the mp3 decoder library into the source tree.
# sudo contrib/scripts/get_mp3_source.sh A addons/mp3/decode_ntom.c A addons/mp3/interface.c A addons/mp3/MPGLIB_README A addons/mp3/common.c A addons/mp3/huffman.h A addons/mp3/tabinit.c A addons/mp3/Makefile A addons/mp3/README A addons/mp3/decode_i386.c A addons/mp3/dct64_i386.c A addons/mp3/MPGLIB_TODO A addons/mp3/mpg123.h A addons/mp3/layer3.c A addons/mp3/mpglib.h Exported revision 202.
Ensure all dependencies are resolved:
sudo contrib/scripts/install_prereq install
This may take some time depending on your internet speed. Make sure you get a success message at the end:
############################################# ## install completed successfully #############################################
Step 3: Build and Install Asterisk from source
When all dependency packages are installed, we are ready to build asterisk PBX system from source code.
You need to first run the configure script which is responsible for making sure all of the dependencies the build and install process is available. It also finds out what uses those dependencies.
./configure
A success should have an output like below:
configure: Menuselect build configuration successfully completed
.$$$$$$$$$$$$$$$=..
.$7$7.. .7$$7:.
.$$:. ,$7.7
.$7. 7$$$$ .$$77
..$$. $$$$$ .$$$7
..7$ .?. $$$$$ .?. 7$$$.
$.$. .$$$7. $$$$7 .7$$$. .$$$.
.777. .$$$$$$77$$$77$$$$$7. $$$,
$$$~ .7$$$$$$$$$$$$$7. .$$$.
.$$7 .7$$$$$$$7: ?$$$.
$$$ ?7$$$$$$$$$$I .$$$7
$$$ .7$$$$$$$$$$$$$$$$ :$$$.
$$$ $$$$$$7$$$$$$$$$$$$ .$$$.
$$$ $$$ 7$$$7 .$$$ .$$$.
$$$$ $$$$7 .$$$.
7$$$7 7$$$$ 7$$$
$$$$$ $$$
$$$$7. $$ (TM)
$$$$$$$. .7$$$$$$ $$
$$$$$$$$$$$$7$$$$$$$$$.$$$$$$
$$$$$$$$$$$$$$$$.
configure: Package configured for:
configure: OS type : linux-gnu
configure: Host CPU : x86_64
configure: build-cpu:vendor:os: x86_64 : pc : linux-gnu :
configure: host-cpu:vendor:os: x86_64 : pc : linux-gnu :
Setup menu options by running the following command:
make menuselect
Use arrow keys to navigate, and Enter key to select.
On Add-ons select chan_ooh323
and format_mp3
as shown below
On Core Sound Packages, select the formats of Audio packets like below
For Music On Hold, select the following minimal modules
On Extra Sound Packages select as shown below:
You can change other configurations you see fit. When done, save and exit then install Asterisk with selected modules:
make
make install
make samples
make config
ldconfig
The make command output:
Building Documentation For: third-party channels pbx apps codecs formats cdr cel bridges funcs tests main res addons
+--------- Asterisk Build Complete ---------+
+ Asterisk has successfully been built, and +
+ can be installed by running: +
+ +
+ make install +
+-------------------------------------------+
Successful make install
output:
make[1]: Leaving directory '/usr/src/asterisk-16.9.0/sounds'
find rest-api -name "*.json" | while read x; do \
/usr/bin/install -c -m 644 $x "/var/lib/asterisk/rest-api" ; \
done
+---- Asterisk Installation Complete -------+
+ +
+ YOU MUST READ THE SECURITY DOCUMENT +
+ +
+ Asterisk has successfully been installed. +
+ If you would like to install the sample +
+ configuration files (overwriting any +
+ existing config files), run: +
+ +
+ For generic reference documentation: +
+ make samples +
+ +
+ For a sample basic PBX: +
+ make basic-pbx +
+ +
+ +
+----------------- or ---------------------+
+ +
+ You can go ahead and install the asterisk +
+ program documentation now or later run: +
+ +
+ make progdocs +
+ +
+ **Note** This requires that you have +
+ doxygen installed on your local system +
+-------------------------------------------+
Create separate user and group to run asterisk services, and assign correct permissions:
sudo groupadd asterisk
sudo useradd -r -d /var/lib/asterisk -g asterisk asterisk
sudo usermod -aG audio,dialout asterisk
sudo chown -R asterisk.asterisk /etc/asterisk
sudo chown -R asterisk.asterisk /var/{lib,log,spool}/asterisk
sudo chown -R asterisk.asterisk /usr/lib/asterisk
Set Asterisk default user to asterisk:
$ sudo vim /etc/default/asterisk AST_USER="asterisk" AST_GROUP="asterisk" $ sudo vim /etc/asterisk/asterisk.conf runuser = asterisk ; The user to run as. rungroup = asterisk ; The group to run as.
Restart asterisk service after making the changes:
sudo systemctl restart asterisk
Enable service to start on boot:
$ sudo systemctl enable asterisk
Executing: /lib/systemd/systemd-sysv-install enable asterisk
Service should return status of running.
$ systemctl status asterisk.service
● asterisk.service - LSB: Asterisk PBX
Loaded: loaded (/etc/init.d/asterisk; generated)
Active: active (running) since Wed 2020-04-29 17:15:14 UTC; 2min 44s ago
Docs: man:systemd-sysv-generator(8)
Tasks: 69 (limit: 2344)
Memory: 44.5M
CGroup: /system.slice/asterisk.service
└─47094 /usr/sbin/asterisk -U asterisk -G asterisk
Apr 29 17:15:14 ubuntu20 systemd[1]: Starting LSB: Asterisk PBX...
Apr 29 17:15:14 ubuntu20 asterisk[47066]: * Starting Asterisk PBX: asterisk
Apr 29 17:15:14 ubuntu20 asterisk[47066]: ...done.
Apr 29 17:15:14 ubuntu20 systemd[1]: Started LSB: Asterisk PBX.
Test to see if you can connect to Asterisk CLI:
$ sudo asterisk -rvv Asterisk 16.9.0, Copyright (C) 1999 - 2018, Digium, Inc. and others. Created by Mark Spencer [email protected] 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 16.9.0 currently running on ubuntu20 (pid = 47094) ubuntu20*CLI>
Step 3: Install FreePBX 15 on Ubuntu 20.04/18.04/16.04 & Debian 9
FreePBX is a web-based open source GUI (graphical user interface) that controls and manages Asterisk (PBX). Now that we have Asterisk running happily, let’s install FreePBX.
Step 1: Install MariaDB database server:
sudo apt install mariadb-server
Step 2: Install and configure Apache
Install apache2 package from apt:
sudo apt-get install apache2
Then set options below:
sudo cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf_orig
sudo sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/apache2/apache2.conf
sudo sed -i 's/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf
Step 3: Install PHP
FreePBX is dependent on PHP installed, run the following commands to install php and required modules.
sudo apt-get -y install wget libapache2-mod-php php php-{pear,cgi,common,curl,mbstring,gd,gettext,mysql,bcmath,zip,xml,imap,json,snmp,fpm}
Step 4: Change PHP maximum file upload size:
For Debian 9:
sudo sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php/7.0/cli/php.ini
sudo sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php/7.0/fpm/php.ini
For Ubuntu 20.04:
sudo sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php/7.4/apache2/php.ini
sudo sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php/7.4/cli/php.ini
For Ubuntu 18.04:
sudo sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php/7.2/apache2/php.ini
sudo sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php/7.2/cli/php.ini
Step 5: Download and Install FreePBX
Use wget to download the latest version of FreePBX – 14 as of this writing:
cd /usr/src
sudo wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-15.0-latest.tgz
sudo tar xfz freepbx-15.0-latest.tgz
sudo rm -f freepbx-15.0-latest.tgz
cd freepbx
sudo ./start_asterisk start
sudo apt install nodejs
sudo ./install -n
Sample output:
Done. All modules installed. Updating Hooks...Done Done installing modules Taking too long? Customize the chown command, See http://wiki.freepbx.org/display/FOP/FreePBX+Chown+Conf Setting Permissions... Setting base permissions...Done Setting specific permissions... 32451 [============================] Finished setting permissions Generating default configurations... Finished generating default configurations You have successfully installed FreePBX
If you encounter an error like below:
Unable to read /etc/asterisk/asterisk.conf or it was missing a directories section
Then edit /etc/asterisk/asterisk.conf
and remove (!) at the first line. Change from
[directories](!) to [directories]
NOTE: Restore the line to [directories](!) after installing FreePBX otherwise Asterisk will fail to start.
Enable Apache Rewrite engine and restart apache2.
sudo a2enmod rewrite
sudo systemctl restart apache2
If you have an active ufw firewall, open http ports and ports 5060,5061
sudo ufw enable
sudo ufw allow 5060
sudo ufw allow 5061
That’s it!. You have a ready Asterisk 15 with FreePBX 15 on your Ubuntu / Debian server. Open up your web browser and connect to the ip_address_or_hostname/admin of your new FreePBX server.
You will see the Admin setup page, set ‘admin‘ account with a password, and configure an email address to receive update notifications.
Login to Administration panel to configure Asterisk.
I highly recommend you read How to secure Asterisk and FreePBX from VoIP Fraud and Bruteforce attacks
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK