How to install Asterisk and A2billing on an Ubuntu server (11.04)

Written by admin on November 17, 2014. Posted in A2billing, Asterisk

This installation was carried out on Ubuntu 10.04 Lucid for SolusVM on x86-64

We need to upgrade apt-get

#apt-get upgrade
#apt-get update
Configure your timezone:
#dpkg-reconfigure tzdata

Install some pre-requisites:
#apt-get install libapache2-mod-php5 php5 php5-common
#apt-get install php5-cli php5-mysql mysql-server apache2 php5-gd (note the password for mysql, we will need it later)
#apt-get install php5-mcrypt

Add repos and install Asterisk 1.8
#apt-get install python-software-properties -y
#apt-key adv --keyserver --recv-keys 175E41DF

#add-apt-repository "deb `lsb_release -cs` main"
#sudo add-apt-repository "deb-src `lsb_release -cs` main" (If you get an error here just ignore and carry on)

#apt-get update
#apt-get upgrade

# apt-get install asterisk

Download and install A2billing:
# cd /usr/local/src

# wget

# tar -zxvf v1-current
rm v1-current
mv Star2Billing-a2billing-* a2billing

Prep the database:
#cd a2billing/DataBase/mysql-5.x

# mysql -uroot -p < a2billing-createdb-user.sql

# ./

You will be asked to enter details. Enter them as follows

database name :  mya2billing

hostname : localhost
User : root
Password : mysqlpassword (This is the one we created earlier)
Copy and edit a2billing.conf:
# cp /usr/local/src/a2billing/a2billing.conf /etc/
# nano -w /etc/a2billing.conf
Make sure the first stanza looks like the following:
hostname = localhost
port = 3306
user = a2billinguser
password = a2billing
dbname = mya2billing
dbtype = mysqlAdditional files for A2billing:# chmod 777 /etc/asterisk -R
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 -Rf www-data /etc/asterisk/additional_a2billing_iax.conf
chown -Rf www-data /etc/asterisk/additional_a2billing_sip.confInstall the A2billing sounds:
# cd /usr/local/src/a2billing/addons/sounds
chown -R asterisk:asterisk /usr/share/asterisk/sounds/

Edit manager.conf:
# nano -w /etc/asterisk/manager.conf

Install the AGI etc:

# mkdir /usr/share/asterisk/agi-bin
cd /usr/local/src/a2billing/AGI
cp a2billing.php /usr/share/asterisk/agi-bin/
chown -R asterisk:asterisk /usr/share/asterisk/agi-bin
chmod 755 /usr/share/asterisk/agi-bin/a2billing.php
cp /usr/local/src/a2billing/common/lib  /usr/share/asterisk/agi-bin/lib -R

Install the webui:
# mkdir /var/www/a2billing
chown www-data:www-data /var/www/a2billing
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 www-data:www-data /var/www

Add contexts to extensions.conf: (For wholesale termination)
# nano -w /etc/asterisk/extensions.conf

; CallingCard application
;exten => _X.,1,Answer
;exten => _X.,2,Wait(2)
;exten => _X.,3,deadAGI(a2billing.php)
;exten => _X.,4,Wait(2)
;exten => _X.,5,Hangup
exten => _X.,1,deadAGI(a2billing.php)
exten => _X.,n,Hangup

; CallingCard application
exten => _X.,1,deadAGI(a2billing.php,1,did)

Add some cron entries:
# crontab -e

# update the currency table
0 6 * * * php /usr/local/src/a2billing/Cronjobs/currencies_update_yahoo.php

# manage the monthly services subscription
0 6 1 * * php /usr/local/src/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/src/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/src/a2billing/Cronjobs/a2billing_bill_diduse.php

# This script will take care of the recurring service.
0 12 * * * php /usr/local/src/a2billing/Cronjobs/a2billing_batch_process.php

# To generate invoices and for each user.
0 6 * * * php /usr/local/src/a2billing/Cronjobs/a2billing_batch_billing.php

# to proceed the autodialer
*/5 * * * * php /usr/local/src/a2billing/Cronjobs/a2billing_batch_autodialer.php

# manage alarms
0 * * * * php /usr/local/src/a2billing/Cronjobs/a2billing_alarm.php

Make a logfile:

# mkdir /var/log/a2billing
touch /var/log/a2billing/a2billing_agi.log
chown -R asterisk:asterisk /var/log/a2billing
Add some rotation:
# cd /etc/logrotate.d
nano -w a2billing

/var/log/a2billing/*.log {
rotate 4

Enable SSL using default certificate for admin:

ln -s /etc/apache2/sites-available/default-ssl /etc/apache2/sites-enabled/000-default-ssl

# a2enmod rewrite
# service apache2 restart


Browse to http://youripaddress/a2billing/admin and login with the following credentials:

Username: root

Password : changepassword



If you like our site please consider donating any amount to keep this site running

Trackback from your site.