PBX – Install freePBX 14 + asterisk 14 on Centos 7 +zend-loader

yum install nano -y

Disable selinux
In /etc/sysconfig/selinux , change the following lines:

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

Reboot, and verify the selinux status by running ‘sestatus‘.

SELinux status: disabled

Update Your System

yum -y update
yum -y groupinstall core base "Development Tools"

Install Additional Required Dependencies

yum -y install lynx tftp-server unixODBC mysql-connector-odbc mariadb-server mariadb \
  httpd ncurses-devel sendmail sendmail-cf sox newt-devel libxml2-devel libtiff-devel \
  audiofile-devel gtk2-devel subversion kernel-devel git crontabs cronie \
  cronie-anacron wget vim uuid-devel sqlite-devel net-tools gnutls-devel python-devel texinfo \
  libuuid-devel

Install php 5.6 repositories

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

Install php5.6w

yum remove php*
yum install php56w php56w-pdo php56w-mysql php56w-mbstring php56w-pear php56w-process php56w-xml php56w-opcache php56w-ldap php56w-intl php56w-soap

Install nodejs

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

Install Legacy Pear requirements

pear install Console_Getopt

Firewalld Basic Configuration
You must open port 80 so that you can access the administration interface

firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload

Enable and Start MariaDB

systemctl enable mariadb.service
systemctl start mariadb
Now that our MariaDB database is running, we want to run a simple security script that will remove some dangerous defaults and lock down access to our database system a little bit
mysql_secure_installation

The prompt will ask you for your current root password. Since you just installed MySQL, you most likely won’t have one, so leave it blank by pressing enter. Then the prompt will ask you if you want to set a root password. Do not set a root password. We secure the database automatically, as part of the install script. Apart from that you can chose yes for the rest. This will remove some sample users and databases, disable remote root logins, and load these new rules so that MySQL immediately respects the changes we have made.

Add the Asterisk User

adduser asterisk -m -c "Asterisk User"

Install and Configure Asterisk
Download Asterisk source files.

cd /usr/src
wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz
wget -O jansson.tar.gz https://github.com/akheron/jansson/archive/v2.7.tar.gz
wget http://www.pjsip.org/release/2.4/pjproject-2.4.tar.bz2

Compile and install pjproject

cd /usr/src
tar -xjvf pjproject-2.4.tar.bz2
rm -f pjproject-2.4.tar.bz2
cd pjproject-2.4
CFLAGS='-DPJ_HAS_IPV6=1' ./configure --prefix=/usr --enable-shared --disable-sound\
  --disable-resample --disable-video --disable-opencore-amr --libdir=/usr/lib64
make dep
make
make install

Compile and Install jansson

cd /usr/src
tar vxfz jansson.tar.gz
rm -f jansson.tar.gz
cd jansson-*
autoreconf -i
./configure --libdir=/usr/lib64
make
make install

Compile and install Asterisk

BUG:
Some versions of Asterisk will crash with a missing ari.conf https://issues.asterisk.org/jira/browse/ASTERISK-27026
You may wish to "mkdir -p /etc/asterisk && touch /etc/asterisk/ari.conf" after compiling Asterisk
cd /usr/src
tar xvfz asterisk-13-current.tar.gz
rm -f asterisk-13-current.tar.gz
cd asterisk-*
contrib/scripts/install_prereq install
./configure --libdir=/usr/lib64
contrib/scripts/get_mp3_source.sh
make menuselect

You will be prompted at the point to pick which modules to build. Most of them will already be enabled, but if you want to have MP3 support (eg, for Music on Hold), you need to manually turn on ‘format_mp3’ on the first page.

./configure --with-pjproject-bundled

After selecting ‘Save & Exit’ you can then continue

make
make install
make config
ldconfig
chkconfig asterisk off

Install Asterisk Soundfiles.

The ‘make install’ above installs a standard low-quality base sound file by default. This is suitable if you are on a small, underpowered system (such as a Rasberry Pi), but on a larger system you should install higher quality soundfiles. Note that this installs the (8khz) ‘wav’ soundfiles and G722 (High Definition ‘Wideband’) audio.

cd /var/lib/asterisk/sounds
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en-wav-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-wav-current.tar.gz
tar xvf asterisk-core-sounds-en-wav-current.tar.gz
rm -f asterisk-core-sounds-en-wav-current.tar.gz
tar xfz asterisk-extra-sounds-en-wav-current.tar.gz
rm -f asterisk-extra-sounds-en-wav-current.tar.gz
# Wideband Audio download
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-core-sounds-en-g722-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/sounds/asterisk-extra-sounds-en-g722-current.tar.gz
tar xfz asterisk-extra-sounds-en-g722-current.tar.gz
rm -f asterisk-extra-sounds-en-g722-current.tar.gz
tar xfz asterisk-core-sounds-en-g722-current.tar.gz
rm -f asterisk-core-sounds-en-g722-current.tar.gz

Set Asterisk ownership permissions.

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/

Install and Configure FreePBX

A few small modifications to Apache.

sed -i 's/\(^upload_max_filesize = \).*/\120M/' /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
systemctl restart httpd.service

Download and install FreePBX.

cd /usr/src
wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-14.0-latest.tgz
tar xfz freepbx-14.0-latest.tgz
rm -f freepbx-14.0-latest.tgz
cd freepbx
./start_asterisk start
./install -n

Install Zend Optimizer

Zend Guard optimization depends on both operating system (64/32 bit) and Php version of the server.

 

# arch
x86_64

php -v
PHP 5.4.16 (cli) (built: Jun 23 2015 21:17:27) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

Now we can download the appropriate Zend Guard package for the operating system (centos7/64 bit) and PHP version (PHP 5.4) on the server.

Zend Guard Loader (Runtime for PHP 5.4) 64-bit:

cd /usr/local/src
wget http://downloads.zend.com/guard/6.0.0/ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz
or you can download any version from http://www.zend.com/en/products/loader/downloads#Linux

Extract the down loaded package by using tar (tape Archeive)command:

tar xzvf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz
ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64/
ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64/php-5.4.x/
ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64/php-5.4.x/ZendGuardLoader.so
ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64/README.txt
cd ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64/

The new folder extracted contains ZendGuardLoader.so file and copy it to /etc/php.d/ZendGuard.ini. See example below (use cd command)

# cd php-5.4.x
[[email protected] php-5.4.x]# ll
total 1044
-rwxrwxrwx 1 894 nobody 1068334 May  8  2013 ZendGuardLoader.so

cp ZendGuardLoader.so /usr/lib64/php/modules
mv /usr/lib64/php/modules/ZendGuardLoader.so /usr/lib64/php/modules/ZendguardLoader.so

Now create ZendGuard.ini file inside /etc/php.d directory:

# nano /etc/php.d/Zendguard.ini

Server is 64-bit then add below lines to the file /etc/php.d/Zendguard.ini

; Enable Zend Guard extension
zend_extension=/usr/lib64/php/modules/ZendguardLoader.so
zend_loader.enable=1

Restart apache service to update changes

# systemctl restart httpd.service

Now check it bye using php -v you can see that php is optimized with zend guard

[[email protected] modules]# php -v
PHP 5.4.16 (cli) (built: Jun 23 2015 21:17:27) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
    with Zend Guard Loader v3.3, Copyright (c) 1998-2013, by Zend Technologies

 

 

wget http://download-ib01.fedoraproject.org/pub/epel/7/x86_64/

wget http://download-ib01.fedoraproject.org/pub/epel/7/x86_64/
yum install epel-release
yum install incron