Hướng dẫn cài đặt FusionPBX v4.4 Freeswitch v1.6 CentOS v7 MariaDB Apache

Hướng dẫn cài đặt FusionPBX v4.4 Freeswitch v1.6 CentOS v7 MariaDB Apache

Fusionpbx là một giao diện quản lí đầy đủ tính năng cho Freeswitch. Hướng dẫn này bao gồm cài đặt FusionpbxFreeswitch® với Mariadb Apache trên Centos7.

1.Chuẩn bị
CentOS v7
Freeswitch v1.6
FusionPBX v4.4
MariaDB v5.5
Apache v2.4
PHP v7.1

2.Cài đặt

Cài đặt packages cần thiết.

# yum -y update && yum -y install epel-release
# yum install git nano httpd unixODBC mysql-connector-odbc memcached ghostscript libtiff-devel libtiff-tools at mariadb mariadb-server tftp-server
  • PHP

Cài đặt gói hỗ trợ

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

# yum -y install yum-plugin-replace

Cập nhập lại phiên bản PHP nếu đã cài

# yum replace php-common --replace-with php71u-common
# yum -y install php71u php71u-common php71u-pdo php71u-soap php71u-xml php71u-xmlrpc php71u-mysqlnd php71u-cli php71u-imap php71u-mcrypt php71u-gd php71u-odbc php71u-opcache php71u-json
  • Tắt Selinux

Check status

# sestatus
# sed -i 's/\(^SELINUX=\).*/\SELINUX=disabled/' /etc/selinux/config
  • Tắt Firewall
# systemctl disable firewalld
# systemctl disable iptables
# systemctl stop firewalld
# systemctl stop iptables
  • Set Timezone
# tzselect 
# timedatectl set-timezone Asia/Ho_Chi_Minh
# ​timedatectl status
# systemctl restart rsyslog
  • Cài Memmcached
# nano /etc/sysconfig/memcached
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS="-l 127.0.0.1"
  • Cài đặt

Freeswitch

# rpm -Uvh http://files.freeswitch.org/freeswitch-release-1-6.noarch.rpm
# yum install freeswitch-config-vanilla freeswitch-sounds* freeswitch-lang* freeswitch-lua freeswitch-xml-cdr

Database

# systemctl start mariadb
# password=somepassword
# mysql -e "CREATE DATABASE freeswitch;"
# mysql -e "CREATE DATABASE fusionpbx;"
# mysql -e "GRANT ALL PRIVILEGES ON freeswitch.* TO fusionpbx@localhost IDENTIFIED BY '$password';"
# mysql -e "GRANT ALL PRIVILEGES ON fusionpbx.* TO fusionpbx@localhost IDENTIFIED BY '$password';"
# mysql -e "flush privileges;"

ODBC

# nano /etc/odbc.ini
[freeswitch]
Driver   = MySQL
SERVER   = 127.0.0.1
PORT     = 3306
DATABASE = freeswitch
OPTION  = 67108864
Socket   = /var/lib/mysql/mysql.sock
threading=0
MaxLongVarcharSize=65536

[fusionpbx]
Driver   = MySQL
SERVER   = 127.0.0.1
PORT     = 3306
DATABASE = fusionpbx
OPTION  = 67108864
Socket   = /var/lib/mysql/mysql.sock
threading=0

Test odbc driver

# odbcinst -s -q

Kiểm tra odbc kết nối

# isql -v freeswitch fusionpbx somepassword 
# quit

Fusionpbx

cd /var/www/html
git clone -b 4.4 https://github.com/powerpbx/fusionpbx.git .
Thay thế mặc định  freeswitch conf files với fusionpbx conf files
# mv /etc/freeswitch /etc/freeswitch.orig
# mkdir /etc/freeswitch
# cp -R /var/www/html/resources/templates/conf/* /etc/freeswitch

Copy thư muc music  đến vị tri cài đặt

# mkdir -p /usr/share/freeswitch/sounds/music/default
# mv /usr/share/freeswitch/sounds/music/*000/ /usr/share/freeswitch/sounds/music/default/

Apache

Thêm quyền user apache với file /var/lib/php/sessions 
# usermod -a -G apache freeswitch

Cài http server chạy user/group cúng như Freeswitch
# sed -i "s/User apache/User freeswitch/" /etc/httpd/conf/httpd.conf
# sed -i "s/Group apache/Group daemon/" /etc/httpd/conf/httpd.conf

Gán quyền try cập any .htaccess trong /var/www/html và subdirs 
# sed -i ':a;N;$!ba;s/AllowOverride None/AllowOverride All/2' /etc/httpd/conf/httpd.conf

Set quyền cho thư mục

Ownership
# chown -R freeswitch.daemon /etc/freeswitch /var/lib/freeswitch \
/var/log/freeswitch /usr/share/freeswitch /var/www/html

Directory permissions to 770 (u=rwx,g=rwx,o='')
# find /etc/freeswitch -type d -exec chmod 770 {} \;
# find /var/lib/freeswitch -type d -exec chmod 770 {} \;
# find /var/log/freeswitch -type d -exec chmod 770 {} \;
# find /usr/share/freeswitch -type d -exec chmod 770 {} \;
# find /var/www/html -type d -exec chmod 770 {} \;

File permissions to 664 (u=rw,g=rw,o=r)
# find /etc/freeswitch -type f -exec chmod 664 {} \;
# find /var/lib/freeswitch -type f -exec chmod 664 {} \;
# find /var/log/freeswitch -type f -exec chmod 664 {} \;
# find /usr/share/freeswitch -type f -exec chmod 664 {} \;
# find /var/www/html -type f -exec chmod 664 {} \;

Taọ file cấu hình hệ thống cho freeswitch

# nano /etc/systemd/system/freeswitch.service

[Unit]
Description=FreeSWITCH
Wants=network-online.target
After=syslog.target network-online.target
After=mariadb.service httpd.service

[Service]
Type=forking
User=freeswitch
ExecStartPre=/usr/bin/mkdir -m 0750 -p /run/freeswitch
ExecStartPre=/usr/bin/chown freeswitch:daemon /run/freeswitch
WorkingDirectory=/run/freeswitch
PIDFile=/run/freeswitch/freeswitch.pid
EnvironmentFile=-/etc/sysconfig/freeswitch
ExecStart=/usr/bin/freeswitch -ncwait -nonat $FREESWITCH_PARAMS
ExecReload=/usr/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target
Tạo file biến môi trường.
cat >> /etc/default/freeswitch << EOF
# Uncommented variables will override variables in unit file
# User=""
# Group=""
# DAEMON_OPTS=""
EOF

Mở Freeswitch tự động chạy khi khở động

# systemctl daemon-reload
# systemctl enable freeswitch
# systemctl restart freeswitch
Vào trình duyệt và đăng nhập ip và cài đặt tiếp theo

http://xx.xx.xx.xx

Hoàn thành các bước bên dưới:

Username: superadmin
Password: somesuperadminpassword

Database Name: fusionpbx
Database Username: fusionpbx
Database Password: somepassword(The database user password created earlier)
Create Database Options: uncheck
Create Database Username:
Create Database Password :

Quá trình cài đặt khoảng 2 phút.
Đăng nhập vào Advanced > Default Settings > Adminer(auto_login) > Enabled = True
Reload lại Advanced > Adminer và xem database..

Mở kết nối freeswitch với database

# nano +147 /etc/freeswitch/autoload_configs/switch.conf.xml
<param name="core-db-dsn" value="freeswitch:fusionpbx:somepassword" />
systemctl restart freeswitch

Cấu hình Firewall

# apt -y install firewalld
# systemctl enable firewalld
# systemctl start firewalld

# firewall-cmd --permanent --zone=public --add-service={http,https}
# firewall-cmd --permanent --zone=public --add-port={5060,5061,5080,5081}/tcp
# firewall-cmd --permanent --zone=public --add-port={5060,5061,5080,5081}/udp
# firewall-cmd --permanent --zone=public --add-port=16384-32768/udp
# firewall-cmd --reload
# firewall-cmd --list-all

Tạo script  Backup theo ngày.

# nano /etc/cron.daily/fusionpbx-backup
#!/bin/sh

# set up variables
NOW=$(date +%Y-%m-%d)
DATABASE=fusionpbx
USER=fusionpbx
PASS=somepassword
mkdir -p /var/backups/fusionpbx/mysql

# Xóa  mysql backups nếu hơn 4 ngày
find /var/backups/fusionpbx/mysql/fusionpbx_mysql* -mtime +4 -exec rm {} \;

# Xóa fiel backup chính nếu hơn 4 ngày
find /var/backups/fusionpbx/*.tgz -mtime +4 -exec rm {} \;

# Thực hiện mysql database backup
/usr/bin/mysqldump --opt --user=${USER} --password=${PASS} ${DATABASE} > /var/backups/fusionpbx/mysql/fusionpbx_mysql_${NOW}.sql

# Kết hợp nén và tạo file backup chính
tar -zvcf /var/backups/fusionpbx/backup_${NOW}.tgz /var/backups/fusionpbx/mysql/fusionpbx_mysql_${NOW}.sql \
/var/www/fusionpbx /usr/share/freeswitch/scripts /var/lib/freeswitch/storage \
/var/lib/freeswitch/recordings /etc/fusionpbx /etc/freeswitch
# chmod 755 /etc/cron.daily/fusionpbx-backup

Như vậy là chúng ta đã hoàn thành việc cài Freeswitch thông qua Fusion để quản lí tổng đài.

Chúc các bạn thành công!

Tham khảo: https://docs.fusionpbx.com/en/latest/getting_started/quick_install.html

Bài viết liên quan

Leave a Reply

Your email address will not be published. Required fields are marked *