This guide covers the installation of Asterisk v16 and Freepbx v15 GUI, from source, on Debian v9 or v10.
Tested on
Debian v9 (Stretch) and v10 (Buster) x64 minimal install
Asterisk v16
Freepbx v15
PHP v7.3
Assumptions
Console text mode (multi-user.target)
Installation done as root user (su -
)
Prerequisites
Initial upgrade and install
apt update && apt -y upgrade && apt install lsb-release
PHP
# Install dependencies apt -y install curl apt-transport-https ca-certificates
# Add php repository on Debian v9. Optional for Debian v10 as v7.3 is included. wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > \ /etc/apt/sources.list.d/php.list
# Install PHP v7.3 apt update && apt -y install php7.3 php7.3-curl php7.3-cli php7.3-mysql php7.3-mbstring php7.3-gd php7.3-xml
Other
apt -y install locales sngrep build-essential aptitude openssh-server apache2 mariadb-server mariadb-client bison doxygen flex php-pear curl sox libncurses5-dev libssl-dev libmariadbclient-dev mpg123 libxml2-dev libnewt-dev sqlite3 libsqlite3-dev pkg-config automake libtool-bin autoconf git subversion uuid uuid-dev libiksemel-dev tftpd postfix mailutils nano ntp libspandsp-dev libcurl4-openssl-dev libical-dev libneon27-dev libasound2-dev libogg-dev libvorbis-dev libicu-dev libsrtp*-dev unixodbc unixodbc-dev python-dev xinetd e2fsprogs dbus sudo xmlstarlet lame ffmpeg dirmngr linux-headers*
Node.js
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - apt -y install nodejs
ODBC
Install connector
cd /usr/src wget https://downloads.mariadb.com/Connectors/odbc/connector-odbc-2.0.19/\ mariadb-connector-odbc-2.0.19-ga-debian-x86_64.tar.gz tar -zxvf mariadb-connector-odbc-2.0.19*.tar.gz cp lib/libmaodbc.so /usr/lib/x86_64-linux-gnu/odbc/
Create /etc/odbcinst.ini
cat >> /etc/odbcinst.ini << EOF [MySQL] Description = ODBC for MariaDB Driver = /usr/lib/x86_64-linux-gnu/odbc/libmaodbc.so Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so FileUsage = 1 EOF
Create /etc/odbc.ini
cat >> /etc/odbc.ini << EOF [MySQL-asteriskcdrdb] Description = MariaDB connection to 'asteriskcdrdb' database driver = MySQL server = localhost database = asteriskcdrdb Port = 3306 Socket = /var/run/mysqld/mysqld.sock option = 3 EOF
MongoDB
Only required if you plan to use XMPP
wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | sudo apt-key add - echo "deb http://repo.mongodb.org/apt/debian $(lsb_release -sc)/mongodb-org/4.2 main" \ | sudo tee /etc/apt/sources.list.d/mongodb-org-4.2.list apt update && apt install -y mongodb-org systemctl enable mongod
Libjansson
Asterisk v16 requires libjansson >= 2.11.
# Mandatory for Debian v9. Optional for Debian v10 which includes a new enough version. cd /usr/src wget http://www.digip.org/jansson/releases/jansson-2.12.tar.gz tar -zxvf jansson-2.12.tar.gz cd jansson-2.12/ ./configure && make && make install
Set Timezone
## FIND YOUR TIMEZONE tzselect
## SET TIMEZONE EXAMPLE timedatectl set-timezone America/Vancouver
timedatectl status systemctl restart rsyslog
Install
DAHDI
Only required if using a physical server and installing telecom hardware. At this time, versions newer than 2.10.2
(2.11.0
and 2.11.1
) do not install correctly.
cd /usr/src wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-2.10.2+2.10.2.tar.gz tar zxvf dahdi-linux-complete-2.10* cd /usr/src/dahdi-linux-complete-2.10*/ make all && make install && make config systemctl restart dahdi
If make all
fails try reboot and run apt install linux-headers*
Asterisk
If upgrading an existing install with older Asterisk, it is best to run rm -rf /usr/lib/asterisk/modules
first.
cd /usr/src wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-16-current.tar.gz tar zxvf asterisk-16-current.tar.gz cd /usr/src/asterisk-16*/ make distclean
Install additional dependencies
cd /usr/src/asterisk-16*/ ./contrib/scripts/install_prereq install
Configure
cd /usr/src/asterisk-16*/ ./configure --with-pjproject-bundled --with-jansson-bundled
To verify type nano -v config.log
.
Set compile options
cd /usr/src/asterisk-16*/
make menuselect
# Go to Applications and make sure app_macro
is checked. # To change compile options after install simply run make menuselect and make && make install again.
Create Asterisk User, compile, install and set preliminary ownership.
adduser asterisk --disabled-password --gecos "Asterisk User"
make && make install && chown -R asterisk. /var/lib/asterisk
Freepbx
cd /usr/src git clone -b release/15.0 --single-branch https://github.com/freepbx/framework.git freepbx
touch /etc/asterisk/modules.conf cd /usr/src/freepbx ./start_asterisk start ./install -n
# Minimal module install fwconsole ma downloadinstall framework core voicemail sipsettings infoservices \ featurecodeadmin logfiles callrecording cdr dashboard music soundlang recordings conferences
fwconsole chown fwconsole reload
Optionally, install all modules (not recommended). You may need to run the following commands twice.
fwconsole ma installall fwconsole chown fwconsole reload
Set Freepbx to start on boot
cat >> /etc/systemd/system/freepbx.service << EOF [Unit] Description=Freepbx After=mariadb.service [Service] Type=oneshot RemainAfterExit=yes ExecStart=/usr/sbin/fwconsole start ExecStop=/usr/sbin/fwconsole stop [Install] WantedBy=multi-user.target EOF
systemctl enable freepbx
Configure Apache
Add AllowOverride All
to web directory so that .htaccess
is active.
cat >> /etc/apache2/conf-available/allowoverride.conf << EOF <Directory /var/www/html> AllowOverride All </Directory> EOF
a2enconf allowoverride
Change default apache user/group, disable index.html, enable rewrite module
sed -i 's/\(APACHE_RUN_USER=\)\(.*\)/\1asterisk/g' /etc/apache2/envvars sed -i 's/\(APACHE_RUN_GROUP=\)\(.*\)/\1asterisk/g' /etc/apache2/envvars chown asterisk. /run/lock/apache2 mv /var/www/html/index.html /var/www/html/index.html.disable a2enmod rewrite
systemctl restart apache2
Reboot and access GUI
reboot
You should now be able to access the Freepbx GUI at http://yourserverIP
Post-install tasks are mandatory.
Post-install tasks
Lock down the database server.
mysql_secure_installation
Answer Y
to everything.
Log File Rotation
If this is not done the log files will keep growing indefinitely.
nano /etc/logrotate.d/asterisk
/var/spool/mail/asterisk /var/log/asterisk/full /var/log/asterisk/dtmf /var/log/asterisk/fail2ban /var/log/asterisk/freepbx.log /var/log/asterisk/freepbx_security.log /var/log/asterisk/freepbx_debug { weekly missingok rotate 4 #compress notifempty sharedscripts create 0640 asterisk asterisk postrotate /usr/sbin/asterisk -rx 'logger reload' > /dev/null 2> /dev/null || true endscript su root root }
Test ODBC
odbcinst -s -q
Use username & password in /etc/asterisk/res_odbc_additional.conf
to test connectivity to the DB via ODBC.
isql -v MySQL-asteriskcdrdb someusername somepassword
Test asterisk ODBC access
asterisk -vvvr CLI> odbc show
TFTP
If you plan to use hardware SIP phones you will probably want to enable the tftp server.
Create tftp configuration file.
nano /etc/xinetd.d/tftp
service tftp { protocol = udp port = 69 socket_type = dgram wait = yes user = nobody server = /usr/sbin/in.tftpd server_args = /tftpboot disable = no }
Make the directory and restart the daemon to start tftp.
mkdir /tftpboot chmod 777 /tftpboot systemctl restart xinetd
Misc. settings
Set php memory limit and upload max file size.
sed -i 's/memory_limit = .*/memory_limit = 256M/g' /etc/php/7.3/apache2/php.ini sed -i 's/upload_max_filesize = .*/upload_max_filesize = 20M/g' /etc/php/7.3/apache2/php.ini
systemctl restart apache2
Troubleshooting
As the moment there is a bug in Freepbx related to Debian/Ubuntu. If pressing the Apply Config button on the GUI hangs try the following as a temporary work around.
apt purge dirmngr killall -p dirmngr