比較流行的可能是 FreePBX, 另外我正在研讀的是 a2billing, 很多成功的案例通常都是在講 FreePBX, 其他像 AsteriskNOW, 及 PBX in a Flash 等專案也都是基於 FreePBX, 我們當然不會花太多心力在它們上面,主要原因有二,一個最主要原因是這些 GUI 套件都不怎麼提底層的 Asterisk 本身,第二個原因是要找這些 GUI 專案文件很容易,反而專門討論 Asterisk 的中文文件很少。
當然並不是說這些 GUI 專案不好,正因為有這些 GUI 套件才讓 Asterisk 成功起來。只是我想從基礎讀起而已。反過來說,對於一個想快速建立網路電話的人來說,相當建議您直接採用像 AsteriskNOW 這種使用 FreePBX 界面的專案套件來用。
這邊建議一個專案叫 a2billing, 它不止是 Asterisk 的 GUI 界面,而且提供完整的 VoIP 網路電話營運商解決方案。雖然如此,你也千萬別以為下載安裝了 a2billing 之後就可以安心當個網路電話運營商。
首先你可能要安裝一些套件,例如: perl-DBD-Pg subversion libapache2-mod-php5 php5 php5-common php5-cli php5-mysql mysql-server apache2 php5-gd openssh-server php5-mcrypt python-setuptools python-mysqldb,總之,GUI 一般就是像這樣,透過 apache2 + php5 + Mysql
- 取得套件
- mkdir /usr/local/src/a2billing
- git clone https://github.com/Star2Billing/a2billing.git /usr/local/src/a2billing/
- cd /usr/local/src/a2billing
- 複製設定檔: cp a2billing.conf /etc/
- 更新相依套件
- curl -sS https://getcomposer.org/installer | php
- mv composer.phar /usr/local/bin/composer
- composer update && composer install
- 設定資料庫
- mysql -u root -p < DataBase/mysql-5.x/a2billing-createdb-user.sql
這個步驟會產生底下資料庫資訊
database name: mya2billing
database user: a2billinguser
user password: a2billing - cd DataBase/mysql-5.x/ ; ./install-db.sh
- 驗證
- mysql -u root -p mya2billing
這一步會要求你輸入 MySQL 的 root 密碼,請自行根據設定登入 - mysql> show tables;
這一步可以看到相當多表格,以我的來看是 97 個 - mysql> exit
- 修改 /etc/a2billing.conf,修改 [database] 節即可,如下
[database] hostname = localhost port = 3306 user = a2billinguser password = a2billing dbname = mya2billing dbtype = mysql
- 新增設定檔:
touch /etc/asterisk/additional_a2billing_iax.conf touch /etc/asterisk/additional_a2billing_sip.conf echo \#include additional_a2billing_sip.conf >> /etc/asterisk/sip.conf echo \#include additional_a2billing_iax.conf >> /etc/asterisk/iax.conf
- 安裝音頻檔
- cd /usr/local/src/a2billing/addons/sounds
- ./install_a2b_sounds.sh
- 安裝 agi-bin
- cd /usr/local/src/a2billing
- cp -a AGI/*.php common/lib /var/lib/asterisk/agi-bin/
- 安裝網頁界面:
- 將必要的檔案複製/或移動到現有的 apache DocumentRoot 下
- mkdir /var/www/html/a2billing
- mv admin agent common customer vendor webservice /var/www/html/a2billing/
- 新增撥號計劃 /etc/asterisk/extensions.conf
[a2billing]
include => a2billing_callingcard
include => a2billing_monitoring
include => a2billing_voucher
[a2billing_callingcard]
; CallingCard application
exten => _X.,1,NoOp(A2Billing Start)
exten => _X.,n,DeadAgi(a2billing.php|1)
exten => _X.,n,Hangup
[a2billing_voucher]
exten => _X.,1,Answer(1)
exten => _X.,n,DeadAgi(a2billing.php|1|voucher)
;exten => _X.,n,AGI(a2billing.php|1|voucher44) ; will add 44 in front of the callerID for the CID authentication
exten => _X.,n,Hangup
[a2billing_did]
exten => _X.,1,DeadAgi(a2billing.php|1|did)
exten => _X.,2,Hangup - 增加 crontab, 請自行編譯,例如透過 crontab -e
0 6 * * * php /usr/local/src/a2billing/Cronjobs/currencies_update_yahoo.php
0 6 1 * * php /usr/local/src/a2billing/Cronjobs/a2billing_subscription_fee.php
0 * * * * php /usr/local/src/a2billing/Cronjobs/a2billing_notify_account.php
0 2 * * * php /usr/local/src/a2billing/Cronjobs/a2billing_bill_diduse.php
0 12 * * * php /usr/local/src/a2billing/Cronjobs/a2billing_batch_process.php
0 6 * * * php /usr/local/src/a2billing/Cronjobs/a2billing_batch_billing.php
*/5 * * * * php /usr/local/src/a2billing/Cronjobs/a2billing_batch_autodialer.php
0 * * * * php /usr/local/src/a2billing/Cronjobs/a2billing_alarm.php - 手動增加 log files:
mkdir /var/log/a2billing; cd /var/log/a2billing
touch cront_a2b_alarm.log
touch cront_a2b_autorefill.log
touch cront_a2b_batch_process.log
touch cront_a2b_archive_data.log
touch cront_a2b_bill_diduse.log
touch cront_a2b_subscription_fee.log
touch cront_a2b_currency_update.log
touch cront_a2b_invoice.log
touch cront_a2b_check_account.log
touch a2billing_paypal.log
touch a2billing_epayment.log
touch a2billing_api_ecommerce_request.log
touch a2billing_api_callback_request.log
touch a2billing_api_card.log
touch a2billing_agi.log
cd /usr/local/src/a2billing - 修改權限
- chown -R asterisk.asterisk /etc/asterisk /var/{log,run,lib,spool}/asterisk /var/log/a2billing /usr/local/src/a2billing /var/www/html/a2billing
- find /etc/asterisk /var/lib/asterisk /usr/local/src/a2billing -type d -exec chmod 777 {} \;
- 如果您發現網頁看不到或是其它怪怪的時候,很可能就是權限沒設定好,包括這邊寫的可能有遺漏, apache2 也要檢查
- 安裝 daemon
- cd /usr/local/src/a2billing/CallBack/callback-daemon-py/
- easy install sqlalchemy
- cp -a callback_daemon/a2b-callback-daemon.debian /etc/init.d/a2b-callback-daemon
- chmod a+x /etc/init.d/a2b-callback-daemon
- 如果要開機自動執行,請執行:
update-rc.d a2b-callback-daemon defaults - tar zxf dist/callback_daemon-1.0.prod-r1528.tar.gz -C /tmp
- cd /tmp/callback_daemon-1.0.prod-r1528/
- touch callback_daemon/__init__.py
- python setup.py build &&python setup.py bdist_egg && python setup.py install --prefix=/usr
- easy_install dist/callback_daemon-1.0.prod_r1528-py2.7.egg
- 重新啟動系統
- 其實可以透過 service 重啟即可,但是因為我在寫這道食譜時亂試一通,系統後來怪怪的,重新啟動後又一切正常
- 需要重新啟動的或許是底下幾個
- mysql
- apache2
- asterisk
- a2b-callback-daemon
- 測試
用瀏覽器瀏覽 http://localhost/a2billing/admin/
0 意見:
張貼留言