Installing FreePBX 14 on Ubuntu 18.04 For Asterisk 16

Installing FreePBX 14 on Ubuntu 18.04 For Asterisk 16 READ FIRST

Manual installations of FreePBX is considered an EXPERTS ONLY exercise. This method of installation is enough to get CORE functionality of FreePBX. Non-commercial modules may not function as expected or detailed in the Wiki’s. Certain modules and features may require additional software to be installed and configured on the server.


Do not use the 18.04.1 ‘-live’ ISO image as it has significant, and critical bugs. If you do so, you will need to run the ‘Is my installation buggy’ fix. Make sure you do not use a -live, image, and instead use an ISO from the cdimages repository.

Installing FreePBX 14 on Ubuntu 18.04 For Asterisk 16 you must enable app_macro in make menuselect

Initial System Setup

Nothing unusual is required when installing the machine, excepted to install openssh-server to accomplish the first step.

Note that this installation guide installs PHP 5.6. PHP 7 and higher is NOT SUPPORTED on FreePBX 14, and is provided on a best-effort basis. FreePBX Framework and higher may install successfully with PHP 7, but it is not recommended.

Log in as, or switch to, the Root User

THIS IS IMPORTANT!  You must run the entire process as root. Attempting to use ‘sudo’ later on will not work. Please don’t ignore this.

rob@fpbxu18:~$ sudo -i
[sudo] password for rob:

It will be helpful to enable ssh logins as root. To do so, you need to enable the ‘PermitRootLogin’ line in /etc/ssh/sshd_config.  You can do this with the following commands:

sed -ir 's/#?PermitRootLog.+/PermitRootLogin yes/' /etc/ssh/sshd_config
systemctl restart sshd

Check if your installation is buggy

There is an issue with Ubuntu 18.04.1 installing incorrectly – See this ticket for more information. Run the command ‘grep backports /etc/apt/sources.list‘ and if it does not return anything, you need to run the fix that we supplied in comment 27.  Note that this forces the use of the US mirrors. If you’re not in the US (eg, if you’re in Australia), you can change the URLs from ‘us.archive’ to ‘au.archive’, by doing something like sed -i 's/us.archive/au.archive/' /etc/apt/sources.list which will speed up your upgrades and installations dramatically.

Update Your System

Now that you have ensured your machine is functioning correctly, you can proceed with the installation (and don’t forget, you must run all of this as root). Start by installing the PHP 5.6 repository, and doing a complete update.

add-apt-repository ppa:ondrej/php /dev/null
apt-get update && apt-get upgrade -y 

Install Dependencies

Note that this uses an older PHP 5.6. FreePBX 15 supports PHP 7.1 and higher.

apt-get install -y openssh-server apache2 mysql-server mysql-client \
  mongodb curl sox mpg123 sqlite3 git uuid libodbc1 unixodbc unixodbc-bin \
  asterisk asterisk-core-sounds-en-wav asterisk-core-sounds-en-g722 \
  asterisk-dahdi asterisk-flite asterisk-modules asterisk-mp3 asterisk-mysql \
  asterisk-moh-opsound-g722 asterisk-moh-opsound-wav asterisk-opus \
  asterisk-voicemail dahdi dahdi-dkms dahdi-linux libapache2-mod-security2 \
  php5.6-mysql php5.6-odbc php5.6-xml php5.6-bcmath php-pear libicu-dev gcc \
  g++ make postfix libapache2-mod-php5.6

As part of this install, you may be asked (possibly several times) for a mysql password. DO NOT SET A MYSQL PASSWORD AT THIS POINT. Your machine will automatically generate a secure password later in the installation.

When prompted for Email configuration, make sure you set this correctly! Most machines will select ‘Internet with smarthost’, and use the SMTP server of your internet provider.

Install nodejs

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

Fix permissions for the Asterisk user

useradd -m asterisk
chown asterisk. /var/run/asterisk
chown -R asterisk. /etc/asterisk
chown -R asterisk. /var/{lib,log,spool}/asterisk
chown -R asterisk. /usr/lib/asterisk
chsh -s /bin/bash asterisk
rm -rf /var/www/html

Remove any ‘sample’ config files left over, and fix errors

These are a security vulnerability and must be removed before installing freepbx. There is also an incompatibility in the Ubuntu-supplied asterisk.conf which needs to be fixed.

rm -rf /etc/asterisk/ext/etc/asterisk/sip/etc/asterisk/pj/etc/asterisk/iax/etc/asterisk/manager*
sed -i 's/.!.//' /etc/asterisk/asterisk.conf

Update Apache configuration

sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php/5.6/cgi/php.ini
sed -i 's/www-data/asterisk/' /etc/apache2/envvars
sed -i 's/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf
a2enmod rewrite
service apache2 restart

Fix ‘Pear-GetOpt’ compatibility issue.

The standard ‘pear-getopt’ uses ‘each’ which is Deprecated in PHP 7.  This simple patch fixes it

sed -i 's/ each(/ @each(/' /usr/share/php/Console/Getopt.php

Install MySQL ODBC Connector

The MySQL ODBC connector is used for CDRs.

Download and install package

mkdir -p /usr/lib/odbc
curl -s | \
  tar -C /usr/lib/odbc --strip-components=2 --wildcards -zxvf - */lib/*so

Configure ODBC

Note that this assumes you haven’t previously configured ODBC on this machine. If so, you will need to manually add the required data.

cat /etc/odbc.ini << EOF
Description=MySQL connection to 'asteriskcdrdb' database
cat /etc/odbcinst.ini << EOF
Description=ODBC for MySQL

Fix Ubuntu/Debian Paths

Debian and Ubuntu use /usr/share/asterisk for things like MOH and Sounds. As sounds are now controlled by FreePBX, you need to delete the system sounds, and link them to the correct location.

rm -rf /var/lib/asterisk/moh
ln -s /usr/share/asterisk/moh /var/lib/asterisk/moh
rm -rf /usr/share/asterisk/sounds
ln -s /var/lib/asterisk/sounds /usr/share/asterisk/sounds
chown -R asterisk.asterisk /usr/share/asterisk

Download and Install FreePBX 14.

cd /usr/src
cd freepbx
./install -n

If an error appears after install, then check php verison.

To downgrade it, launch this cmd line:

# sudo a2dismod php7.x 
# sudo a2enmod php5.6
# sudo update-alternatives --set php /usr/bin/php5.6
# sudo service apache2 restart

You’ve done it!

You can now start using FreePBX.  Open up your web browser and connect to the IP address or hostname of your new FreePBX server.  You will see the Admin setup page, which is where you set your  ‘admin’ account password, and configure an email address to receive update notifications.

Install additional modules

There are (at the time of writing) approximately 50 additional modules that can be installed to enhance the usability of your FreePBX machine – you can install these individually via Module Admin, or, you can simply run ‘fwconsole ma installall‘ to download and install all the additional modules available.

Click to edit this heading

View all projects