Install FreePBX and Asterisk on Ubuntu 22.04

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

Today you will learn how to install FreePBX and Asterisk on Ubuntu 22.04

Asterisk is an Open-Source VOIP server to facilitate business, and other organizations’ communication in terms of Voice calls, Voicemail, call recording, interactive voice response, and conferencing calling.

The system is managed through a web browser where we create

Prerequisites

OS: Ubuntu

Step 1: Install the OS

Step 2: Install the required dependencies

$ apt update -y
$ apt-get install unzip git gnupg2 curl libnewt-dev libssl-dev libncurses5-dev subversion libsqlite3-dev build-essential libjansson-dev libxml2-dev uuid-dev subversion -y

Step 3: Install Asterisk

$ wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-19-current.tar.gz
Note: Asterisk 19 is the latest version. check the latest version using this link $ wget http://downloads.asterisk.org/pub/telephony/asterisk/

Extract the download file

$ tar zxf asterisk-19-current.tar.gz

change the directory to the extracted directory

$ cd asterisk-19.*/
$ contrib/scripts/get_mp3_source.sh
$ contrib/scripts/install_prereq install

Configure Asterisk

$ ./configure

setup menu options

$ make menuselect

Enabe Add-on

Enable Core Sound Module

Enable Music On Hold file packages

Extra Sound Packages

Build Asterisk

$ make -j2

Install Asterisk

$ make install

Install config & sample

$ make samples
$ make config
$ ldconfig

Step 4: Configure further Asterisk option

Create user and group

$ groupadd unixcop
$ useradd -r -d /var/lib/asterisk -g asterisk asterisk

add users to group

$ usermod -aG audio,dialout asterisk

Set permissions

chown -R asterisk.asterisk /etc/asterisk
chown -R asterisk.asterisk /var/{lib,log,spool}/asterisk
chown -R asterisk.asterisk /usr/lib/asterisk

To set the asterisk user as the default user, edit the file “/etc/default/asterisk” and uncomment the following

Edit Asterisk default configuration file as below

$ vi /etc/asterisk/asterisk.conf
Install FreePBX
:wq + enter
$ systemctl restart asterisk
$ systemctl enable asterisk
$ systemctl status asterisk

You will see some errors; run the following commands to remove that.

sed -i 's";[radius]"[radius]"g' /etc/asterisk/cdr.conf
sed -i 's";radiuscfg => /usr/local/etc/radiusclient-ng/radiusclient.conf"radiuscfg => /etc/radcli/radiusclient.conf"g' /etc/asterisk/cdr.conf
sed -i 's";radiuscfg => /usr/local/etc/radiusclient-ng/radiusclient.conf"radiuscfg => /etc/radcli/radiusclient.conf"g' /etc/asterisk/cel.conf

please submit the above second and third command in one line past in notepad and adjust in one line.

$ systemctl restart asterisk

connect the Asterisk

$ asterisk -rvv
$ exit

Step 5: Install FreePBX

Install the dependencies like PHP and MariaDB

$ apt-get install software-properties-common –y
$ add-apt-repository ppa:ondrej/php -y
$ apt-get install apache2 mariadb-server libapache2-mod-php7.2 php7.2 php-pear php7.2-cgi php7.2-
common php7.2-curl php7.2-mbstring php7.2-gd php7.2-mysql php7.2-bcmath php7.2-zip php7.2-
xml php7.2-imap php7.2-json php7.2-snmp
$ apt install mariadb-server
$ sudo add-apt-repository -y ppa:ondrej/php

$ apt-get update

$ sudo apt-get install php7.2 libapache2-mod-php7.2 php7.2-common php7.2-curl php7.2-mbstring php7.2-xmlrpc php7.2-mysql php7.2-gd php7.2-xml php7.2-intl php7.2-ldap php7.2-imagick php7.2-json php7.2-cli

Download FreePBX file

$ wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-15.0-latest.tgz
$ tar -xvzf freepbx-15.0-latest.tgz

$ cd FreePBX

$ apt-get install nodejs -y
$ ./install -n

Change Apache user to asterisk and turn on the AllowOverride option.

Install FreePBX
sed -i 's/^(User|Group).*/\1 asterisk/' /etc/apache2/apache2.conf
sed -i 's/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf

Setup upload_max_filesize to php.ini

sed -i 's/(^upload_max_filesize = )./\120M/' /etc/php/7.2/apache2/php.ini 
sed -i 's/(^upload_max_filesize = )./\120M/' /etc/php/7.2/cli/php.ini

Enable APache rewrite module and restart the services

$ a2enmod rewrite
$systemctl restart apache2

Access FreePBX

http: yourserver ip/admin
Install FreePBX

Thanks !!!

I will create the following blog for creating extensions and calling.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Fazal
Fazal
Solution Architect. passionate about exploring, deploying, and writing about new technologies related to systems, networks, cloud, and microservices.

13 COMMENTS

  1. Nice, but in step: run command “asterisk-rvv” i had failuer (….does /var/run/asterisk.ctl exist?). I checked folder and located “asterisk.ctl” file and i changed atributes with “chmod 777 asterisk.ctl”. After this command “asterisk -rvv” ran without failure.

  2. those commands not working:
    sed -i ‘s/^(User|Group).*/\1 asterisk/’ /etc/apache2/apache2.conf
    sed -i ‘s/(^upload_max_filesize = )./\120M/’ /etc/php/7.2/apache2/php.ini
    sed -i ‘s/(^upload_max_filesize = )./\120M/’ /etc/php/7.2/cli/php.ini

    is necesarry remove “\”:
    sed -i ‘s/^(User|Group).*/1 asterisk/’ /etc/apache2/apache2.conf
    sed -i ‘s/(^upload_max_filesize = )./120M/’ /etc/php/7.2/apache2/php.ini
    sed -i ‘s/(^upload_max_filesize = )./120M/’ /etc/php/7.2/cli/php.ini

  3. Thanks for this guideline,

    but obviously, it should be “groupadd asterisk” and not unixcop, and also I would use FreePBX 16 which allows php7.4 –> no EOL Software

  4. Everything runs smoothly command wise but when i try to access the GUI i get an error 500 on /admin/config.php

    PLEASE HELP!

  5. I get this> sudo ./install -n
    PHP Fatal error: Uncaught Error: Call to undefined function FreePBX\Install\simplexml_load_file() in /home/roland/Downloads/freepbx/install:19
    Stack trace:
    #0 {main}
    thrown in /home/roland/Downloads/freepbx/install on line 19

    what to do? thanks

  6. /install -n
    Assuming you are Database Root
    Checking if SELinux is enabled…Its not (good)!
    Reading /etc/asterisk/asterisk.conf…Done
    Checking if Asterisk is running and we can talk to it as the ‘asterisk’ user…Yes. Determined Asterisk version to be: 19.7.0
    Checking if NodeJS is installed and we can get a version from it…Yes. Determined NodeJS version to be: 12.22.9
    Preliminary checks done. Starting FreePBX Installation
    Checking if this is a new install…Yes (No /etc/freepbx.conf file detected)
    Database Root installation checking credentials and permissions..Connected!
    PHP Fatal error: Declaration of FreePBX\Database::query() must be compatible with PDO::query(string $query, ?int $fetchMode = null, mixed …$fetchModeArgs): PDOStatement|false in /home/ubunturoot/asterisk-19.7.0/freepbx/amp_conf/htdocs/admin/libraries/BMO/Database.class.php on line 239

  7. hello, also for me the installation completed successfully but when i try to access the GUI i get an error 500 on /admin/config.php

  8. Hi, I fixed the 500 error by changing the apache2 user / group :

    #nano /etc/apache2/envvars

    export APACHE_RUN_USER=asterisk
    export APACHE_RUN_GROUP=asterisk

    #systemctl restart apache2

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook