Install A2Billing
  • 2,671 views,
  • 2017-06-04,
  • 上傳者: 洪國恩,
  •  0
5c7a580f49bd7dfb177bb0027db41ba1.jpg
步驟
A.
安裝相關套件
yum -y update && yum -y groupinstall core && yum -y groupinstall base && yum -y install epel-release
yum -y install php-mcrypt php-xml perl-DBD-Pg git
 
B.
下載 A2Billing
cd /usr/src
git clone -b 'v2.2.0' --single-branch https://github.com/Star2Billing/a2billing.git
 
透過 composer 安裝
cd /usr/src/a2billing
curl -sS https://getcomposer.org/installer | php
php composer.phar update
php composer.phar install
C.
建立 A2Billing 資料庫 (要先安裝 mariadb)
cd /usr/src/a2billing
mysql -u root -p < DataBase/mysql-5.x/a2billing-createdb-user.sql
 
預設的資料庫帳號密碼如下:
Database name: mya2billing
Database user: a2billinguser
Database user password: a2billing
 
然後就開始執行設定
cd /usr/src/a2billing/DataBase/mysql-5.x
./install-db.sh
D.
複製並修改相關設定檔案
cp /usr/src/a2billing/a2billing.conf /etc/
 
要確定 /etc/a2billing.conf 裡面的檔案 [database] section 設定都跟你的 mariadb 一樣喔!
E.
產生相關的設定檔案與權限設定
touch /etc/asterisk/additional_a2billing_iax.conf
touch /etc/asterisk/additional_a2billing_sip.conf
echo \#include additional_a2billing_sip.conf >> /etc/asterisk/sip_custom.conf
echo \#include additional_a2billing_iax.conf >> /etc/asterisk/iax_custom.conf
chown -Rf asterisk. /etc/asterisk/additional_a2billing_iax.conf
chown -Rf asterisk. /etc/asterisk/additional_a2billing_sip.conf
chmod -R 640 /etc/asterisk
F.
安裝 聲音 檔案
cd /usr/src/a2billing/addons/sounds
./install_a2b_sounds.sh
chown -R asterisk:asterisk /var/lib/asterisk/sounds/
G.
修改 astrisk manager_custom.conf
加上下列設定
[myasterisk]
secret=mycode
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.255.0
read=system,call,log,verbose,command,agent,user
write=system,call,log,verbose,command,agent,user
H.
把 fwconsole 加入黑名單
這個步驟是為了避免 fwconsole 重新啟動後把相關的連結砍了! 所以一定要做喔!
vi /etc/asterisk/freepbx_chown.conf 
加入以下設定
[blacklist]
directory=/var/www/html/a2billing/
I.
新增 a2billing Web 設定
A2billing 有三個主要的畫面,分別是 admin, agent 跟 customer
把這些介面都放到 a2billing 目錄下
mkdir /var/www/html/a2billing

cp -rf /usr/src/a2billing/admin /var/www/html/a2billing
cp -rf /usr/src/a2billing/agent /var/www/html/a2billing
cp -rf /usr/src/a2billing/customer /var/www/html/a2billing
cp -rf /usr/src/a2billing/common /var/www/html/a2billing
cp -rf /usr/src/a2billing/vendor /var/www/html/a2billing

chown -R asterisk. /var/www/html/a2billing
chmod 755 /var/www/html/a2billing/admin/templates_c
chmod 755 /var/www/html/a2billing/customer/templates_c
chmod 755 /var/www/html/a2billing/agent/templates_c
然後就可以連線囉
 
預設的帳號密碼為
account: root
password: changepassword
J.
設定 AGI
mkdir /var/lib/asterisk/agi-bin
cd /usr/src/a2billing/AGI               
cp a2billing.php /var/lib/asterisk/agi-bin
cp a2billing_monitoring.php /var/lib/asterisk/agi-bin
chown -R asterisk. /var/lib/asterisk/agi-bin
chmod 755 /var/lib/asterisk/agi-bin/a2billing.php
chmod 755 /var/lib/asterisk/agi-bin/a2billing_monitoring.php
ln -s /var/www/html/a2billing/common/lib /var/lib/asterisk/agi-bin/lib
ln -s /var/www/html/a2billing/vendor /var/lib/asterisk/vendor
K.
加入 extensions 
可以直接編輯 /etc/asterisk/extensions_custom.conf
加入以下設定
[a2billing-did]
exten => _X.,1,AGI(a2billing.php,1,did)
exten => _X.,n,Hangup()

[a2billing-out]
exten => _X.,1,AGI(a2billing.php,1)
exten => _X.,n,Hangup()
或是在 FreePBX > Admin > Custom Destinations 加上
Target: a2billing-did,${EXTEN},1 
Description: A2Billing - Inbound
 
Target: a2billing-out,${EXTEN},1 
Description: A2Billing - Outbound
 
設定好後就要重新啟動 FreePBX
fwconsole restart
L.
設定 crontab
  • 先把 cron 檔案複製到 /usr/local 並設定權限
    mkdir -p /usr/local/a2billing
    cp -R /usr/src/a2billing/Cronjobs /usr/local/a2billing/
    ln -sf /var/www/html/a2billing/common/lib /usr/local/a2billing/Cronjobs/lib
    chown -R asterisk. /usr/local/a2billing
  • 編輯 crontab 加上以下設定 (crontab -e -u asterisk)
    # update the currency table
    0 6 * * * php /usr/local/a2billing/Cronjobs/currencies_update_yahoo.php
    
    # manage the monthly services subscription
    0 6 1 * * php /usr/local/a2billing/Cronjobs/a2billing_subscription_fee.php
    
    # To check account of each Users and send an email if the balance is less than the user have choice.
    0 * * * * php /usr/local/a2billing/Cronjobs/a2billing_notify_account.php
    
    # this script will browse all the DID that are reserve and check if the customer need to pay for it.
    # bill them or warn them per email to know if they want to pay in order to keep their DIDs.
    0 2 * * * php /usr/local/a2billing/Cronjobs/a2billing_bill_diduse.php
    
    # This script will take care of the recurring service.
    0 12 * * * php /usr/local/a2billing/Cronjobs/a2billing_batch_process.php
    
    # To generate invoices and for each user.
    0 6 * * * php /usr/local/a2billing/Cronjobs/a2billing_batch_billing.php
    
    # to proceed the autodialer
    */5 * * * * php /usr/local/a2billing/Cronjobs/a2billing_batch_autodialer.php
    
    # manage alarms
    0 * * * * php /usr/local/a2billing/Cronjobs/a2billing_alarm.php
    
    # manage archive
    0 12 * * * php /usr/local/a2billing/Cronjobs/a2billing_archive_data_cront.php
    
    #autorefill
    0 10 21 * * php /usr/local/a2billing/Cronjobs/a2billing_autorefill.php
    15 * * * * php /usr/local/a2billing/Cronjobs/a2billing_batch_cache.php
 
M.
加上 Log
mkdir -p /var/log/a2billing

touch /var/log/a2billing/cront_a2b_alarm.log
touch /var/log/a2billing/cront_a2b_autorefill.log
touch /var/log/a2billing/cront_a2b_batch_process.log
touch /var/log/a2billing/cront_a2b_archive_data.log   
touch /var/log/a2billing/cront_a2b_bill_diduse.log   
touch /var/log/a2billing/cront_a2b_subscription_fee.log   
touch /var/log/a2billing/cront_a2b_currency_update.log   
touch /var/log/a2billing/cront_a2b_invoice.log   
touch /var/log/a2billing/cront_a2b_check_account.log   
touch /var/log/a2billing/a2billing_paypal.log
touch /var/log/a2billing/a2billing_epayment.log
touch /var/log/a2billing/a2billing_api_ecommerce_request.log
touch /var/log/a2billing/a2billing_api_callback_request.log
touch /var/log/a2billing/a2billing_api_card.log
touch /var/log/a2billing/a2billing_agi.log

chown -R asterisk. /var/log/a2billing
Facebook 討論區載入中...
資料夾 :
發表時間 :
2017-06-04 19:53:50
觀看數 :
2,671
發表人 :
洪國恩
部門 :
老洪的 IT 學習系統
QR Code :