Are you eager to harness the power of FreePBX 16 on AWS Debian 10 instance but feeling overwhelmed by the installation process? You’re not alone – setting up FreePBX can be a daunting and time-consuming task, especially when dealing with ISO uploads or cloud services that don’t support them. Fear not! This comprehensive, step-by-step guide will walk you through the entire process of installing FreePBX 16 on a Debian 10 instance on AWS, making it a breeze to unlock its potential and get your system up and running in no time.
Prerequisites
Before we get started, you need to make sure that you have the following prerequisites:
- An AWS account (Learn How to get AWS Free Tier for One Whole Year)
- A Debian instance on AWS (Learn How to Create an EC2 Instance on AWS free Tier)
- Root access to the Debian instance
- Basic knowledge of Linux commands
Note
Initial System Setup
Log in as ‘root’ User
Log in as, or switch to, the Root User
THIS IS IMPORTANT!!!
You can do this with the following commands.
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
service sshd restart
Update Your System
Update your system’s package list and upgrade installed packages by running:
apt-get update && apt-get upgrade -y
Install the SURY Repository Signing Key
Install the required GnuPG package and add the SURY repository signing key and Add the SURY repository for PHP and update your system packages:
apt-get install gnupg2 -y
wget -qO - https://packages.sury.org/php/apt.gpg | sudo apt-key add -
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php7.x.list
apt-get update && apt-get upgrade -y
Install Required Dependencies
Install the necessary dependencies for FreePBX:
apt-get install -y build-essential linux-headers-'uname -r' openssh-server apache2 mariadb-server mariadb-client bison flex php7.4 php7.4-cli php7.4-common php7.4-mysql php7.4-gd php7.4-intl php7.4-xml php-pear curl sox libncurses5-dev libssl-dev mpig12 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 libc-6-dev libcurl4-openssl-dev libical-dev libneon27-dev libsrtp2-dev libspandsp-dev sudo subversion libtool-bin python-dev unixodbc dirmngr sendmail-bin sendmail
Install Node.js
Install Node.js on your system:
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
Reboot Server
Reboot your server to ensure you’re running the latest Linux kernel:
reboot
Install Prerequisites
Ensure that you’re running the latest Linux kernel (at the time of writing, it was 4.19.0-16).
Install MariaDB ODBC and Configure for Asterisk
Download and install the MariaDB ODBC, then configure for Asterisk by following the steps:
cd /usr/src/
wget https://wiki.freepbx.org/download/attachments/202375584/libssl1.0.2_1.0.2u-1_deb9u4_amd64.deb
wget https://wiki.freepbx.org/download/attachments/122487323/mariadb-connector-odbc_3.0.7-1_amd64.deb
dpkg -i libssl1.0.2_1.0.2u-1_deb9u4_amd64.deb
dpkg -i mariadb-connector-odbc_3.0.7-1_amd64.deb
MariaDB Warning!
Go to MySQL:
mysql
Set STRICT_TRANS_TABLES (it’s better if you enter these codes one line at a time):
set global sql_mode=STRICT_TRANS_TABLES;
set sql_mode=STRICT_TRANS_TABLES;
Review your changes:
SELECT @@SQL_MODE, @@GLOBAL.SQL_MODE
Exit MySQL
exit
Install and Configure Asterisk
Install Kernel Source for Asterisk
Run the following command to install the kernel source for Asterisk:
apt-get install linux-headers-$(uname -r)
Download Asterisk Source Files
Download the Asterisk source files using the following command:
cd /usr/src
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-16-current.tar.gz
Compile and Install Asterisk
Use the following commands to compile and install Asterisk (it’s better if you enter these codes one line at a time):
cd /usr/src
tar xvfz asterisk-16-current.tar.gz
rm -f asterisk-16-current.tar.gz
cd asterisk-*
contrib/scripts/get_mp3_source.sh
contrib/scripts/install_prereq install
./configure --with-pjproject-bundled --with-jansson-bundled
Enter your ITU-T Telephone Code(country code). In my case it is Bangladesh so the code is 880 or 88. Then press Tab to select <OK> and hit Enter:
make menuselect.makeopts
menuselect/menuselect --enable app_macro --enable format_mp3 menuselect.makeopts
Now enter the following commands and continue:
make
make install
make config
ldconfig
update-rc.d -f asterisk remove
Install and Configure FreePBX
Create Asterisk User and Set Base File Permissions
Run the following commands to create the Asterisk user and set base file permissions
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
rm -rf /var/www/html
Few Small Modifications to Apache
Make a few small modifications to Apache by running the following commands:
sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php/7.4/apache2/php.ini
cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf_orig
sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/apache2/apache2.conf
sed -i 's/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf
a2enmod rewrite
service apache2 restart
Configure ODBC
Edit /etc/odbcinst.ini and add the following lines:
cat <<EOF > /etc/odbcinst.ini
[MySQL]
Description = ODBC for MySQL (MariaDB)
Driver = /usr/local/lib/libmaodbc.so
FileUsage = 1
EOF
Edit or create /etc/odbc.ini and add the following section:
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
Download and Install FreePBX
Download and install FreePBX using the following commands:
cd /usr/src
wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-16.0-latest.tgz
tar vxfz freepbx-16.0-latest.tgz
rm -f freepbx-16.0-latest.tgz
touch /etc/asterisk/{modules,cdr}.conf
cd freepbx
./start_asterisk start
./install -n
Install All FreePBX Modules
Run the following commands to install all FreePBX modules:
fwconsole ma disablerepo commercial
fwconsole ma installall
fwconsole ma delete firewall
fwconsole reload
fwconsole restart
Configure Firewall Ports on AWS
You need to configure Firewall Ports to access FreePBX and make communicatios:
Ports | TCP/UDP | Purpose | Purpose |
---|---|---|---|
22 | TCP | SSH Console | Port used to allow SSH to the PBX from the outside world. |
80 | TCP | PBX GUI HTTP (Non HTTPS) | Used to access the PBX Admin GUI |
443 | TCP | PBX GUI HTTPS | Used to access the PBX Admin GUI with SSL encryption |
1194 | TCP | OpenVPN server | Used to connect OpenVPN clients to PBX VPN Server. |
For all ports visit FreePBX wiki
Access FreePBX Web Interface
That’s 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, where you can set your admin account password and configure an email address to receive update notifications. To get help with Initial Configurations, go to this page.
There are approximately 50 additional modules that can be installed to enhance the usability of your FreePBX machine. You can install these via Module Admin.
Installing FreePBX on a Debian instance on AWS is not as scary as it sounds. With this tutorial, you can install FreePBX 16 on a Debian instance on AWS with ease. You can use FreePBX to set up a complete PBX system for your business or organization. If you encounter any issues during the installation process, please refer to the FreePBX wiki or community forum for assistance.
2 Comments
My good God!!!!!
I just copy pasted these codes and got the FreePBX runnig.
I wish you very best for next articles
Thanks a lot Steve. I am trying to be more resourceful