How to install FreePBX on Arch Linux
This manual-install method builds a FreePBX system on a recent Arch Linux installation with the following specifications:
FreePBX 15
Asterisk compiled from AUR
Parts of these instructions are shared with How to Install FreePBX 15 on Debian 10 with Asterisk 16, PHP 7.3 .
Update system
pacman --noconfirm -Syu
Install required packages
pacman --noconfirm -Sy apache sudo nodejs wget base-devel git cmake unixodbc \
                      alsa-lib speex libvorbis jansson libxslt opus gsm \
                      ffmpeg libsamplerate libsrtp portaudio python swig dd \
                      mariadb cron sox
Create a user that will be used for compilation, set password and switch to this user
As a good security practice you will use the user until end of this manual. Commands that require root permissions are prepended with sudo
.
useradd -s /bin/bash -m instuser
echo "instuser ALL=(ALL) ALL" >>/etc/sudoers
# set password for the user
passwd instuser
su - instuser
# make sure sudo works
sudo -l
# enter password for instuser
# the output should be similar to this:
User instuser may run the following commands on YOURHOST:
   (ALL : ALL) ALL
Initialize and enable mariadb
sudo mariadb-install-db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
sudo systemctl enable --now mysqld
Create a temporary helper function to compile and install package from AUR
function aur_install() {
 cd ~instuser/src
 rm "$1.tar.gz"
 wget "https://aur.archlinux.org/cgit/aur.git/snapshot/$1.tar.gz"
 tar xvf "$1.tar.gz"
 cd $1
 makepkg -i --noconfirm
}
Install a supported PHP version
While installing current PHP from repositories may work but it's more likely that you'll start getting depreciation errors or other issues and will be force to install an older version - one option is to use AUR (if the PKGBUILD is available there):aur_install php73
Another way is to pull the older PKGBUILD from official repositories.# x86_64 arch
sudo pacman --noconfirm -S aspell c-client enchant gd net-snmp postgresql-libs tidy postfix freetds libsodium
cd ~instuser/src
mkdir php73 && cd php73
git init
git config core.sparseCheckout true
git remote add -f origin git://git.archlinux.org/svntogit/packages.git
git checkout $(git log --all --grep='php 7.3' --oneline -1 | awk '{print $1}')
cd trunk/
makepkg -i
# arm
sudo pacman --noconfirm -S aspell c-client enchant gd net-snmp postgresql-libs tidy postfix freetds libsodium
visit https://archlinuxarm.org/packages/armv7h/php/log and get the PKGBUILD and patches manually of the supported PHP version. Then install using
makepkg --skipinteg -i
Install more dependencies from AUR
aur_install mariadb-connector-odbc
aur_install a2enmod-git
# pjproject requires approximately 2 GB of RAM to compile
# so on light systems you may want to create temporary 4GB swap
# file beforehand (otherwise compiler may get killed by OOM killer):
#Â Â sudo dd if=/dev/zero of=swapfile bs=1024000 count=4096
#Â Â sudo chmod 600 /swapfile
#Â Â sudo mkswap /swapfile
#Â Â sudo swapon /swapfile
aur_install pjproject
# if you had swapfile created, remove it now:
#Â Â sudo swapoff /swapfile
#Â Â sudo rm /swapfile
Compile and install asterisk
aur_install asterisk
Pay attention to Asterisk version matrix. If you need older asterisk:Â cd asterisk
 edit PKGBUILD (line with pkgver)
 makepkg -i --skipinteg
Configure and enable PHP and apache
echo "extension=pdo" | sudo tee -a /etc/php/conf.d/freepbx.ini
echo "extension=pdo_mysql.so" | sudo tee -a /etc/php/conf.d/freepbx.ini
echo "extension=gettext" | sudo tee -a /etc/php/conf.d/freepbx.ini
echo "extension=sysvsem" | sudo tee -a /etc/php/conf.d/freepbx.ini
sudo sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php/php.ini
sudo sed -i 's/\(^memory_limit = \).*/\1256M/' /etc/php/php.ini
sudo sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/httpd/conf/httpd.conf
sudo sed -i 's/AllowOverride None/AllowOverride All/' /etc/httpd/conf/httpd.conf
# enable PHP in Apache per https://wiki.archlinux.org/index.php/Apache_HTTP_Server#Using_libphp
sudo a2enmod rewrite
sudo systemctl enable --now httpd
Configure ODBC
cat <<EOF | sudo tee /etc/odbcinst.ini
[MariaDB]
Description = ODBC Driver for MariaDB
Driver     = /usr/lib/libmaodbc.so
FileUsage  = 1
EOF
cat <<EOF | sudo tee /etc/odbc.ini
[MySQL-asteriskcdrdb]
Description = MySQL connection to 'asteriskcdrdb' database
Driver = MySQL
Server = localhost
Database = asteriskcdrdb
Port = 3306
Socket = /run/mysqld/mysqld.sock
Option = 3
EOF
Install FreePBX
cd ~instuser/src
wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-15.0-latest.tgz
tar xvf freepbx-15.0-latest.tgz
cd freepbx/
sudo ./start_asterisk start
ps -ef | grep safe_asteris[k]
sudo ./install -n --webroot=/srv/http
If you get a somewhat illogical error like:Â Checking if Asterisk is running and we can talk to it as the 'asterisk' user...Error!
 Unsupported Version of 17.0.0
 Supported Asterisk versions: 13, 14, 15, 16, 17
edit install.php
and installlib/installcommand.class.php
files:
 change:  if (version_compare($engine_info['version'], "13", "lt") || version_compare($engine_info['version'], "17", "ge")) {
   to  if (version_compare($engine_info['version'], "13", "lt") || version_compare($engine_info['version'], "18", "ge")) {
 and run sudo ./install
-- again
You may need to do this change once more after installation in:/srv/http/admin/libraries/Console/Reload.class.php
Fix permissions
chown -R asterisk:asterisk /srv/http/
chown -R asterisk:asterisk /var/log/asterisk/
chmod 644 /srv/http
Get the rest of the modules
Only a very basic system is installed at this point. You will probably want to install all the modules. Alternatively, you can skip this and pick-and-choose the individual modules you want later.
sudo fwconsole ma installall
sudo fwconsole ma delete firewall
sudo fwconsole ma delete digium_phones
sudo fwconsole r
Apply the current configuration
sudo fwconsole reload
Perform a restart to load all Asterisk modules that had not yet been configured
sudo fwconsole restart
Set up systemd (startup script)
cat <<EOF | sudo tee /etc/systemd/system/freepbx.service
[Unit]
Description=FreePBX VoIP Server
After=mariadb.service
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/fwconsole start -q
ExecStop=/usr/sbin/fwconsole stop -q
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now freepbx