***UPDATE*** Asterisk 16, FreePBX 14, Hylafax 7, Avantfax 3.3.5, IAX Modem 1.2.0 ***WORKING***

Hello All!

I bring you an updated guide to installing FreePBX on CentOS 6 with Asterisk, Avantfax and IAX Modem!

A Complete faxing solution for CentOS 6 with web interface, well here we go!

In this guide I used CentOS 6 Minimal cd and fresh install.

FreePBX 14
Asterisk 16.7.0
AvantFax 3.3.5
IAXModem 1.2.0

CentOS 6.10 x86_64 Minimal Install
01/07/2020

cd /usr/src

vi /etc/sysconfig/network-scripts/ifcfg-eth0

Edit ONBOOT=“yes”

“esc” :w ; :q

/etc/init.d/network restart

cd /usr/src

yum -y install wget nano ntpdate perl-Net-SSLeay perl-Encode-Detect unzip yum-utils

wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6.rpm


yum-config-manager --enable remi
yum-config-manager --enable remi-php56

##ENABLE REMI

setenforce 0
sudo sed -i 's/\(^SELINUX=\).*/\SELINUX=disabled/' /etc/selinux/config

STOP & DISABLE iptables ip6tables
DISABLE CHROOT IN BIND WEBMIN MODULE

chkconfig iptables off
chkconfig ip6tables off
service iptables stop
service ip6tables stop

cd /usr/src
wget http://download.webmin.com/devel/rpm/webmin-current.rpm
rpm -ivh webmin-current.rpm

#wget http://software.virtualmin.com/gpl/scripts/install.sh
#chmod +x install.sh
#sh install.sh

yum clean all
yum -y groupinstall core base "Development Tools"
yum -y install kernel kernel-devel kernel-headers perl system-config*

cd /usr/src
yum -y install gcc gcc-c++ lynx bison mysql-devel mysql-server php php-devel php-mysql php-pear php-mbstring php-xml tftp-server httpd httpd-devel make ncurses-devel libtermcap-devel sendmail sendmail-cf caching-nameserver sox newt-devel libxml2-devel libtiff-devel audiofile-devel gtk2-devel subversion kernel-devel git subversion kernel-devel php-process crontabs cronie cronie-anacron wget vim php-xml uuid-devel libtool sqlite-devel unixODBC mysql-connector-odbc libuuid-devel binutils-devel php-ldap php-bcmath php-gd php-imap php-intl php-opcache php-pecl-mcrypt php-pecl-memcached php-pecl-redis php-pecl-zip php-snmp clang ImageMagick icu-last libicu-last libicu-last-devel

yum -y update && reboot

#HOST SETTINGS

nano /etc/hosts

127.0.0.1 localhost.localdomain localhost
192.168.1.2 your.fqhn.com

#Firewall & Network Settings

system-config-firewall-tui
system-config-network-tui
service network restart

rm -rf /var/www/html/

service mysqld start
mysql_secure_installation
service mysqld stop

yum clean all && sudo yum makecache fast

cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf_orig
sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/httpd/conf/httpd.conf
sed -i 's/AllowOverride None/AllowOverride All/' /etc/httpd/conf/httpd.conf

groupadd asterisk
useradd -r -d /var/lib/asterisk -g asterisk asterisk
usermod -aG audio,dialout asterisk

sudo sed -i 's/\(^post_max_size = \).*/\post_max_size = 128M/' /etc/php.ini
sudo sed -i 's/\(^upload_max_filesize = \).*/\upload_max_filesize = 128M/' /etc/php.ini
sudo sed -i 's/\(^memory_limit = \).*/\memory_limit = 256M/' /etc/php.ini

chkconfig httpd on
service httpd start

reboot
cd /usr/src
yum -y remove nodejs
curl --silent --location https://rpm.nodesource.com/setup_10.x | sudo bash -
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
yum -y install yarn

cd /usr/src
wget https://www.python.org/ftp/python/2.7.17/Python-2.7.17.tgz
tar zxf Python-2.7.17.tgz
cd Python-2.7.17
./configure --prefix=/usr/local --enable-unicode=ucs4 --enable-shared LDFLAGS="-Wl,-rpath /usr/local/lib"
make && make altinstall
strip /usr/local/lib/libpython2.7.so.1.0

nano ~/.bashrc
alias python=/usr/local/bin/python2.7
alias autoreconf=/usr/local/bin/autoconf
alias automake=/usr/local/bin/automake

source ~/.bashrc

cd /usr/src
yum -y install wget vim  net-tools ghostscript perl-devel perl-Net-Telnet

#Ghostscript Fonts Fix

cd /usr/src
wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/ghostscript/ghostscript-fonts-std-8.11.tar.gz
tar zxf ghostscript-fonts-std-8.11.tar.gz
mv fonts/ /usr/share/ghostscript/
nano /usr/share/ghostscript/8.70/Resource/Init/Fontmap.GS

#REPLACE LINE 92
/Courier-Bold (n022004l.pfa) ;

cd /usr/src
wget https://bootstrap.pypa.io/ez_setup.py -O - | python

#Fix Build Path

cd /lib/modules/2.6.32-754.25.1.el6.x86_64/
rm -rf build
ln -s /usr/src/kernels/2.6.32-754.25.1.el6.x86_64 build

#Install DAHDI

cd /usr/src
wget http://downloads.asterisk.org/pub/telephony/dahdi-linux/dahdi-linux-3.1.0.tar.gz
tar zxf dahdi-linux-3.1.0.tar.gz
cd dahdi-linux-3.1.0
make && make install

cd ..
wget http://downloads.asterisk.org/pub/telephony/dahdi-tools/dahdi-tools-3.1.0.tar.gz
tar zxf dahdi-tools-3.1.0.tar.gz
cd dahdi-tools-3.1.0
autoreconf -i
automake --add-missing
./configure --libdir=/usr/lib64 && make && make install && make config

cd ..
wget http://downloads.asterisk.org/pub/telephony/libpri/releases/libpri-1.6.0.tar.gz
tar zxf libpri-1.6.0.tar.gz
cd libpri-1.6.0
make && make install

#Setup Asterisk directories and startup files

mkdir -p /var/lib/digium/licenses/
chown asterisk /var/lib/php/session/
mkdir -p /etc/udev/permissions.d/
/sbin/udevd
chkconfig --add dahdi
/etc/init.d/dahdi start
chkconfig --add httpd
/etc/init.d/httpd start
chkconfig --add named
/etc/init.d/named start
chkconfig --add mysqld
/etc/init.d/mysqld start

cd ..
wget http://www.cpan.org/modules/by-module/Asterisk/asterisk-perl-1.08.tar.gz
tar zxf asterisk-perl-1.08.tar.gz
cd asterisk-perl-1.08
perl Makefile.PL
make all
make install

cd ..
wget http://mpg123.de/download/mpg123-1.25.13.tar.bz2
tar jxf mpg123-1.25.13.tar.bz2
cd mpg123-1.25.13
./configure --libdir=/usr/lib64 && make && make install

cd ..
wget http://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz
tar zxf lame-3.100.tar.gz
cd lame-3.100
./configure --libdir=/usr/lib64 && make && make install

cd ..
wget http://ftp.gnu.org/gnu/texinfo/texinfo-6.7.tar.gz
tar zxf texinfo-6.7.tar.gz
cd texinfo-6.7
./configure --libdir=/usr/lib64 && make && make install

cd ..
wget https://github.com/meduketto/iksemel/archive/master.zip
unzip master.zip
cd iksemel-master
./autogen.sh
./configure --libdir=/usr/lib64 && make && make install

echo "/usr/local/lib" > /etc/ld.so.conf.d/iksemel.conf 
ldconfig

#Install Secure RTP Communications

cd /usr/src
wget https://github.com/cisco/libsrtp/archive/v2.3.0.tar.gz
tar zxf v2.3.0.tar.gz
cd libsrtp-2.3.0
./configure --libdir=/usr/lib64 --enable-openssl && make && make install

echo "/usr/local/include" > /etc/ld.so.conf.d/srtp.conf
ldconfig

cd ..
wget https://www.sqlite.org/2019/sqlite-autoconf-3300100.tar.gz
tar zxf sqlite-autoconf-3300100.tar.gz
cd sqlite-autoconf-3300100
./configure --libdir=/usr/lib64 && make && make install
ldconfig

#Asterisk 16

cd /usr/src
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-16-current.tar.gz
tar zxf asterisk-16-current.tar.gz
cd asterisk-16*
contrib/scripts/get_mp3_source.sh
contrib/scripts/install_prereq install
./configure --libdir=/usr/lib64 --with-crypto --with-ssl --with-mysqlclient --with-srtp  --with-sqlite3
make menuconfig

format_mp3, res_config_mysql, app_confbridge, app_saycounted, cdr_adaptive_odbc, func_odbc, res_srtp, muted, stereorize, streamplayer

make && make install && make config
ldconfig

sed -i 's/\(^upload_max_filesize = \).*/\256M/' /etc/php.ini
sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/httpd/conf/httpd.conf
sed -i 's/AllowOverride None/AllowOverride All/' /etc/httpd/conf/httpd.conf

chown -R asterisk:asterisk /var/lib/php/session
chown -R asterisk:asterisk /var/spool/asterisk/*
chown asterisk. /var/run/asterisk
chown -R asterisk. /etc/asterisk
chown -R asterisk. /var/{lib,log,spool}/asterisk
chown -R asterisk. /usr/lib64/asterisk

#Install FreePBX 14.0

cd /usr/src
wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-14.0-latest.tgz
tar zxf freepbx-14.0-latest.tgz
cd freepbx
mysqladmin -p create asterisk
mysqladmin -p create asteriskcdrdb
mysql -p
GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO [email protected] IDENTIFIED BY 'PASSWORD';
GRANT ALL PRIVILEGES ON asterisk.* TO [email protected] IDENTIFIED BY 'PASSWORD';
flush privileges;
\q
pear channel-update pear.php.net
pear install DB MDB2 MDB2 MDB2#mysql MDB2#mysqli MDB2#sqlite

mkdir -p /var/lib/asterisk/run
ln -s /var/lib/asterisk/run /var/run/asterisk
rm -rf /var/lib/asterisk/mohmp3/moh
ln -s /var/lib/asterisk/moh /var/lib/asterisk/mohmp3

ldconfig

#Install FreePBX

cd /usr/src/freepbx

#pear uninstall db
#pear install db-1.7.14

./start_asterisk start
./install

service httpd restart

#Edit httpd.conf

Options FollowSymLinks
AllowOverride All

mkdir -p /var/www/html/admin/modules/_cache
chmod 777 /etc/amportal.conf
chmod 777 /etc/freepbx.conf
chown -R asterisk:asterisk /var/lib/php/session
chown -R asterisk:asterisk /var/spool/asterisk/*
chown asterisk. /var/run/asterisk
chown -R asterisk. /etc/asterisk
chown -R asterisk. /var/{lib,log,spool}/asterisk
chown -R asterisk. /usr/lib64/asterisk
chown -R asterisk. /var/www/html

fwconsole setting LAUNCH_AGI_AS_FASTAGI 0
fwconsole restart

#Edit Asterisk IAX2 Settings Add Other Options in FreePBX

calltokenoptional = 0.0.0.0/0.0.0.0
maxcallnumbers = 16382
requirecalltoken = no

#Fix exim

yum -y install exim
nano /etc/exim/exim.conf

#Add to Main Configuration

queue_list_requires_admin = false

chmod 755 /var/spool/mqueue

#Install Tesseract

cd /usr/src
wget http://www.leptonica.org/source/leptonica-1.79.0.tar.gz
tar zxf leptonica-1.79.0.tar.gz
cd leptonica-1.79.0
autoreconf
./configure --libdir=/usr/lib64 && make && make install

cd ..
wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
tar zxf autoconf-2.69.tar.gz
cd autoconf-2.69
./configure --libdir=/usr/lib64 && make && make install

cd ..
wget http://ftp.gnu.org/gnu/automake/automake-1.16.1.tar.gz
tar zxf automake-1.16.1.tar.gz
cd automake-1.16.1
./configure --libdir=/usr/lib64 && make && make install

cd ..
wget https://github.com/tesseract-ocr/tesseract/archive/3.04.01.tar.gz
tar zxf 3.04.01.tar.gz
cd tesseract-3.04.01
./configure --libdir=/usr/lib64 && make && make install

#Install IAXModem 1.2.0

cd ..
wget https://sourceforge.net/projects/iaxmodem/files/iaxmodem/iaxmodem-1.2.0/iaxmodem-1.2.0.tar.gz
tar zxf iaxmodem-1.2.0.tar.gz
cd iaxmodem-1.2.0
./configure --libdir=/usr/lib64
./build static
mkdir -p /etc/iaxmodem
mkdir -p /var/log/iaxmodem
cp iaxmodem /usr/local/sbin/

nano /etc/iaxmodem/ttyIAX1
device          /dev/ttyIAX1
owner           uucp:uucp
mode            660
port            4570
refresh         300
server          127.0.0.1
peername        1111
secret          PASSWORD
codec           ulaw
cidname         Fax Server
cidnumber       5555551212
nojitterbuffer

#Install Hylafax

cd /usr/src
wget http://prdownloads.sourceforge.net/hylafax/hylafax-7.0.1.tar.gz
tar zxf hylafax-7.0.1.tar.gz
cd hylafax-7.0.1.tar.gz
./configure

make
make install

faxsetup
mysql_upgrade -p

nano /var/spool/hylafax/etc/config.ttyIAX1
CountryCode:            1
AreaCode:               555
FAXNumber:              1.555.555.1212
LongDistancePrefix:     1
InternationalPrefix:    011
DialStringRules:        "etc/dialrules"
ServerTracing:          1
SessionTracing:         1
RecvFileMode:           0600
LogFileMode:            0600
DeviceMode:             0600
RingsBeforeAnswer:      1
SpeakerVolume:          off
GettyArgs:              "-h %l dx_%s"
LocalIdentifier:        "Fax Server"
TagLineFont:            etc/lutRS18.pcf
TagLineFormat:          "From %%l|%c|Page %%P of %%T"
MaxRecvPages:           200
JobReqNoCarrier:        180
JobReqNoAnswer:         180
FaxRcvdCmd:             bin/faxrcvd.php
DynamicConfig: 		bin/dynconf.php
NotifyCmd:              bin/notify.php
ModemType:              Class1          # use this to supply a hint
ModemResetCmds:         "ATH1\nAT+VCID=1"       # enables CallID display
ModemReadyCmds:         ATH0
Class1AdaptRecvCmd:     AT+FAR=1
Class1TMConnectDelay:   400             # counteract quick CONNECT response
Class1RMQueryCmd:       "!24,48,72,96"  # V.17 fast-train recv doesn't work well
Class1TMQueryCmd:       "!24,48,72,96"  # V.17 fast-train recv doesn't work well
CallIDPattern:          "NMBR="
CallIDPattern:          "NAME="
CallIDPattern:          "ANID="
CallIDPattern:          "NDID="
cd /var/spool/hylafax/etc
chown uucp:uucp config.ttyIAX1

#Edit HylaFAX Verticle Resolution

nano /usr/local/lib/fax/hyla.conf
JobFmt: "%-5j %1a %15o %-15.15e %5P %5D %5i %7z %.25s"
RcvFmt: "%7o %-10t %-25s %-20f %5p %1z %-40e"
PageSize:       na-let
VRes:   196

#ASTERISK MANAGER/DB PASSWORD

faxadduser -a admin FREEPBXMGRPASSWORD
faxdeluser localhost
faxdeluser 127.0.0.1
echo 127.0.0.1 >> /var/spool/hylafax/etc/hosts.hfaxd

nano /etc/init/faxgetty1.conf
start on runlevel 2
start on runlevel 3
start on runlevel 4
start on runlevel 5
stop on runlevel 0
stop on runlevel 1
stop on runlevel 6
respawn
exec /usr/local/sbin/faxgetty ttyIAX1

nano /etc/init/iaxmodem1.conf

start on runlevel 2
start on runlevel 3
start on runlevel 4
start on runlevel 5
stop on runlevel 0
stop on runlevel 1
stop on runlevel 6
respawn
exec /usr/local/sbin/iaxmodem ttyIAX1
nano /etc/rc.local
/usr/local/sbin/fwconsole start
initctl start faxgetty1
initctl start iaxmodem1

#Install AvantFAX

cd /usr/src
wget http://downloads.sourceforge.net/project/avantfax/avantfax-3.3.5.tgz
tar zxf avantfax-3.3.5.tgz
cd avantfax-3.3.5
chown -R asterisk:asterisk *
cd avantfax
ln -s /usr/src/avantfax-3.3.5/avantfax /var/www/html/fax
chown -R asterisk:asterisk /var/www/html/fax
chmod -R 0770 /var/www/html/fax/tmp /var/www/html/fax/faxes
chown -R asterisk:uucp /var/www/html/fax/tmp /var/www/html/fax/faxes
chown -R asterisk:asterisk /var/lib/php/session
mv /usr/local/bin/faxcover /usr/local/bin/faxcover.old
ln -s /var/www/html/fax/includes/faxcover.php /usr/local/bin/faxcover
ln -s /var/www/html/fax/includes/faxrcvd.php /var/spool/hylafax/bin/faxrcvd.php
ln -s /var/www/html/fax/includes/dynconf.php /var/spool/hylafax/bin/dynconf.php
ln -s /var/www/html/fax/includes/notify.php /var/spool/hylafax/bin/notify.php
ln -s /usr/local/bin/faxstat /usr/bin/faxstat
pear channel-update pear.php.net
pear install --alldeps Mail Net_SMTP Mail_mime pear/Auth_SASL2-beta
pear upgrade mdb2-beta mdb2_driver_mysqli-beta
cd ..
mysql -p < create_user.sql
mysql -p avantfax < create_tables.sql

nano /etc/cron.d/avantfax
# runs once an hour to update the phone book
0 * * * * /var/www/html/fax/includes/phb.php
# runs once a day to remove old files
0 0 * * * /var/www/html/fax/includes/avantfaxcron.php -t 2
cp /var/www/html/fax/includes/local_config-example.php /var/www/html/fax/includes/local_config.php

#Edit local_config.php

nano /var/www/html/fax/includes/local_config.php
        $BINARYDIR                      = '/usr/bin';
        $HYLAFAX_PREFIX      		= '/usr/local';
        $HYLASPOOL                      = '/var/spool/hylafax';

define('OCR_BINARY',                    "/usr/local/bin/tesseract");

#HP Fax Test
888-HP-FAX-ME
888-473-2963

#Time Server
time-b.timefreq.bldrdoc.gov

If you have any questions feel free to reach out or email me [email protected]

-Darnel

2 Likes

Nice writeup !

Is the local console showing the warnings? (Most are fixable by redeclaration of some of the function calls. I never got passed the database calls)

A challenge perhaps ? Add t38modem to the mix?

No console errors as Ive repeated this process multiple times on a vps from vultr. If by console warning you mean asterisk -r there may be some files in /etc/asterisk that may need configuration or just deletion if you dont use those features. This guide is fairly simple to get everything up and running.

I will look into t38 modem. IAX modem works well and can transmit over SIP. Just create an IAX extention hook it up to IAX modem and then outbound route it through a SIP trunk. I use voip.ms pretty cheap and reliable.

No, I mean the physical console running on /dev/tty1, there will be floods of warnings about mdb2 connections and other deprecated php calls from php 5.6 running 5.2 written code whenever a fax is received or sent.

Most folks find T38 way more forgiving than g711/T30 , In my case reliability went from aroung 90% to > 99% using various reputable VSP’s.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.