Hướng dẫn cài chi tiết từng bước 1
Phiên bản cài đặt như sau:
• Debian v8 (Jessie) x64 minimal
• ASTPP v3.6
• Freeswitch v1.6
• Apache v2.4
• PHP v7.1
• MariaDB v10
apt update && apt upgrade -y && apt installapt -y install git nano dbus sudo apache2 curl sqlite3 haveged lsb-release ghostscript libtiff5-dev libtiff-tools at dirmngr postfix gawk dnsutils openssl ntp libmyodbc unixodbc unixodbc-bin gettextNhớ cài từng bước một
apt -y install apt-transport-https ca-certificateswget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpgecho "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.listapt update && apt -y install php7.1 php7.1-gd php7.1-opcache php7.1-cli php7.1-common php7.1-curl php7.1-sqlite3 php7.1-odbc php7.1-mysql php7.1-xml php7.1-mcrypt php7.1-json php7.1-pdo php-pearcd /usr/srcwget https://downloads.mariadb.com/Connectors/odbc/connector-odbc-3.0.3/\mariadb-connector-odbc-3.0.3-ga-debian-x86_64.tar.gztar -zxvf mariadb-connector-odbc-3.0.3*.tar.gzcp mariadb-connector-odbc-3.0.3*/lib/libmaodbc.so /usr/lib/x86_64-linux-gnu/odbc/Tạo file driver ODBC /etc/odbcinst.ini
## Lưu ý: dạng câu lệnh tiếp theo là mở file /etc/odbcinst.ini sau đó thêm đoạn giữa EOF……..EOF
cat >> /etc/odbcinst.ini << EOF[MySQL]Description = ODBC for MariaDBDriver = /usr/lib/x86_64-linux-gnu/odbc/libmaodbc.soSetup = /usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.soFileUsage = 1 EOFapt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bashapt update && apt -y install mariadb-server# Hãy đặt password cho mysql , nếu không khi cài đặt sẽ bị lỗi
Thêm dòng này:
sql_mode=''vào dưới dòng [mysqld] trong file /etc/mysql.my.cnf sau đó restart mysql
systemctl restart mariadb Kiểm tra trang thái Selinux
sestatusNếu trạng thái là enabled thì mở file /etc/selinux/config Và đổi
SELINUX=disabled Sau đó reboot server
systemctl disable firewalldsystemctl disable iptablessystemctl stop firewalldsystemctl stop iptablestimedatectl set-timezone Asia/Ho_Chi_Minh curl https://files.freeswitch.org/repo/deb/debian/freeswitch_archive_g0.pub | apt-key add -echo "deb http://files.freeswitch.org/repo/deb/freeswitch-1.6/ $(lsb_release -sc) main" > \/etc/apt/sources.list.d/freeswitch.listapt update && apt -y install freeswitch-all freeswitch-all-dbg freeswitch-sounds* freeswitch-music* gdbcd /usr/srcgit clone -b v3.6 https://github.com/iNextrix/ASTPP.git## Gõ từng lệnh mysql và nhập mật khẩu lúc đầu đã tạo
## Tạo DB astpp , USER là astppuser, PASSWORD là 123qwe
mysql -p -e "CREATE DATABASE astpp CHARACTER SET utf8 COLLATE utf8_general_ci;"mysql -p -e "CREATE USER 'astppuser'@'localhost' IDENTIFIED BY '123qwe';"mysql -p -e "GRANT ALL PRIVILEGES ON astpp.* TO 'astppuser'@'localhost' WITH GRANT OPTION;"mysql -p -e "FLUSH PRIVILEGES;"mysql -p astpp < ASTPP/database/astpp-3.0.sqlmysql -p astpp < ASTPP/database/astpp-upgrade-3.5.sqlmysql -p astpp < ASTPP/database/astpp-upgrade-3.6.sqlODBC kết nối giữa Freeswitch và Mysql
cat >> /etc/odbc.ini << EOF[ASTPP]Driver = MySQLSERVER = 127.0.0.1DATABASE = astppUSERNAME = astppuserPASSWORD = 123qwePORT = 3306OPTION = 67108864Socket = /run/mysqld/mysqld.sockthreading = 0charset = utf8EOFTest odbc driver
odbcinst -s -qTest odbc connection
isql -v astpp astppuser 123qwequitCopy and configure Freeswitch files
cd /usr/srccp -R ASTPP/freeswitch/fs /var/www/html/cp -R ASTPP/freeswitch/scripts/* /usr/share/freeswitch/scripts/cp -R ASTPP/freeswitch/sounds/*.wav /usr/share/freeswitch/sounds/en/us/callie/rm -Rf /etc/freeswitch/dialplan/*touch /etc/freeswitch/dialplan/astpp.xmlrm -Rf /etc/freeswitch/directory/*touch /etc/freeswitch/directory/astpp.xmlrm -Rf /etc/freeswitch/sip_profiles/*touch /etc/freeswitch/sip_profiles/astpp.xmlCopy and configure ASTPP files
cd /usr/srcmkdir -p /var/lib/astppcp ASTPP/config/astpp-config.conf /var/lib/astpp/astpp-config.confcp ASTPP/config/astpp.lua /var/lib/astpp/astpp.lua# Copy/config web GUI filescp -R ASTPP/web_interface/astpp /var/www/html/cp ASTPP/web_interface/apache/astpp.conf /etc/apache2/conf-available/astpp.confcp ASTPP/web_interface/apache/astpp.conf /etc/apache2/conf-available/fs.confsed -i "s#log/httpd#log/apache2#g" /etc/apache2/conf-available/astpp.confsed -i "s#log/httpd#log/apache2#g" /etc/apache2/conf-available/fs.confsed -i "s#8081#8735#g" /etc/apache2/conf-available/fs.confsed -i "s#astpp#fs#g" /etc/apache2/conf-available/fs.confmv /var/www/html/astpp/htaccess /var/www/html/astpp/.htaccessa2enconf astppa2enconf fssystemctl reload apache2# Copy ASTPP specific freeswitch config files/bin/cp -R ASTPP/freeswitch/conf/autoload_configs/* /etc/freeswitch/autoload_configs/# ASTPP links to Freeswitch use /usr/local by default. Freeswitch binary packages use /usr/share.sed -i "s#/usr/local/freeswitch/#/usr/share/freeswitch/#g" /etc/freeswitch/autoload_configs/lua.conf.xmlsed -i "s#/usr/local/freeswitch/#/usr/share/freeswitch/#g" /etc/freeswitch/autoload_configs/json_cdr.conf.xmlsed -i "s#/usr/local/freeswitch/#/usr/share/freeswitch/#g" /usr/share/freeswitch/scripts/astpp-callingcards.luased -i "s#/usr/local/freeswitch/#/usr/share/freeswitch/#g" /usr/share/freeswitch/scripts/astpp/astpp.luased -i "s#/usr/local/freeswitch/#/usr/share/freeswitch/#g" /usr/share/freeswitch/scripts/astpp/scripts/astpp.xml.luaCheck IP của server:
ifconfig | sed -En 's/127.0.0.*//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p'
Configure ASTPP config files in /var/lib/astpp
sed -i "s#\(^dbname\).*#dbname = astpp#" /var/lib/astpp/astpp-config.confsed -i "s#\(^dbuser\).*#dbuser = astppuser#" /var/lib/astpp/astpp-config.confsed -i "s#\(^dbpass\).*#dbpass = 123qwe#" /var/lib/astpp/astpp-config.conf##Đổi 192.168.1.3 thành IP server của bạn
sed -i "s#\(^base_url\).*#base_url = http://192.168.1.3:8089/#" /var/lib/astpp/astpp-config.confsed -i "s#\(^DB_USERNAME\).*#DB_USERNAME = \"astppuser\"#" /var/lib/astpp/astpp.luased -i "s#\(^DB_PASSWD\).*#DB_PASSWD = \"123qwe\"#" /var/lib/astpp/astpp.luaCRON
crontab -e# I# Generate Invoice 0 1 * * * cd /var/www/html/astpp/cron/ && php cron.php GenerateInvoice# Low balance notification0 1 * * * cd /var/www/html/astpp/cron/ && php cron.php UpdateBalance# Low balance notification0 0 * * * cd /var/www/html/astpp/cron/ && php cron.php LowBalance # Update currency rate0 0 * * * cd /var/www/html/astpp/cron/ && php cron.php CurrencyUpdate# Email Broadcasting* * * * * cd /var/www/html/astpp/cron/ && php cron.php BroadcastEmailThêm dòng AllowOverride All vào file .htaccess bằng cách gõ lệnh sau:
cat >> /etc/apache2/conf-available/allowoverride.conf << EOF <Directory /var/www/html> AllowOverride All </Directory>EOFChỉnh sửa file "/etc/apache2/conf-available/astpp.conf
nano /etc/apache2/conf-available/astpp.confĐổi các port 8081 thành 8089
a2enconf allowoverrideChange default apache user/group, disable index.html, enable rewrite module
sed -i 's/\(APACHE_RUN_USER=\)\(.*\)/\1freeswitch/g' /etc/apache2/envvarssed -i 's/\(APACHE_RUN_GROUP=\)\(.*\)/\1freeswitch/g' /etc/apache2/envvarschown freeswitch. /run/lock/apache2mv /var/www/html/index.html /var/www/html/index.html.disablea2enmod rewritesystemctl restart apache2It is a good idea to run this anytime there are any changes/moves/adds/upgrades.
# Ownershipchown -R freeswitch. /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 {} \;nano /etc/systemd/system/freeswitch.service
[Unit]Description=FreeSWITCHWants=network-online.targetAfter=syslog.target network.target network-online.targetAfter=mariadb.service apache2.service[Service]Type=forkingUser=freeswitchWorkingDirectory=/run/freeswitchPIDFile=/run/freeswitch/freeswitch.pidEnvironmentFile=-/etc/default/freeswitchExecStart=/usr/bin/freeswitch -ncwait -nonat $FREESWITCH_PARAMSExecReload=/usr/bin/kill -HUP $MAINPID[Install]WantedBy=multi-user.targetCreate the file for adding extra parameters.
cat >> /etc/default/freeswitch << EOF## Type: string## Default: ""## Config: ""## ServiceRestart: freeswitch## if not empty: parameters for freeswitch#FREESWITCH_PARAMS=""EOFsed -i "s#short_open_tag = Off#short_open_tag = On#g" /etc/php/7.1/apache2/php.inised -i "s#;cgi.fix_pathinfo=1#cgi.fix_pathinfo=1#g" /etc/php/7.1/apache2/php.inised -i "s/max_execution_time = 30/max_execution_time = 3000/" /etc/php/7.1/apache2/php.inised -i "s/upload_max_filesize = 2M/upload_max_filesize = 20M/" /etc/php/7.1/apache2/php.inised -i "s/post_max_size = 8M/post_max_size = 20M/" /etc/php/7.1/apache2/php.inised -i "s/memory_limit = 128M/memory_limit = 512M/" /etc/php/7.1/apache2/php.iniapt -y install firewalldsystemctl enable firewalldsystemctl start firewalldfirewall-cmd --permanent --zone=public --add-service={http,https}firewall-cmd --permanent --zone=public --add-port={5060,5061,8081}/tcpfirewall-cmd --permanent --zone=public --add-port={5060,5061}/udpfirewall-cmd --permanent --zone=public --add-port=16384-32768/udpfirewall-cmd --reloadfirewall-cmd --list-allEnable services
systemctl daemon-reloadsystemctl enable freeswitchsystemctl restart freeswitchTest Freeswitch console
If fs_cli command is not working change the following line.
nano +4 /etc/freeswitch/autoload_configs/event_socket.conf.xml<param name="listen-ip" value="127.0.0.1"/>
systemctl restart freeswitch
Mở trình duyệt http://yoursIP:8089
username: adminpassword: adminVideo hướng dẫn: