Skip to main content

Asterisk Freepbx on CentOS (CentOS v7, Asterisk v16, Freepbx v16)

 This covers the installation of Asterisk v16 and Freepbx v16 GUI, from source, on CentOS v7.  

 

Tested on

CentOS v7 x64
Asterisk v16
Freepbx v16
PHP v7.4

Assumptions

Console text mode (multi-user.target)
Installation done as root user (#)

Prerequisites

Ensure a basic server install with initial dependencies to start with.

yum -y update && yum -y groupinstall core && yum -y groupinstall base && yum -y install epel-release && yum -y remove sendmail
yum -y install automake gcc gcc-c++ ncurses-devel openssl-devel libxml2-devel unixODBC-devel libcurl-devel libogg-devel libvorbis-devel speex-devel spandsp-devel freetds-devel net-snmp-devel corosynclib-devel newt-devel popt-devel libtool-ltdl-devel lua-devel sqlite-devel radiusclient-ng-devel portaudio-devel neon-devel libical-devel openldap-devel gmime-devel mysql-devel bluez-libs-devel jack-audio-connection-kit-devel gsm-devel libedit-devel libuuid-devel libsrtp-devel git subversion libxslt-devel kernel-devel audiofile-devel gtk2-devel libtiff-devel libtermcap-devel ilbc-devel python-devel bison tftp-server httpd sox tzdata mysql-connector-odbc mariadb mariadb-server fail2ban jwhois xmlstarlet ghostscript libtiff-tools patch e2fsprogs mpg123 lame gstreamer postfix gamin-python vsftpd apcupsd

PHP

Install repository

yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum install yum-utils

Install PHP v7.4

yum-config-manager --enable remi-php74
yum -y install php php-mysqlnd php-process php-pear php-mbstring php-xml php-gd php-curl

Node.js

curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
yum -y install nodejs

ODBC

cat >> /etc/odbc.ini << EOF
[MySQL-asteriskcdrdb]
Description = MariaDB connection to 'asteriskcdrdb' database
driver = MySQL
server = localhost
database = asteriskcdrdb
Port = 3306
Socket = /var/lib/mysql/mysql.sock
option = 3
Charset=utf8
  
EOF

Miscellaneous

yum localinstall --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm
yum install ffmpeg

Set Timezone

## FIND YOUR TIMEZONE
tzselect
## SET TIMEZONE EXAMPLE
timedatectl set-timezone America/Vancouver
​timedatectl status

Install

DAHDI

Only required if using a physical server and installing telecom hardware.  At this time, versions newer than 2.10.2 (2.11.0 and 2.11.1) do not install correctly.

cd /usr/src
wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-2.10.2+2.10.2.tar.gz
tar zxvf dahdi-linux-complete-2.10*
cd /usr/src/dahdi-linux-complete-2.10*/
make all && make install && make config
systemctl restart dahdi

If make all fails try reboot and run yum install kernel-devel

Asterisk

If upgrading an existing install with older asterisk it is best to run  rm -rf /usr/lib64/asterisk/modules first.

cd /usr/src
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-16-current.tar.gz
tar zxvf asterisk-16-current.tar.gz
cd /usr/src/asterisk-16*/
make distclean

Install release specific dependencies

cd /usr/src/asterisk-16*/
./contrib/scripts/install_prereq install

Configure

cd /usr/src/asterisk-16*/
./configure --libdir=/usr/lib64 --with-jansson-bundled

To view results type nano -v config.log.

Set compile options

cd /usr/src/asterisk-16*/
make menuselect

# Go to Applications and make sure app_macro is checked.
# To add/change compile options afterwards just run make menuselect and make && make install again.

Create Asterisk User, compile, install and set preliminary ownership.

adduser asterisk -s /bin/bash -c "Asterisk User"
make && make install && chown -R asterisk. /var/lib/asterisk

Freepbx

systemctl restart mariadb
cd /usr/src
git clone -b release/16.0 --single-branch https://github.com/freepbx/framework.git freepbx
touch /etc/asterisk/modules.conf
cd /usr/src/freepbx
./start_asterisk start

./install -n

Module install

fwconsole ma downloadinstall framework core voicemail sipsettings infoservices \
featurecodeadmin logfiles callrecording cdr dashboard music soundlang recordings conferences pm2
fwconsole chown
fwconsole reload

Additional modules can be installed via GUI > Admin > Module Admin.

Optionally, install all modules (not recommended).  You may need to run the following commands twice.

fwconsole ma installall
fwconsole chown
fwconsole reload

Configure Freepbx to start on boot

cat >> /etc/systemd/system/freepbx.service << EOF
[Unit]
Description=Freepbx
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 enable freepbx

Post-install tasks

Lock down the database server.

mysql_secure_installation

Answer Y to everything.

Change apache web server settings.

sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php.ini
sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/httpd/conf/httpd.conf
sed -i ':a;N;$!ba;s/AllowOverride None/AllowOverride All/2' /etc/httpd/conf/httpd.conf

Set required services are set to start on boot.

systemctl enable mariadb
systemctl enable httpd
systemctl enable postfix

Finally, reboot for all changes to take effect

reboot

Optional

Log File Rotation

If this is not done the log files will keep growing indefinitely.

nano /etc/logrotate.d/asterisk
/var/spool/mail/asterisk
/var/log/asterisk/full
/var/log/asterisk/dtmf
/var/log/asterisk/fail2ban {
        size 50M
        dateformat -%Y%m%d-%H
        missingok
        rotate 4
        #compress
        notifempty
        sharedscripts
        create 0640 asterisk asterisk
        postrotate
        /usr/sbin/asterisk -rx 'logger reload' > /dev/null 2> /dev/null || true
        endscript
        su root root
}

Set daily log rotate script to run hourly.  Based on above settings they will rotate if larger than 50 MB.  The rotated file will be datestamped and include the hour.  The hourly part prevents duplicate file errors from occurring when multiple rotations are attempted on the same day.

cp /etc/cron.daily/logrotate /etc/cron.hourly

Firewall

systemctl enable firewalld
systemctl restart firewalld
firewall-cmd --permanent --zone=public --add-service={http,https}
firewall-cmd --permanent --zone=public --add-port=5060-5061/tcp
firewall-cmd --permanent --zone=public --add-port=5060-5061/udp
firewall-cmd --permanent --zone=public --add-port=10000-20000/udp
firewall-cmd --reload

TFTP

If you plan to use hardware SIP phones you will probably want to set up TFTP.

yum -y install tftp-server
nano /etc/xinetd.d/tftp

change server_args = -s /var/lib/tftpboot
to server_args = -s /tftpboot

change disable=yes
to disable=no

mkdir /tftpboot
chmod 777 /tftpboot
systemctl restart xinetd
firewall-cmd --permanent --zone=public --add-port=69/udp
firewall-cmd --reload

Test ODBC

odbcinst -s -q

Use username & password in /etc/freepbx.conf to test connectivity to the DB via ODBC. 

isql -v MySQL-asteriskcdrdb freepbxuser somepassword

Test asterisk ODBC access

asterisk -vvvr
CLI> odbc show

Misc. settings

Set php memory_limit = 256M .

sed -i 's/memory_limit = .*/memory_limit = 256M/g' /etc/php.ini
systemctl restart httpd

 

Comments

Popular posts from this blog

Vicidial Scratch installation Alma -9

Step 1 – Download the dependencies   hostnamectl set-hostname xxxxxx.xxxxx.xxx ### Use YOUR SubDomain vi /etc/hosts ##Change domain name for actual server ip (xxx.xxx.xxx.xxx   complete domain name    subdomain only) timedatectl set-timezone Asia/Kolkata yum check-update yum update -y yum -y install epel-release yum update -y yum install git -y yum install -y kernel* sudo dnf install kernel-devel-$(uname -r) -y #Disable SELINUX sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config     reboot Step 2 – Run the Script cd /usr/src/ git clone https://github.com/manish23k/vicidial-install-scripts cd vicidial-install-scripts chmod +x alma-rocky9-ast16.sh ./alma-rocky9-ast16.sh Or the Asterisk 18 version: chmod +x alma-rocky9-ast18.sh ./alma-rocky9-ast18.sh ####For PHP 8 use this script. chmod +x main-installer-php8.sh ./main-installer-php8.sh

How to delete old call logs and other logs in vicidial or goautodial.

Step 1 : SSH to the server using the Putty Step 2:   login to mysql by typing   mysql -p                    (if you dont know password try below command )               mysql -ucron -p1234 Step 3 : select the asterisk database by typing               use asterisk step 4: Run the below command to check total disk occupied by asterisk database                SELECT table_schema AS "asterisk", ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Size (MB)" FROM information_schema.TABLES GROUP BY table_schema; Step 5 : Run the below command to check disk space consumed by each table in asterisk database SELECT table_name AS "Table", ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Size (MB)" FROM information_schema.TABLES WHERE table_schema = "asterisk" ORDER BY (data_length + inde...

Install the No-IP client (Dynamic Update Client) on AlmaLinux 9

 Install the No-IP client (Dynamic Update Client) on AlmaLinux 9 1. Install Required Packages First, install the necessary packages to compile the client from source. sudo dnf install gcc make wget tar 2. Download the No-IP DUC (Dynamic Update Client) Download the latest version of the No-IP DUC. cd /opt wget https://www.noip.com/client/linux/noip-duc-linux.tar.gz 3. Extract the Downloaded File Extract the downloaded tarball. tar -zxvf noip-duc-linux.tar.gz cd noip-2.1.9-1/ 4. Compile the Client Run the following commands to compile the client. sudo make install 5. Configure the No-IP Client After installation, you’ll be prompted to enter your No-IP account credentials (email and password) and choose the hostname(s) to update. If not, you can manually run the configuration: sudo /usr/local/bin/noip2 -C 6. Start the No-IP Client To start the client: sudo /usr/local/bin/noip2 7. Verify Installation To confirm that the No-IP DUC is running, use: sudo /usr/local/bin/noip2 -S 8. Set Up...