Thursday, December 26, 2024
Google search engine
HomeGuest BlogsHow To Install FreePBX 16 on Ubuntu 20.04/18.04/16.04

How To Install FreePBX 16 on Ubuntu 20.04/18.04/16.04

.tdi_3.td-a-rec{text-align:center}.tdi_3 .td-element-style{z-index:-1}.tdi_3.td-a-rec-img{text-align:left}.tdi_3.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_3.td-a-rec-img{text-align:center}}

This article is designed to help you install FreePBX 16 on Ubuntu 20.04/18.04/16.04 and manage it with FreePBX 16 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.

Install Asterisk 18 LTS on Ubuntu 20.04/18.04/16.04 (Optional)

We’ve provided Asterisk installation steps for reference

As we start the installation, it is good practice to ensure all your system packages are latest to avoid any dependency issues:

.tdi_2.td-a-rec{text-align:center}.tdi_2 .td-element-style{z-index:-1}.tdi_2.td-a-rec-img{text-align:left}.tdi_2.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_2.td-a-rec-img{text-align:center}}

sudo apt update && sudo apt -y full-upgrade
[ -f /var/run/reboot-required ] && sudo reboot -f

Step 1: Install Asterisk 18 PBX dependencies

Once the system is online, proceed to install dependency packages for Asterisk PBX.

sudo apt 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 18 source and install dependencies

Since Asterisk 18 LTS is not available from 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 to your local system for installation.

sudo su -
cd /usr/src/
curl -O http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-18-current.tar.gz

Then extract the file:

tar xvf asterisk-18-current.tar.gz
cd asterisk-18*/

.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

install asterisk ubuntu 18.04 01 min

On Core Sound Packages, select the formats of Audio packets like below

install asterisk ubuntu 18.04 02 min

For Music On Hold, select the following minimal modules

install asterisk ubuntu 18.04 03 min

On Extra Sound Packages select as shown below:

install asterisk ubuntu 18.04 04 min

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:

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:

cd
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 2022-04-14 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 18.12.1, Copyright (C) 1999 - 2021, Sangoma Technologies Corporation 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 18.12.1 currently running on ubuntu-20-04-02 (pid = 43531)

ubuntu-20-04-02*CLI> exit
Asterisk cleanly ending (0).
Executing last minute cleanups

Install FreePBX 16 on Ubuntu 20.04/18.04/16.04

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.

1) Install MariaDB database server:

sudo apt install mariadb-server

2) Install and configure Apache

Install apache2 package from apt:

sudo apt 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

Remove default index.html page

sudo rm -f /var/www/html/index.html
sudo unlink  /etc/apache2/sites-enabled/000-default.conf

3) Install PHP

Add APT repository configuration dependencies:

sudo apt install -y lsb-release ca-certificates apt-transport-https software-properties-common gnupg2

Add the PHP packages APT repository to your Debian server.

echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/sury-php.list

Import repository key:

wget -qO - https://packages.sury.org/php/apt.gpg | sudo apt-key add -

Remove any current version of PHP installed:

sudo apt remove php*

FreePBX is dependent on PHP, run the following commands to install php and required extensions.

sudo apt install php7.4 php7.4-{mysql,cli,common,imap,ldap,xml,fpm,curl,mbstring,zip,gd,gettext,xml,json,snmp}

Install PHP Apache module:

sudo apt install libapache2-mod-php7.4

4) Change PHP maximum file upload size:

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
sed -i 's/\(^memory_limit = \).*/\1256M/' /etc/php/7.4/apache2/php.ini

5) Download and Install FreePBX

Use wget to download the latest version of FreePBX 16 as of this writing:

cd ~/
wget http://mirror.freepbx.org/modules/packages/freepbx/7.4/freepbx-16.0-latest.tgz
sudo tar xfz freepbx-16.0-latest.tgz
sudo rm -f freepbx-16.0-latest.tgz
cd freepbx
sudo systemctl stop asterisk
sudo ./start_asterisk start
sudo apt install nodejs npm
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

Install all Freepbx modules

sudo fwconsole ma disablerepo commercial
sudo fwconsole ma installall
sudo fwconsole ma delete firewall
sudo fwconsole reload
sudo fwconsole restart

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 18 with FreePBX 16 on your Ubuntu server. Open up your web browser and connect to the ip_address_or_hostname/admin of your new FreePBX server.

install freepbx ubuntu 18.04 set username min

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 Secure Asterisk and FreePBX from VoIP Fraud and Bruteforce attacks

.tdi_4.td-a-rec{text-align:center}.tdi_4 .td-element-style{z-index:-1}.tdi_4.td-a-rec-img{text-align:left}.tdi_4.td-a-rec-img img{margin:0 auto 0 0}@media(max-width:767px){.tdi_4.td-a-rec-img{text-align:center}}

RELATED ARTICLES

Most Popular

Recent Comments