Skip to main content

FreePBX 17 and Asterisk 21 installation on Debian 12

Updated over 2 weeks ago

Introduction

FreePBX is a powerful, open-source graphical user interface (GUI) for managing Asterisk, the world’s most popular open-source telephony engine. By combining them, you can build a complete VoIP PBX with call routing, voicemail, IVR menus, conferencing, and more, all managed through a web dashboard.

In this tutorial, you’ll learn how to install FreePBX 17 with Asterisk 21 on a clean Debian 12 VPS.

Prerequisites

Before you begin, make sure you have:

  • A fresh Debian 12 VPS (recommended at least 2 CPU cores and 2 GB RAM).

  • Root or sudo access.

  • A domain name pointing to your server’s IP (optional, but useful for web access and SSL).

  • Basic familiarity with the Linux command line.

Installation

1. Update the System

apt update && apt upgrade -y

2. Install Required Packages

apt -y install build-essential git curl wget libnewt-dev libssl-dev libncurses5-dev subversion libsqlite3-dev libjansson-dev libxml2-dev uuid-dev default-libmysqlclient-dev htop sngrep lame ffmpeg mpg123 expect vim

3. Install Apache, MariaDB and PHP 8.2

FreePBX 17 supports PHP 8.2 only so if you are running older PHP version or newer PHP version then please remove that version and install the PHP 8.2 version.

apt-get install -y apache2 mariadb-server mariadb-client bison flex php8.2 php8.2-curl php8.2-cli php8.2-common php8.2-mysql php8.2-gd php8.2-mbstring  php8.2-intl php8.2-xml php-pear sox sqlite3 pkg-config automake libtool autoconf unixodbc-dev uuid libasound2-dev libogg-dev libvorbis-dev libicu-dev libcurl4-openssl-dev odbc-mariadb libical-dev libneon27-dev libsrtp2-dev  libspandsp-dev libtool-bin python-dev-is-python3 unixodbc software-properties-common nodejs npm ipset iptables fail2ban php-soap

4. Install Asterisk

Download asterisk source and compilation. Compilation (make command) can take some time, please be patient.

cd /usr/src
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-21-current.tar.gz
tar xvf asterisk-21-current.tar.gz
cd asterisk-21*/
contrib/scripts/get_mp3_source.sh
contrib/scripts/install_prereq install
./configure --libdir=/usr/lib64 --with-pjproject-bundled --with-jansson-bundled
make menuselect
make

After compilation is done, you should see the message in your terminal.

Now, let's proceed with the installation.

make install
make samples
make config
ldconfig

Start and enable Asterisk at boot:

systemctl enable asterisk
systemctl start asterisk

4.1. Create asterisk user and give permission

groupadd asterisk
useradd -r -d /var/lib/asterisk -g asterisk asterisk
usermod -aG audio,dialout asterisk
chown -R asterisk:asterisk /etc/asterisk
chown -R asterisk:asterisk /var/{lib,log,spool}/asterisk
chown -R asterisk:asterisk /usr/lib64/asterisk

sed -i 's|#AST_USER|AST_USER|' /etc/default/asterisk
sed -i 's|#AST_GROUP|AST_GROUP|' /etc/default/asterisk
sed -i 's|;runuser|runuser|' /etc/asterisk/asterisk.conf
sed -i 's|;rungroup|rungroup|' /etc/asterisk/asterisk.conf
echo "/usr/lib64" >> /etc/ld.so.conf.d/x86_64-linux-gnu.conf
ldconfig

4.2. Configure Apache web server

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

4.3. Configure ODBC

cat <<EOF > /etc/odbcinst.ini
[MySQL]
Description = ODBC for MySQL (MariaDB)
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmaodbc.so
FileUsage = 1
EOF
cat <<EOF > /etc/odbc.ini
[MySQL-asteriskcdrdb]
Description = MySQL connection to 'asteriskcdrdb' database
Driver = MySQL
Server = localhost
Database = asteriskcdrdb
Port = 3306
Socket = /var/run/mysqld/mysqld.sock
Option = 3
EOF

5. Install FreePBX

cd /usr/local/src
wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-17.0-latest-EDGE.tgz
tar zxvf freepbx-17.0-latest-EDGE.tgz
cd /usr/local/src/freepbx/
./start_asterisk start
./install -n

Done! You should see message in your terminal "You have successfully installed FreePBX".

6. Access FreePBX Web Interface

Open a browser and go to:

http://your-server-ip/admin

Follow the setup wizard to create an admin account and finish the configuration.

Did this answer your question?