Hướng dẫn cài đặt Asterisk Freepbx trên CentOS ( CentOS v7, Asterisk v14, Freepbx v14)

Khóa học VoIP Admin

 

1/ Giới thiệu   #

Hướng dẫn này bao gồm việc cài đặt Asterisk v13 hoặc v14 và Freepbx v14 GUI từ soruce trên CentOS v7

Phiên bản phần mềm:

CentOS v7 x64 

Asterisk v13 và v14  

Freepbx v14

2/ Cài đặt #

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 iksemel-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 jansson-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 mongodb-server

2.1 PHP: #

Cài đặt repository và thay thế bất kì gói PHP hiện có.

yum -y install https://centos7.iuscommunity.org/ius-release.rpm 

yum -y install yum-plugin-replace  

yum replace php --replace-with php56u

Cài đặt PHP v5.6

yum -y install php56u php56u-mysqlnd php56u-process php56u-pear php56u-mbstring php56u-xml php56u-gd php56u-curl

2.2 Node.js #

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

yum -y install nodejs

2.3 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  

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

yum install ffmpeg

2.4 Đặt Timezone #

## FIND YOUR TIMEZONE

tzselect

## SET TIMEZONE EXAMPLE

timedatectl set-timezone America/Vancouver

​timedatectl status

2.5 Cài đặt #

2.5.1 DAHDI   #

Chỉ cần nếu sử dụng server vât lý và cài đặt card TDM .

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

Nếu  make all thất bại hãy thử khởi động lại và chạy apt install linux-headers*

Để cài đặt Asterisk v14, đặt VERSION = 14. Để chuyển đổi version, tốt nhất là chạy rm -rf /usr/lib64/asterisk/modules trước.

# Select Asterisk VERSION=14 or 

VERSION=13  

cd /usr/src  

wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-${VERSION}-current.tar.gz  

tar zxvf asterisk-${VERSION}-current.tar.gz  

cd /usr/src/asterisk-${VERSION}*/  

make distclean

Cài đặt các gói phụ thuộc bổ sung

cd /usr/src/asterisk-${VERSION}*/ 

./contrib/scripts/install_prereq install

2.5.2 Cấu hình #

cd /usr/src/asterisk-${VERSION}*/ 

./configure --libdir=/usr/lib64 --with-pjproject-bundled

Để xem loại kết quả nano -v config.log

Đặt tùy chọn compile

cd /usr/src/asterisk-${VERSION}*/

make menuselect

# Select additional compile options or leave at default and save. 

# To add/change compile options afterwards just run make menuselect and make && make install again

Tạo Asterisk User, biên dịch, cài đặt và thiết lập permission

adduser asterisk -s /sbin/nologin -c "Asterisk User" 

make && make install && chown -R asterisk. /var/lib/asterisk

2.5.3 FreePBX #

systemctl restart mariadb 

cd /usr/src  

git clone -b release/14.0 --single-branch https://github.com/freepbx/framework.git freepbx  
cd /usr/src/freepbx  

./start_asterisk start  

./install -n

Nếu bạn gặp lỗi Could not determine Asterisk version, hãy sửa đổi dòng sau:

nano +266  installlib/installcommand.class.php 

$lastline = exec("runuser" . $answers['user'] . ' -s /bin/bash -c "cd ~/ && asterisk -rx \'core show version\' | grep ^Asterisk 2>&1"', $tmpout, $ret);

2.5.4 Cài đặt Module #

fwconsole ma downloadinstall framework core voicemail sipsettings infoservices \ 

featurecodeadmin logfiles callrecording cdr dashboard music conferences  

fwconsole chown  

fwconsole reload

Các module được bổ sung có thể được cài đặt qua GUI> Admin > Module Admin không khuyến khích cài đặt tất cả module. Bạn rất có thể sẽ cần phải chạy lại các lệnh sau hai lần.

fwconsole ma installall 

fwconsole chown  

fwconsole reload

Cấu hình để Freepbx tự động chạy khi khởi động lại

nano /etc/systemd/system/freepbx.service

[Unit]

Description=Freepbx 

After=mariadb.service

[Service]

Type=oneshot 

RemainAfterExit=yes  

ExecStart=/usr/sbin/fwconsole start  

ExecStop=/usr/sbin/fwconsole stop

[Install]

WantedBy=multi-user.target 

systemctl enable freepbx

2.6 Sau khi cài đặt: #

Bảo mật database

mysql_secure_installation

Thay đổi cấu hình Apache web server

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

Bật các dịch vụ tự động chạy khi khởi động

systemctl enable mariadb 

systemctl enable httpd  

systemctl enable postfix

Khởi động lại server.

reboot

2.7 Cấu hình thêm #

2.7.1 Log File Rotation #

Nếu không được thực hiện, Log Files sẽ tiếp tục tăng dung lượng

nano /etc/logrotate.d/asterisk 

/var/spool/mail/asterisk  

/var/log/asterisk/full  

/var/log/asterisk/dtmf  

/var/log/asterisk/fail2ban {  

weekly  
     
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

2.7.2 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

2.7.3 TFTP #

Nếu bạn dự định sử dụng IP Phone,bạn cần cài đặt TFTP.

yum -y install tftp-server 

nano /etc/xinetd.d/tftp  

thay đổi  server_args = -s /var/lib/tftpboot v 

thay đổi  disable=yes  

thành  disable=no  

mkdir /tftpboot  

chmod 777 /tftpboot  

systemctl restart xinetd  

firewall-cmd --permanent --zone=public --add-port=69/udp  

firewall-cmd --reload

2.7.3 Kiểm tra ODBC #

odbcinst -s -q

Sử dụng username và password trong /etc/asterisk/res_odbc_additional.conf để kiểm tra kết nối với DB thông qua ODBC

isql -v MySQL-asteriskcdrdb someusername somepassword

Kiểm tra truy cập asterisk ODBC

asterisk -vvvr 

CLI> odbc show

2.7.4 Misc. setting #

Set php memory_limit = 256M . 

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

Section

Asterisk

Powered by BetterDocs

Để lại bình luận

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *