A2B 2.1.0 on Debian

    版本為 16:04, 20 Nov 2024

    到這個版本。

    返回到 版本存檔.

    查閱目前版本

    Softwares

    • A2Billing 2.1.0/2.2
    • Debian 7.8/7.11
    • Asterisk 11.18/13

    The basic assumptions of the installation

    • your apache2 default root folder is /var/www
    • your asterisk sounds are under /var/lib/asterisk/sounds
    • your asterisk AGI folder is expected under /var/lib/asterisk/agi-bin
    • your apache2 runs as asterisk (uid)
    • you asterisk runs as asterisk (uid)

    Required password and access info

    • mysql root password
    • A2Billing default database is mya2billing, user is a2billinguser and password is a2billing
    • asterisk manager default information is: [myasterisk] and secret=mycode
    • A2Billing admin default password is: user: root password: changepassword

    Pre-required software packages

    > apt-get install libapache2-mod-php5 php5 php5-common \
    php5-cli php5-mysql mysql-server apache2 php5-gd \
    openssh-server git php5-mcrypt subversion
    

    Configure Apache to run as Asterisk account

    > sed -i "s/\(APACHE_RUN_USER=*\)\(.*\)/\1asterisk/" /etc/apache2/envvars
    > sed -i "s/\(APACHE_RUN_GROUP=*\)\(.*\)/\1asterisk/" /etc/apache2/envvars
    > chown asterisk:asterisk /var/lock/apache2
    > service apache2 restart
    

    Installation

    1. Download and unpack source code

    > cd /usr/local/src
    > wget https://github.com/Star2Billing/a2billing/archive/v2.1.0.tar.gz -O a2billing-2.1.0.tar.gz
    > tar xzf a2billing-2.1.0.tar.gz
    > mv a2billing-2.1.0/ a2billing/
    

    You should have a a2billing tree structure that looks like:

    Files :

    - AGI
    - CHANGELOG
    - COPYING
    - CallBack
    - Cronjobs : Recurrent services run via crontab
    - DataBase : Database Schema / DB Installation
    - FEATURES_LIST
    - a2billing.conf : Main Configuration file
    - addons : Sounds and other addons
    - admin : Admin UI
    - agent : Agent UI
    - customer : Customer UI
    - webservice

    1.1 PHP Composer

    cd /usr/local/src/a2billing
    curl -sS https://getcomposer.org/installer | php
    php composer.phar update
    php composer.phar install 
    

    2. Prepare the Database

    > cd /usr/local/src/a2billing
    > mysql -u root -p < DataBase/mysql-5.x/a2billing-createdb-user.sql
    

    The script with create a database, username and password with the following default values

     Database name is: mya2billing
     Database user is: a2billinguser
     User password is: a2billing

    Create a set of tables and insert some initial basic configuration data:

    > cd DataBase/mysql-5.x/
    > ./install-db.sh
    

    3. Edit the a2billing.conf

    > cp /usr/local/src/a2billing/a2billing.conf /etc/
    

    Edit the file /etc/a2billing.conf

    [database]
    hostname = localhost
    port = 3306
    user = a2billinguser
    password = a2billing
    dbname = mya2billing
    dbtype = mysql
    

    TIPs:

     Ensuring the database connection info is correct.

    4. Fix permissions, files and folders

    SIP and IAX:

    > chmod 777 /etc/asterisk
    > 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
    > chown -R asterisk:asterisk /etc/asterisk
    

    Sound Files:
    If the OS is Debian and Asterisk' sounds folder is /var/lib/asterisk/sounds, you have to change the line below in the script a2billing/addons/sounds/install_a2b_sounds.sh

    case $DIST in
        'DEBIAN')
                    #ast_sound=/usr/share/asterisk/sounds
                    ast_sound=/var/lib/asterisk/sounds
            ;;
        'CENTOS')
                    ast_sound=/var/lib/asterisk/sounds
            ;;
    esac
    
    > cd /usr/local/src/a2billing/addons/sounds/
    > ./install_a2b_sounds.sh
    > chown -R asterisk:asterisk /var/lib/asterisk/sounds
    

    5. Configure Asterisk Manager

    > vi /etc/asterisk/manager.conf
    
    [general]
    enabled = yes
    port = 5038
    bindaddr = 0.0.0.0
    
    ; for A2Billing
    [myasterisk]
    secret = mycode
    read = system,call,log,verbose,command,agent,user
    write = system,call,log,verbose,command,agent,user
    

    6. Install web-based interfaces

    > mkdir /var/www/a2billing
    

    Copy the web files:

    > cp -rf /usr/local/src/a2billing/admin /var/www/a2billing
    > cp -rf /usr/local/src/a2billing/agent /var/www/a2billing
    > cp -rf /usr/local/src/a2billing/customer /var/www/a2billing
    > cp -rf /usr/local/src/a2billing/common /var/www/a2billing
    
    > chmod 755 /var/www/a2billing/admin/templates_c
    > chmod 755 /var/www/a2billing/customer/templates_c
    > chmod 755 /var/www/a2billing/agent/templates_c
    > chown -R asterisk:asterisk /var/www/a2billing
    

    7. Install  AGI components

    > cd /usr/local/src/a2billing/AGI
    > cp a2billing.php /var/lib/asterisk/agi-bin
    > cp a2billing_monitoring.php /var/lib/asterisk/agi-bin
    > ln -sf /var/www/a2billing/common/lib /var/lib/asterisk/agi-bin/lib
    
    > chown -R asterisk:asterisk /var/lib/asterisk/agi-bin/a2billing*
    

    Checkpoint 2:

    Direct a browser to the administrative web interface (http://<ip-addr>/a2billing/admin) and login as administrator. Default passwords are:

            user: root
            pass: changepassword

    8. Create a dialplan for A2Billing

    > cp /usr/local/src/a2billing/addons/asterisk-conf/extensions_a2billing_1_6.conf /etc/asterisk
    > chown asterisk:asterisk /etc/asterisk/extensions_a2billing_1_6.conf
    > echo \#include extensions_a2billing_1_6.conf >> /etc/asterisk/extensions.conf
    

    9. Create the crontab jobs

    Create folder directory for monitoring Scripts:

    > mkdir -p /var/lib/a2billing/script
    > chown asterisk:asterisk /var/lib/a2billing/script
    

    Create folder directory for Cronts PID:

    > mkdir -p /var/run/a2billing
    > chown asterisk:asterisk /var/run/a2billing
    
    > mkdir -p /usr/local/a2billing
    > cp -R /usr/local/src/a2billing/Cronjobs /usr/local/a2billing/
    > ln -sf /var/www/a2billing/common/lib /usr/local/a2billing/Cronjobs/lib
    > chown -R asterisk:asterisk /usr/local/a2billing
    
    > vi /var/spool/cron/crontabs/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
    

    9. Add log files

    > 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:asterisk /var/log/a2billing
    

    10. Add index file to prevent browsing of root folder

    > touch /var/www/a2billing/index.html
    

    Restart Asterisk service

    > service asterisk restart
    

    Log into the webpage

    http://{my-ip-address}/a2billing/admin

     - user: root
     - changepassword


     

    Powered by MindTouch Core