Install A2billing on Debian Wheezy Status Alpha Tutorial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
install realtime Kernel and Kernel Headers: | |
apt-get install -y linux-image-rt-amd64 linux-headers-rt-amd64 | |
remove the old kernel | |
apt-get remove -y linux-image-3.2.0-4-amd64 linux-headers-3.2.0-4-amd64 | |
update-grub ##reconfigure the bootloader for the new Kernel | |
reboot ## start the sytstem with the new Kernel | |
uname -r ## check the new Kernel is loaded >>3.2.0-4-rt-amd64 | |
Install Xtables Geoip Firewall: | |
apt-get install xtables-addons-common libtext-csv-xs-perl unzip | |
mkdir -p /usr/share/xt_geoip | |
cd /usr/lib/xtables-addons | |
./xt_geoip_dl | |
./xt_geoip_build -D /usr/share/xt_geoip *.csv | |
reboot | |
make some iptables rules for xtables geoip: | |
iptables -I INPUT 1 -m state --state NEW -m geoip ! --source-country DE -j DROP ## alow Traffic only from Germany | |
iptables -I INPUT 1 -s 127.0.0.1 -j ACCEPT ## allow internel Traffic | |
Now save the rules: | |
iptables-save > /root/geoip.fw | |
Make a Entry in rc.local for Start the geip Firewall at System Start: | |
nano /etc/init.d/rc.local | |
Append the line: | |
/sbin/iptables-restore < /root/geoip.fw | |
save the rc.local file and reboot the System | |
after reboot show the rules: | |
/sbin/iptables -L -v -n | |
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 | |
apt-get install php5-mcrypt | |
apt-get install build-essential wget libssl-dev libncurses5-dev libnewt-dev libxml2-dev linux-headers-$(uname -r) libsqlite3-dev uuid-dev sendmail | |
Add jansson and install Asterisk | |
apt-get install python-software-properties -y | |
apt-key adv --keyserver pgp.mit.edu --recv-keys 175E41DF | |
wget http://www.digip.org/jansson/releases/jansson-2.4.tar.gz | |
tar -zxf jansson-2.4.tar.gz | |
cd jansson-2.4/ | |
./configure --prefix=/usr/ && make clean && make && make install | |
cd /usr/src/ | |
wget http://downloads.asterisk.org/pub/telephony/dahdi-linux-complete/dahdi-linux-complete-current.tar.gz | |
wget http://downloads.asterisk.org/pub/telephony/libpri/libpri-1.4.14.tar.gz | |
wget http://download.vicidial.com/required-apps/asterisk-1.8.23.0-vici.tar.gz | |
tar zxvf dahdi-linux-complete* | |
tar zxvf libpri* | |
tar zxvf asterisk* | |
cd /usr/src/dahdi-linux-complete* | |
make && make install && make config | |
cd ../libpri* | |
make && make install | |
cd ../asterisk* | |
./configure && make menuselect && make && make install && make config && make samples | |
/etc/init.d/dahdi start | |
/etc/init.d/asterisk start | |
asterisk -rvvv | |
*CLI> dahdi show version | |
+++++++++++++++DAHDI Version: 2.6.1 Echo Canceller: HWEC | |
*CLI> pri show version | |
+++++++++++++++libpri version: 1.4.13 | |
Download and install A2billing: | |
cd /usr/local/src | |
wget https://github.com/Star2Billing/a2billing/archive/master.tar.gz | |
tar -zxvf master.tar.gz | |
rm master.tar.gz | |
mv a2billing-* a2billing | |
Prep the database: | |
cd a2billing/DataBase/mysql-5.x | |
mysql -uroot -p < a2billing-createdb-user.sql | |
./install-db.sh | |
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: | |
[database] | |
hostname = localhost | |
port = 3306 | |
user = a2billinguser | |
password = mysqlpassword | |
dbname = mya2billing | |
dbtype = mysql | |
Additional 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_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.conf | |
Install the A2billing sounds: | |
cd /usr/local/src/a2billing/addons/sounds | |
./install_a2b_sounds_deb.sh | |
Asterisk ended with exit status 1 | |
chown -R asterisk:asterisk /usr/share/asterisk/sounds/ | |
Edit manager.conf: | |
nano -w /etc/asterisk/manager.conf | |
[myasterisk] | |
secret=mycode | |
read=system,call,log,verbose,command,agent,user | |
write=system,call,log,verbose,command,agent,user | |
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 | |
[a2billing] | |
; 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 | |
[did] | |
; 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 | |
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 | |
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 | |
Asterisk Realtime | |
It may be beneficial to use Asterisk Realtime with A2billing. If running Asterisk Realtime you do not need to reload every time you add/remove/change a customer. Also it allows you to share the A2billing database between multiple Aserisk/FreePBX servers if you needed to do that. If you need to create many customers it makes more sense to use a database instead of putting them all in a flat text file. Double check you have the Asterisk Realtime module installed. If using 64bit OS the modules are in /usr/lib64/asterisk/modules. | |
cd /usr/lib/asterisk/modules | |
dir | |
There should be a file there called res_config_mysql.so. If not you need to re-install Asterisk and set it to compile the res_config_mysql.so realtime module in menuselect. Add the following to /etc/asterisk/extconfig.conf | |
nano /etc/asterisk/extconfig.conf | |
NOTE: [settings] is already included and uncommented in this file in asterisk sample configurations. So if you installed asterisk samples or FreePBX and this file already exists and you are trying to add to it, do not add this line twice. | |
[settings] | |
iaxusers => mysql,general,cc_iax_buddies | |
iaxpeers => mysql,general,cc_iax_buddies | |
sipusers => mysql,general,cc_sip_buddies | |
sippeers => mysql,general,cc_sip_buddies | |
extensions => mysql,general,cc_sip_buddies | |
Add the following to /etc/asterisk/res_config_mysql.conf | |
nano /etc/asterisk/res_config_mysql.conf | |
NOTE: [general] is already included and uncommented in this file in asterisk samples. So if you installed asterisk samples or FreePBX and this file already exists and you are trying to add to it, do not add this line twice. | |
[general] | |
dbhost = 127.0.0.1 | |
dbname = mya2billing | |
dbuser = a2billinguser | |
dbpass = a2billing | |
dbport = 3306 | |
;dbsock = /var/lib/mysql/mysql.sock | |
Assuming (as we did in this guide) that the dbname=mya2billing, dbuser=a2billinguser, dbpassword=a2billing. Double check that these settings match /etc/a2billing.conf and substitute as necessary. | |
Now restart freepbx/asterisk | |
amportal restart | |
To check if realtime is working: | |
From Asterisk CLI> | |
# asterisk -vvvr | |
> core show config mappings | |
Should produce: | |
Config Engine: mysql | |
===> extensions (db=general, table=cc_sip_buddies) | |
===> iaxpeers (db=general, table=cc_iax_buddies) | |
===> iaxusers (db=general, table=cc_iax_buddies) | |
===> sippeers (db=general, table=cc_sip_buddies) | |
===> sipusers (db=general, table=cc_sip_buddies) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment