A2Billing Installation and configurations in CentOS 5/6/7

A2Billing is free and open source software for Asterisk, providing telecoms customer management including admin, agent, customer and online signup pages, with flexible inline rating and billing of calls and services in real-time.


php54w php54w-bcmath php54w-cli php54w-common php54w-devel php54w-embedded php54w-fpm php54w-gd php54w-intl php54w-ldap php54w-mbstring php54w-mcrypt php54w-mysql php54w-pecl-apc php54w-snmp php54w-soap php54w-xml php54w-xmlrpc

Before start the installation, change the apache user to asterisk user in httpd configurations

vi /etc/httpd/conf/httpd.conf
replace “user apache” and “Group apache”
with “User asterisk” and Group asterisk”


First of all download the stable release of a2billing by executing the following command in my case it’s 2.2.0

# cd /usr/src

# wget https://github.com/Star2Billing/a2billing/archive/master.tar.gz –no-check-certificate
Unzip it.

# tar -xzf master.tar.gz

# mv a2billing-master a2billing

# cd a2billing

Copy the configurations file to /etc/

# cp /usr/src/a2billing/a2billing.conf /etc/a2billing.conf

Create and Import default a2billing database
#mysql -u root -p

> create database a2billing;

> use a2billing;

> GRANT ALL PRIVILEGES ON *.* TO ‘a2billing’@’localhost’ IDENTIFIED BY ‘a2billing’ WITH GRANT OPTION;

> GRANT ALL PRIVILEGES ON a2billing.* TO a2billing@localhost IDENTIFIED BY ‘a2billing’;


> exit

# cd /usr/src/a2billing/DataBase/mysql-5.x

# ./install-db.sh

Copy the AGI file

# ln -s /usr/src/a2billing/AGI/a2billing.php /var/lib/asterisk/agi-bin/

Change the ownership permission for the asterisk files

# chown asterisk:asterisk /var/lib/asterisk/agi-bin/a2billing.php

# chmod +x /var/lib/asterisk/agi-bin/a2billing.php

# chown -R asterisk:asterisk /var/lib/asterisk/

Create an asterisk manager user for accessing the cli from a2billing

# vi /etc/asterisk/manager.conf
secret = mycode
read = system,call,log,verbose,command,agent,user
write = system,call,log,verbose,command,agent,user

Create web directories

# mkdir /var/www/html/a2billing
# ln -s /usr/src/a2billing/common /var/www/html/a2billing/common
# ln -s /usr/src/a2billing/admin /var/www/html/a2billing/admin
# ln -s /usr/src/a2billing/agent /var/www/html/a2billing/agent
# ln -s /usr/src/a2billing/customer /var/www/html/a2billing/customer

# chown -R asterisk:asterisk /var/www/html/a2billing/
# chown -R asterisk:asterisk /var/www/html/a2billing/common
# chown -R asterisk:asterisk /var/www/html/a2billing/admin
# chown -R asterisk:asterisk /var/www/html/a2billing/customer
# chown -R asterisk:asterisk /var/www/html/a2billing/agent

Add files into crontab
# Automatically added for A2Billing
0 * * * * php /usr/src/a2billing/Cronjobs/a2billing_alarm.php
0 12 * * * php /usr/src/a2billing/Cronjobs/a2billing_archive_data_cront.php
0 10 21 * * php /usr/src/a2billing/Cronjobs/a2billing_autorefill.php
#Batch process at 00:20 each day
20 0 * * * php /usr/src/a2billing/Cronjobs/a2billing_batch_process.php
#Bill DID usage at 00:00 each day
0 0 * * * php /usr/src/a2billing/Cronjobs/a2billing_bill_diduse.php
#Remind users of low balance every day at 06:00
0 6 * * * php /usr/src/a2billing/Cronjobs/a2billing_check_account.php
#Generate Invoices at 7am everyday
0 7 * * * php /usr/src/a2billing/Cronjobs/a2billing_invoice2_cront.php
0 7 * * * php /usr/src/a2billing/Cronjobs/a2billing_invoice_cront.php
#Check if balance below preset value, and email user if so.
1 * * * * php /usr/src/a2billing/Cronjobs/a2billing_notify_account.php
#Charge subscriptions at 06:05 on the 1st of each month
0 6 1 * * php /usr/src/a2billing/Cronjobs/a2billing_subscription_fee.php
#Update currencies at 01:00 each day
0 1 * * * php /usr/src/a2billing/Cronjobs/currencies_update_yahoo.php

Create log files
# touch /var/log/asterisk/a2billing-daemon-callback.log
# touch /var/log/a2billing/a2billing-daemon-callback.log
# 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_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/api_ecommerce_request.log
# touch /var/log/a2billing/api_callback_request.log
# touch /var/log/a2billing/a2billing_agi.log

Update the following fields of /etc/a2billing.conf

hostname = localhost
port = 3306
user = a2billing
password = a2billing
dbname = a2billing
; dbtype setting can either be mysql or postgres
dbtype = mysql

Restart the mysql service

# service mysqld stop
# service mysqld start


Give all permissions to a2billing folder

# chmod -R 777 /usr/src/a2billing/

Add the following lines in extensions.conf

exten => _X.,1,NoOp(A2Billing Start)
exten => _X.,n,DeadAgi(a2billing.php,1,predictivedialer)
exten => _X.,n,Hangup

Now you open the browser and point to http://your-server-ip-address/a2billing/admin default username/password is root/changepassword.

Steps to setup the a2billing

1) Create Call Plan
2) Create Rate Card
3) Create Rates
4) Now again click on CallPlan and add the RateCard, you just created.
5) Add the Trunk and you can put the trunk name of the FreePBX or you give the IP address of the service provider directly.
6) Now Generate Customers, but before that, you should go to system settings Modify the following settings in Global list
Change value to “Yes” for use_dnid
Change value to “No” for use_realtime
Change value to “1_8” for asterisk_version

7) After creating the customer click on VoIP-settings you will see some red panels on the top of the browser so for generating the additional_a2billing_sip.conf and additional_a2billing_iax.conf click on these panels and reload asterisk, it will add the user in that file. Now you should include these files into sip.conf
#include additional_a2billing_sip.conf

This entry was posted in Asterisk, Telephony. Bookmark the permalink.

Leave a Reply

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