This guide covers the installation of FreePBX and Asterisk on Ubuntu 22.04 LTS. It includes steps to update the system, install necessary dependencies, configure Asterisk, and install FreePBX.
In custom installations of FreePBX, the Admin Module may be missing because it is typically included in pre-built FreePBX distributions but not in custom installations. The Admin Module provides a web-based interface for managing various aspects of the FreePBX system, such as users, permissions, system settings, and module administration.
If the Admin Module is missing, users may need to manually install it or use alternative methods to perform administrative tasks, such as using the command line interface (CLI) or directly editing configuration files. Additionally, some features and functionalities that are typically available through the Admin Module may not be accessible in custom installations unless specifically configured or implemented.
Prerequisites
- A fresh installation of Ubuntu 22.04 LTS
- Root or sudo access
Step 1: Update the System
First, update your system to ensure all existing software is up to date:
apt-get update -y
apt-get upgrade -y
Step 2: Set the Hostname
Set the hostname for your server:
hostnamectl set-hostname freepbx
nano /etc/hosts
Add your DNS/domain to the list in /etc/hosts
.
Step 3: Configure Swap Space
Configure swap space to improve performance:
sudo swapon --show
free -h
df -h
sudo fallocate -l 2G /swapfile
ls -lh /swapfile
sudo chmod 600 /swapfile
ls -lh /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo swapon --show
free -h
sudo cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
sudo nano /etc/sysctl.conf
Add the following lines to /etc/sysctl.conf
:
vm.swappiness=10
vm.vfs_cache_pressure=50
Check the configuration:
cat /etc/sysctl.conf
Step 4: Reboot the System
Reboot your system to apply the changes:
reboot
Step 5: Install Asterisk
Install necessary dependencies for Asterisk:
apt-get install unzip git sox gnupg2 curl libnewt-dev libssl-dev libncurses5-dev subversion libsqlite3-dev build-essential libjansson-dev libxml2-dev libedit-dev uuid-dev subversion -y
Download and install Asterisk:
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-20-current.tar.gz
tar -xvzf asterisk-20-current.tar.gz
cd asterisk-20.*
contrib/scripts/get_mp3_source.sh
contrib/scripts/install_prereq install
./configure
make menuselect
make -j2
make install
make samples
make config
ldconfig
Step 6: Configure Asterisk
Create and configure the Asterisk user and group:
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/lib/asterisk
Edit /etc/default/asterisk
to set the Asterisk user and group:
nano /etc/default/asterisk
Set the following values:
AST_USER="asterisk"
AST_GROUP="asterisk"
Edit /etc/asterisk/asterisk.conf
to set the run user and group:
nano /etc/asterisk/asterisk.conf
Set the following values:
runuser = asterisk
rungroup = asterisk
Restart and enable Asterisk:
systemctl restart asterisk
systemctl enable asterisk
systemctl status asterisk
Fix common errors:
sed -i 's";\[radius\]"\[radius\]"g' /etc/asterisk/cdr.conf
sed -i 's";radiuscfg => /usr/local/etc/radiusclient-ng/radiusclient.conf"radiuscfg => /etc/radcli/radiusclient.conf"g' /etc/asterisk/cdr.conf
sed -i 's";radiuscfg => /usr/local/etc/radiusclient-ng/radiusclient.conf"radiuscfg => /etc/radcli/radiusclient.conf"g' /etc/asterisk/cel.conf
Start Asterisk and connect to the CLI:
systemctl start asterisk
asterisk -rvv
exit
Step 7: Install FreePBX Dependencies
Install necessary dependencies for FreePBX:
apt install software-properties-common
add-apt-repository ppa:ondrej/php -y
apt install apache2 mariadb-server libapache2-mod-php7.4 php7.4 php-pear php7.4-cgi php7.4-common php7.4-curl php7.4-mbstring php7.4-gd php7.4-mysql php7.4-bcmath php7.4-zip php7.4-xml php7.4-imap php7.4-json php7.4-snmp -y
Switch to PHP 7.4 as the default:
sudo a2dismod php*
sudo a2enmod php7.4
sudo systemctl restart apache2
sudo update-alternatives --set php /usr/bin/php7.4
sudo update-alternatives --set phar /usr/bin/phar7.4
sudo update-alternatives --set phar.phar /usr/bin/phar.phar7.4
sudo update-alternatives --set phpize /usr/bin/phpize7.4
sudo update-alternatives --set php-config /usr/bin/php-config7.4
Step 8: Download and Install FreePBX
Download FreePBX:
wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-16.0-latest.tgz
tar -xvzf freepbx-16.0-latest.tgz
cd freepbx
Install Node.js and npm:
apt-get install nodejs npm -y
Install FreePBX:
./install -n
fwconsole ma install pm2
Configure Apache2:
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
Update PHP configuration:
sed -i 's/\(^upload_max_filesize = \).*/\512M/' /etc/php/7.4/apache2/php.ini
sed -i 's/\(^upload_max_filesize = \).*/\512M/' /etc/php/7.4/cli/php.ini
sed -i 's/\(^memory_limit = \).*/\1512M/' /etc/php/7.4/apache2/php.ini
sed -i 's/\(^memory_limit = \).*/\1512M/' /etc/php/7.4/cli/php.ini
Restart Apache:
systemctl restart apache2