Pages

Friday, April 12, 2013

How to install A2billing with Asterisk on Centos

Asterisk / A2Billing on centos
What is A2Billing
A2Billing is a class 4 and class 5 softswitch with inline billing, designed for providing residential, business and wholesale VoIP services, calling cards.
Prerequisites  :
>> Centos 5 clean and scratch server with yum installed.
>> First the get version of OS and 64bit/32Bit
You can get the version by following the command below ::
#cat /etc/*release*
>> Kernel  versin using the below command ::
#uname -a
>> disable firewall first. re-enable it later.
# service iptables stop
Initial setup to proceed with installation ::
First Get everything up to date on your server, you can update it via yum using commands below ::
#yum -y upgrade
#yum -y update
#reboot
#yum -y update

Need to install first the required modules on the server  as below :


If you are server version is [32 bit] (i686) then do follow the command below to install modules ::
#yum -y install gcc gcc-c++ kernel-devel bison openssl-devel libtermcap-devel ncurses-devel doxygen curl-devel newt-devel mlocate lynx tar wget nmap bzip2 mod_ssl crontabs vixie-cron speex speex-devel unixODBC unixODBC-devel libtool-ltdl  libtool-ltdl-devel mysql-connector-odbc mysql mysql-devel  mysql-server php-mysql php-mbstring php-mcrypt flex screen  libxml2 libxml2-devel libtiff libtiff-devel
If you are server version is [64 bit] (x86_64) then do follow the command below to install modules ::
#yum -y install gcc.x86_64 gcc-c++.x86_64 kernel-devel.x86_64 bison.x86_64 openssl-devel.x86_64  libtermcap-devel.x86_64 ncurses-devel.x86_64 doxygen.x86_64 curl-devel.x86_64 newt-devel.x86_64  mlocate.x86_64 lynx.x86_64 tar.x86_64 wget.x86_64 nmap.x86_64 bzip2.x86_64 mod_ssl.x86_64  crontabs.x86_64 vixie-cron.x86_64 speex.x86_64 speex-devel.x86_64 unixODBC.x86_64  unixODBC-devel.x86_64 libtool-ltdl.x86_64 libtool-ltdl-devel.x86_64 mysql-connector-odbc.x86_64 mysql.x86_64 mysql-devel.x86_64 mysql-server.x86_64 php-mysql.x86_64 php-mbstring.x86_64  php-mcrypt.x86_64 flex.x86_64 screen.x86_64 libxml2-devel
#yum -y install libidn-devel krb5-devel krb5-libs zlib-devel libidn-devel
#ln -sf /lib64/libcom_err.so.2 /lib64/libcom_err.so
Done.
NOTE :: A2billing Asterisk required PHP 5.2 or higher.
Now installation of Asterisk ::
#groupadd asterisk
#useradd -c “asterisk PBX” -d /var/lib/asterisk -g asterisk asterisk
#cd /usr/src/
#wget http://downloads.digium.com/pub/asterisk/asterisk-1.6.2.9.tar.gz
#tar -zxvf asterisk-1.6.2.9.tar.gz
#cd asterisk-1.6.2.9
#make clean
#./configure
#make menuselect
(setup what you need in the menu manager,include mysql)
#make
#make install
#make samples
#make progdocs
#make config
#chkconfig asterisk on
#asterisk -vvvvvvvvvvvvvvvvvvvc
#core stop now
#service asterisk start
>> edit the following files in /etc/asterisk:
#nano /etc/asterisk/indications.conf – Change default country (its not manadatory do modification if required )
#nano /etc/asterisk/modules.conf – Uncomment the line ‘preload => res_odbc.so’
#nano /etc/asterisk/modules.conf – Add ‘noload => pbx_ael.so’ to bottom of file
#nano /etc/asterisk/modules.conf – Add ‘noload => codec_dahdi.so’ to the bottom of the file
Now copy and paste the below code to the specified files using the commands as below ::
1.
===============================
# rm /etc/asterisk/extensions.ael
# cat > /etc/asterisk/extensions.conf << EOF
[general]
static=yes
writeprotect=yes
autofallthrough=yes
extenpatternmatchnew=no
clearglobalvars=yes
priorityjumping=no
userscontext=default
[globals]
[default]
exten => _.,1,Goto(i,1)
exten => i,1,NoOp(Invalid)
exten => i,n,Congestion()
exten => i,n,Hangup()
exten => h,1,NoOp(Hanging up)
EOF
================================
2.
================================
# rm /etc/asterisk/extensions.lua
# cat > /etc/asterisk/sip.conf << EOF
[general]
context=default
allowguest=yes
match_auth_username=yes
allowoverlap=no
allowtransfer=no
realm=pbx12.vitell.co.uk
udpbindaddr=0.0.0.0
tcpenable=no
tlsenable=no
srvlookup=yes
pedantic=no
tos_sip=cs3
tos_audio=ef
tos_video=af41
tos_text=af41
cos_sip=3
cos_audio=5
cos_video=4
cos_text=3
maxexpiry=3600
minexpiry=60
defaultexpiry=120
mwiexpiry=3600
qualifyfreq=60
qualifygap=100
qualifypeers=1
vmexten=voicemail
disallow=all
allow=alaw
mohinterpret=default
mohsuggest=default
parkinglot=plaza
language=en
relaxdtmf=yes
useragent=AsteriskPBX
sdpsession=AsteriskPBX
promiscredir=no
dtmfmode=rfc2833
videosupport=no
callevents=no
alwaysauthreject=yes
shrinkcallerid=no
allowsubscribe=yes
subscribecontext=default
notifyringing=yes
notifyhold=yes
notifycid=yes
callcounter=yes
t38pt_udptl=yes,fec,maxdatagram=400
faxdetect=no
nat=no
directmedia=no
directrtpsetup=no
EOF
=======================================
You’re done with Asterisk installation here :) :) :)
Now lets get a2Billing for both asterisk server and Master SQL( just gonna use the sql for sql)
# cd /usr/src
# mkdir a2billing
# cd  a2billing
Download the a2billing source from the link below ::
http://www.asterisk2billing.org/get-started/direct-download/
Click on download, it will download the source at your local computer and then upload it to your server using SFTP.
Once uploaded. extract it ::
tar -zxvf Star2Billing-a2billing-v1-current-0-g95789f5.tar.gz
cd Star2Billing-a2billing-d960375
then move all the files from Star2Billing-a2billing-d960375   to a2billing
#scp -r -p /usr/src/a2billing/Star2Billing-a2billing-d960375/ /usr/src/a2billing/
Extraction done. Then ::
>> On Master SQL Server do the following
# cd /usr/src/a2billing/DataBase/mysql-5.x
# mysql -u root -p < a2billing-createdb-user.sql;
# mysql -u root -p mya2billing < a2billing-mysql-schema-v1.7.0.sql;
We will need to make a new user on the master SQL server that has permissions remotely.
# mysql> CREATE USER ‘a2bMySQL’@’10.10.10.%’ IDENTIFIED BY ‘yourpassdb’;
# mysql> GRANT ALL ON *.* TO ‘a2bMySQL’@’10.10.10.%’;
Mysql database, user adding  and importing the database file is restored.
Now Back to Asterisk Box
#cp /usr/src/a2billing/a2billing.conf /etc/
#nano /etc/a2billing.conf
>> Edit a2billing.conf to  the following
===================================
[database]
hostname = 10.10.10.1
port = 3306
user = a2bMySQL
password = yourpassdb
dbname = mya2billing
dbtype = mysql
===================================
>> Edit the file as below ::
# /etc/asterisk/res_mysql.conf  Or you can find /etc/asterisk/res_config_mysql.conf
# nano /etc/asterisk/res_mysql.conf   Or nano /etc/asterisk/res_config_mysql.conf
===================================
[general]
dbhost = 10.10.10.1
dbname = mya2billing
dbuser = a2bMySQL
dbpass = yourpassdb
;dbport = 3306
dbsock = /var/lib/mysql/mysql.sock
===================================
>> Edit the file as below ::
# nano /etc/asterisk/extconfig.conf
===================================
[settings]
sipusers => mysql,mya2billing,cc_sip_buddies
iaxusers => mysql,mya2billing,cc_iax_buddies
sippeers => mysql,mya2billing,cc_sip_buddies
iaxpeers => mysql,mya2billing,cc_iax_buddies
===================================
>> Once done Fix folder Permissions using commands below ::
#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 -Rf apache /etc/asterisk/additional_a2billing_iax.conf
#chown -Rf apache /etc/asterisk/additional_a2billing_sip.conf
>> Copy sound to asterisk folder
#/usr/src/a2billing/addons/sounds/install_a2b_sounds.sh
>> Now Edit the Manger.conf
#nano /etc/asterisk/manager.conf
and add below code ::
==============================================
[myasterisk]
secret=mycode
read=system,call,log,verbose,command,agent,user
write=system,call,log,verbose,command,agent,user
==============================================
and now save and exit the file.
>> Copy AGI files and make executable
#cd /usr/src/a2billing/AGI
#cp a2billing.php /var/lib/asterisk/agi-bin/
#cp -Rf lib /var/lib/asterisk/agi-bin/
#chmod +x /var/lib/asterisk/agi-bin/a2billing.php
#mkdir /var/www/a2billing
#chown apache:apache /var/www/a2billing
#cp -rf /usr/src/a2billing/admin /var/www/a2billing
#cp -rf /usr/src/a2billing/agent /var/www/a2billing
#cp -rf /usr/src/a2billing/customer /var/www/a2billing
#cp -rf /usr/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 -Rf apache:apache /var/www/a2billing/admin/templates_c
chown -Rf apache:apache /var/www/a2billing/customer/templates_c
>> edit apache file that is  /etc/httpd/conf/httpd.conf
#nano /etc/httpd/conf/httpd.conf
find DocumentRoot and chane to below:
===================
DocumentRoot “/var/www/a2billing”
===================
Save and exit the file and restart the apache.
# service httpd restart
Its Done.
Now you can go on your A2billing page  using below link ::
http://yourip/admin/  Here (your ip will be your server ip )
log in  Using the details  below ::
======================
user: root
pass: changepassword
======================
Once logged in Change your login passowrd.
Now lets edit asterisk so the AGI works
# nano /etc/asterisk/extensions.conf
Paste below to the bottom of the file.
====================================
[a2billing]
; CallingCard application
exten => _X.,1,DeadAGI,a2billing.php
exten => _X.,2,Wait,2
exten => _X.,3,Hangup
[did]
; CallingCard application
exten => _X.,1,DeadAGI(a2billing.php|1|did)
Now configure httpd to start on boot
#ntsysv
arrow down to httpd and hit the space bar .tab to ok click enter
====================================
Asterisk will already start on boot
Errors and troubelshootings ::
Access Denied  while changing the password.
Check the ownership of the /var/lib/php/session  and change it to root.
#chown root.root /var/lib/php/session
Done. Now you can configure the A2billing as per your requiredments.

No comments:

Post a Comment