Installing FreePBX 14 on Ubuntu 18.04 or 20

setembro 26, 2023 Por Joel Kern 0

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 forrob:root@fpbxu18:~#

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_configsystemctl 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/nullapt-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 php5.6-cgi php5.6-cli php5.6-curl php5.6-fpm php5.6-gd php5.6-mbstring \  php5.6-mysql php5.6-odbc php5.6-xml php5.6-bcmath php-pear libicu-dev gcc \  g++ makepostfix 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 asteriskchownasterisk. /var/run/asteriskchown-R asterisk. /etc/asteriskchown-R asterisk. /var/{lib,log,spool}/asteriskchown-R asterisk. /usr/lib/asteriskchsh -s /bin/bashasteriskrm-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.inised-i 's/www-data/asterisk/'/etc/apache2/envvarssed-i 's/AllowOverride None/AllowOverride All/'/etc/apache2/apache2.confa2enmod rewriteservice 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/odbccurl -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[MySQL-asteriskcdrdb]Description=MySQL connection to 'asteriskcdrdb'databasedriver=MySQLserver=localhostdatabase=asteriskcdrdbPort=3306Socket=/var/run/mysqld/mysqld.sockoption=3Charset=utf8EOFcat> /etc/odbcinst.ini << EOF[MySQL]Description=ODBC forMySQLDriver=/usr/lib/odbc/libmyodbc5w.soSetup=/usr/lib/odbc/libodbcmy5S.soFileUsage=1EOF

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/mohln-s /usr/share/asterisk/moh/var/lib/asterisk/mohrm-rf /usr/share/asterisk/soundsln-s /var/lib/asterisk/sounds/usr/share/asterisk/soundschown-R asterisk.asterisk /usr/share/asterisk

Download and Install FreePBX 14.

cd/usr/srcwget freepbx-14.0-latest.tgzcdfreepbx./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. 

We hope you enjoy using FreePBX 14!

Automatic Startup

Please note you need to set up FreePBX to start asterisk (and it’s associated services) on bootup. You can view an example systemd startup script here.