Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

This manual-install method builds a FreePBX system with the following specifications:

  • FreePBX 15
  • Asterisk 16 from the Debian Buster package repository or compiled
  • PHP 7.3, standard with Debian Buster

Step-by-step guide

Start from a base Debian 10 installation. Login as root and set server role to become SSH and Web server, remove desktop packages:

apt-get -q -y -o APT::Install-Recommends=true -o APT::Get::AutomaticRemove=true install task-web-server
apt-get -q -y -o APT::Install-Recommends=true -o APT::Get::AutomaticRemove=true install task-ssh-server
apt-get -q -y -o APT::Install-Recommends=true -o APT::Get::AutomaticRemove=true install task-desktop-

It is possible to use this to deploy FreePBX + Asterisk on an existing server but you should backup your data just in case.

Update your system

apt-get update && apt-get -y upgrade

Install all the necessary packages

apt install -y build-essential mariadb-server\
  mariadb-client bison flex php php-curl php-cli php-pdo php-mysql php-pear php-gd php-mbstring php-intl\
  curl sox libncurses5-dev libssl-dev mpg123 libxml2-dev libnewt-dev sqlite3\
  libsqlite3-dev pkg-config automake libtool autoconf git unixodbc-dev uuid uuid-dev\
  libasound2-dev libogg-dev libvorbis-dev libicu-dev libcurl4-openssl-dev libical-dev libneon27-dev libsrtp2-dev\
  libspandsp-dev sudo subversion libtool-bin python-dev unixodbc dirmngr sendmail-bin sendmail cmake\
  cron sudo wget curl libmariadb-dev

Create a user that will be used for compilation, set password and switch to this user

As a good security practice you will use the user until end of this manual. Commands that require root permissions are prepended with sudo.

useradd -s /bin/bash -m -g sudo instuser
# set password for the user
passwd instuser
su - instuser
# make sure sudo works
sudo -l
# enter password for instuser
# the output should be similar to this:
User instuser may run the following commands on YOURHOST:
    (ALL : ALL) ALL

Build mariadb-connector-odbc, and install it

i686 and x86_64 arch:

mkdir ~instuser/src && cd ~instuser/src

git clone

cd mariadb-connector-odbc

git checkout debian/3.1.4-1

curl "" > ../mariadb-connector-odbc_3.1.4.orig.tar.gz


cd ..

dpkg -i odbc-mariadb_3.1.4-1_amd64.deb

arm arch:

mkdir ~instuser/src && cd ~instuser/src
wget -O "mariadb-connector-c.tar.gz" "${pkgver}/mariadb-connector-odbc-${pkgver}-ga-src.tar.gz/from/http%3A//"
tar xvf mariadb-connector-c.tar.gz
cd mariadb-*/
mkdir build && cd build
DM_DIR=/usr/lib/arm-linux-gnueabihf cmake ..  -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCONC_WITH_UNIT_TESTS=Off -DCMAKE_C_FLAGS_RELWITHDEBINFO="-I/usr/local/include/mariadb -I/usr/include/mariadb -L/usr/local/lib"
sudo make install

Install Node.js

curl -sL | sudo -E bash -
sudo apt-get install -y nodejs

Install this required Pear module

sudo pear install Console_Getopt

Compile and install DAHDI

If you don't have any physical PSTN hardware attached to this machine (For example, a T1 or E1 card, or a USB device), you may skip this section. Most smaller setups don't need it.

cd ~instuser/src
tar xvf dahdi-linux-complete-current.tar.gz
cd dahdi-linux-complete-*/
make all
sudo make install
sudo make config
tar xvzf libpri-current.tar.gz
cd libpri-*/
sudo make install

Prepare Asterisk

You may either use asterisk package from Buster repository or build it yourself. Both approaches are listed.

Installation from repository

sudo apt install -y asterisk

sudo systemctl disable --now asterisk

cd /etc/asterisk

sudo mkdir DIST

sudo mv * DIST

sudo cp DIST/asterisk.conf .

sudo sed -i 's/(!)//' asterisk.conf

sudo touch modules.conf

sudo touch cdr.conf


cd ~instuser/src
tar xvf asterisk-16-current.tar.gz
cd asterisk-*/
sudo contrib/scripts/install_prereq install
./configure --with-pjproject-bundled --with-jansson-bundled
make -C menuselect cmenuselect
make menuselect.makeopts
menuselect/menuselect --enable app_macro --enable format_mp3 menuselect.makeopts

# alternatively you may run cmenuselect and tune build options there
menuselect/cmenuselect (hit h for built-in help)

sudo make install
sudo make config
sudo ldconfig
sudo systemctl disable asterisk

Configure Apache web server

sudo sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php/7.*/apache2/php.ini
sudo sed -i 's/\(^memory_limit = \).*/\1256M/' /etc/php/7.*/apache2/php.ini
sudo sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/apache2/apache2.conf
sudo sed -i 's/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf
sudo a2enmod rewrite
sudo service apache2 restart
sudo rm /var/www/html/index.html

Configure ODBC

sudo cp /etc/odbcinst.ini /etc/odbcinst.ini.orig 2>/dev/null

cat <<EOF | sudo tee /etc/odbcinst.ini
Description = ODBC for MySQL (MariaDB)
Driver = /usr/lib/x86_64-linux-gnu/odbc/
FileUsage = 1


sudo cp /etc/odbcinst.ini /etc/odbcinst.ini.orig 2>/dev/null
cat <<EOF | sudo tee /etc/odbc.ini

Description = MySQL connection to 'asteriskcdrdb' database
Driver = MySQL
Server = localhost
Database = asteriskcdrdb
Port = 3306
Socket = /var/run/mysqld/mysqld.sock
Option = 3

Download FFMPEG static build for sound file manipulation(x86_64 only)

cd ~instuser/src
wget ""
tar xf ffmpeg-release-amd64-static.tar.xz
cd ffmpeg-4.2.1-amd64-static
sudo mv ffmpeg /usr/local/bin

Install FreePBX

cd ~instuser/src
tar xvf freepbx-15.0-latest.tgz
sudo touch /etc/asterisk/{modules,cdr}.conf
cd freepbx/
sudo ./start_asterisk start
ps -ef | grep safe_asteris[k]
sudo service mysql start
sudo ./install -n

If you want to install Freepbx in another web root (e.g: under /var/www/myroot), add it to --webroot parameter to install script, modify some Apache settings and restart it.

sudo ./install -n --webroot=/var/www/myroot
sudo sed -i 's/\/var\/www\/html/\/var\/www\/myroot/g' /etc/apache2/sites-available/000-default.conf
sudo sed -i 's/\/var\/www\/html/\/var\/www\/myroot/g' /etc/apache2/sites-available/default-ssl.conf
sudo service apache2 restart

Get the rest of the modules

Only a very basic system is installed at this point. You will probably want to install all the modules. Alternatively, you can skip this and pick-and-choose the individual modules you want later.

sudo fwconsole ma installall
sudo fwconsole ma delete firewall
sudo fwconsole ma delete digium_phones
sudo fwconsole r

Install UCP

As of December 15, 2019, the UCP module needs to be installed from the Edge repository due to issue

sudo fwconsole ma --edge downloadinstall ucp
sudo fwconsole ma install webrtc

Apply the current configuration

sudo fwconsole reload

Set symlinks to the correct sound files

cd /usr/share/asterisk
sudo mv sounds sounds-DIST
sudo ln -s /var/lib/asterisk/sounds sounds

Perform a restart to load all Asterisk modules that had not yet been configured

sudo fwconsole restart

Set up systemd (startup script)

cat <<EOF | sudo tee /etc/systemd/system/freepbx.service
Description=FreePBX VoIP Server
ExecStart=/usr/sbin/fwconsole start -q
ExecStop=/usr/sbin/fwconsole stop -q
systemctl daemon-reload
systemctl enable freepbx

Asterisk and FreePBX 15 are installed! Go to the web interface at http://YOUR-IP to finish setup.

  • No labels