BinaryGuru

Hacking digital systems

FreePBX 1.8.1.4 (CentOS 5.5) & A2Billing 1.9.4 (Stable) inside VirtualBox 4.0.8 Installation Notes

32-bit CentOS 5.5 Only

1. Download FreePBX from http://www.freepbx.org/download-freepbx

Here’s a direct link to the version I downloaded:
http://downloads.freepbxdistro.org/ISO/FreePBX-Distro-Net-1.8.1.4.iso


2. Make a new VirtualBox virtual machine with these specs:

  • OS Type: Red Hat
  • Base Memory: 512MiB (Default)
  • Hard Disk Type: Dynamic
  • Hard Disk Size: 8.00GiB
  • Network: Bridged Adapter

NOTE: You will have to go into the settings and change the network adapter type after you create the virtual machine.


3. Start the virtual machine, VBox will then present the firstime run dialog.

This dialog will ask you to show it where the instllation media is located.
Please point it to where you saved FreePBX-Distro-Net-1.8.1.4.iso


4. FreePBX installation will now start.

Please follow the on-screen instruction for completeing the installation.
I reccoment at this point to setup a static IP for this server.


5. When you have rebooted and logged in, please update using YUM:

yum clean all
yum update
yum upgrade

Reboot using:

shutdown -r now

Then install the packeges nessesary to install VirtualBox Guest Additions:

yum install -y gcc
yum install -y kernel-devel

Reboot again:

shutdown -r now

NOTE: I have found you need to add the option ‘divider=10’ to you kernel boot options to reduce idle CPU load. On my machine, the idle load went from ~20% down to ~1% idle load.


6. We are now ready to install the Guest Additions.

Login as root and then from the Devices menu, choose Install Guest Additions… (or press [Hostkey]+D on your keyboard). This will insert then ISO into the virtual optical drive.

We will need to mount this ISO to use it:

mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom

7. Run the install script to install the guest additions:

cd /mnt/cdrom
./VBoxLinuxAdditions.run

Follow the standard procedure for installing the Guest Addtions documented in the VirtualBox User’s Manual. You will have to reboot when the installation has completed.


8. We must now manually upgrade PHP 5.1.x to 5.2.x

I will be using Jason Litka’s YUM Repo.

Instructions on installing this repo into your system can be found here:
http://www.jasonlitka.com/yum-repository/


9. Once you have added the repo following the instuction on Jason’s site, run the following commands:

yum clean all
yum update

YUM will ask you if it’s OK to upgrade the selected packages, type ‘y’ and hit [Enter].
Once YUM has finished updating, reboot the system:

shutdown -r now

10. Download the A2Billing tarball and extract:

cd /usr/local/src/
wget --no-check-certificate https://github.com/Star2Billing/a2billing/tarball/v1-current
tar xvf Star2Billing-a2billing-v1-current-0-g95789f5.tar.gz
ln -s ./Star2Billing-a2billing-d960375 ./a2billing

I made a symlink to /usr/local/src/Star2Billing-a2billing-d960375 called a2billing to make the directory access easier.


11. Before we can install A2Billing we need to make sure we have the required dependent packages installed:

ln -s /var/lib/asterisk /usr/share/asterisk
yum install -y php-mcrypt.i386

The symlink is for avoiding compatibility issues from .deb based distros. A2Billing setup scripts tend to assume a LOT of things.


12. Prepare the database:

mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 1706
Server version: 5.1.52 MySQL Community Server (GPL) by Utter Ramblings

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql> CREATE DATABASE a2billing;
 Query OK, 1 row affected (0.00 sec)
mysql> quit
 Bye

NOTE: I had to change the MySQL root password becuase I had not set the password and I could not find the default password set by FreePBX. Also, FreePBX does not use the root user anyway for database access, it instead uses ‘freepbxuser’.

NOTE: If you need help changing the MySQL root user password without knowing the original password, please read the insructions here:
http://www.cyberciti.biz/tips/recover-mysql-root-password.html

NOTE: You will have to change /etc/init.d/mysql to /etc/init.d/mysqld where applicable in the above tutorial.


13. Populate the database with new tables from install-db.sh script:

cd /usr/local/src/Star2Billing-a2billing-d960375/DataBase/mysql-5.x
./install-db.sh

When the script is executed, it will interactively ask for input to setup the database for you. Following the example below, you will need your A2Billing database name, hostname where the database is located, username to use to make the changes and the respective password.

Install A2Billing DataBase
-----------------------------
Enter Database Name :
a2billing
Enter Hostname :
localhost
Enter UserName :
root
Enter Password :
mypass
mysql --user=root --password=mypass --host=localhost a2billing

NOTE: Make sure to replace ‘mypass‘ for the password you use for the MySQL root user.

The script will take a few seconds to process and then it will drop you back at the command prompt with no errors if everything went well.


14. Set permissions for the new database:

mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 1706
Server version: 5.1.52 MySQL Community Server (GPL) by Utter Ramblings

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql> CREATE USER 'a2buser'@'localhost' IDENTIFIED BY 'mypass';
 Query OK, 1 row affected (0.00 sec)
mysql> GRANT ALL ON a2billing.* TO 'a2buser'@'localhost';
 Query OK, 1 row affected (0.00 sec)
mysql> quit
 Bye

Check for the new tables (should be 97 of them), and check the new users grants (should be all of them):

mysql -u a2buser -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 1706
Server version: 5.1.52 MySQL Community Server (GPL) by Utter Ramblings

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
mysql> USE a2billing
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> SHOW TABLES;
+---------------------------+
| Tables_in_a2billing       |
+---------------------------+
| cc_agent                  |
| cc_agent_commission       |
| cc_agent_signup           |
| cc_agent_tariffgroup      |
| cc_alarm                  |
| cc_alarm_report           |
| cc_autorefill_report      |
| cc_backup                 |
| cc_billing_customer       |
| cc_call                   |
| cc_call_archive           |
| cc_callback_spool         |
| cc_callerid               |
| cc_callplan_lcr           |
| cc_campaign               |
| cc_campaign_config        |
| cc_campaign_phonebook     |
| cc_campaign_phonestatus   |
| cc_campaignconf_cardgroup |
| cc_card                   |
| cc_card_archive           |
| cc_card_group             |
| cc_card_history           |
| cc_card_package_offer     |
| cc_card_seria             |
| cc_card_subscription      |
| cc_cardgroup_service      |
| cc_charge                 |
| cc_config                 |
| cc_config_group           |
| cc_configuration          |
| cc_country                |
| cc_currencies             |
| cc_did                    |
| cc_did_destination        |
| cc_did_use                |
| cc_didgroup               |
| cc_epayment_log           |
| cc_epayment_log_agent     |
| cc_iax_buddies            |
| cc_invoice                |
| cc_invoice_conf           |
| cc_invoice_item           |
| cc_invoice_payment        |
| cc_iso639                 |
| cc_logpayment             |
| cc_logpayment_agent       |
| cc_logrefill              |
| cc_logrefill_agent        |
| cc_message_agent          |
| cc_monitor                |
| cc_notification           |
| cc_notification_admin     |
| cc_outbound_cid_group     |
| cc_outbound_cid_list      |
| cc_package_group          |
| cc_package_offer          |
| cc_package_rate           |
| cc_packgroup_package      |
| cc_payment_methods        |
| cc_payments               |
| cc_payments_agent         |
| cc_payments_status        |
| cc_paypal                 |
| cc_phonebook              |
| cc_phonenumber            |
| cc_prefix                 |
| cc_provider               |
| cc_ratecard               |
| cc_receipt                |
| cc_receipt_item           |
| cc_remittance_request     |
| cc_restricted_phonenumber |
| cc_server_group           |
| cc_server_manager         |
| cc_service                |
| cc_service_report         |
| cc_sip_buddies            |
| cc_sip_buddies_empty      |
| cc_speeddial              |
| cc_status_log             |
| cc_subscription_service   |
| cc_subscription_signup    |
| cc_support                |
| cc_support_component      |
| cc_system_log             |
| cc_tariffgroup            |
| cc_tariffgroup_plan       |
| cc_tariffplan             |
| cc_templatemail           |
| cc_ticket                 |
| cc_ticket_comment         |
| cc_timezone               |
| cc_trunk                  |
| cc_ui_authen              |
| cc_version                |
| cc_voucher                |
+---------------------------+
97 rows in set (0.00 sec)
mysql> SHOW GRANTS;
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Grants for a2buser@localhost                                                                                                                                                                                                 |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'a2buser'@'localhost' IDENTIFIED BY PASSWORD '*C6A9E404EE2F46734320E4727B7A791BC483BEC1'                                                                                                               |
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, REFERENCES, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES, EXECUTE, CREATE VIEW, SHOW VIEW, CREATE ROUTINE, ALTER ROUTINE ON `a2billing`.* TO 'a2buser'@'localhost' |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
mysql> quit
Bye

15. Setup the a2billing.conf file:

ln -s /usr/local/src/a2billing/a2billing.conf /etc/a2billing.conf
nano /etc/a2billing.conf

Make sure the parameters in the file match these below:

[database]
hostname = localhost
port = 3306
user = a2buser
password = mypass
dbname = a2billing
dbtype = mysql

Type [Ctrl]+O and then [Enter] to save. Press [Ctrl]+X to exit to the command line.

NOTE: Don’t forget to replace ‘mypass‘ with the one you selected earlier.


16. Fix permissions, files and folders:

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:apache /etc/asterisk/additional_a2billing_iax.conf
chown -Rf apache:apache /etc/asterisk/additional_a2billing_sip.conf
chmod 777 /etc/asterisk/additional_a2billing_iax.conf
chmod 777 /etc/asterisk/additional_a2billing_iax.conf

17. Install sound files

cd /usr/local/src/a2billing/addons/sounds
./install_a2b_sounds.sh
chown -R asterisk:asterisk /usr/share/asterisk/sounds/

18. Configure Asterisk Manager

nano /etc/asterisk/manager.conf

Notice that we are using the default values (myasterisk, mycode) in this section. The configuration should look like this

[general]
enabled = yes
port = 5038
bindaddr = 0.0.0.0
[myasterisk]
secret=mycode
permit=127.0.0.1/255.255.255.0
read=system,call,log,verbose,command,agent,user
write=system,call,log,verbose,command,agent,user

19. Install The AGI components

Create a symbolic link of the entire content of the AGI directory into asterisk agi-bin directory:

ln -s /usr/local/src/a2billing/AGI/a2billing.php /var/lib/asterisk/agi-bin/a2billing.php
ln -s /usr/local/src/a2billing/AGI/a2billing_monitoring.php /var/lib/asterisk/agi-bin/a2billing_monitoring.php
ln -s /usr/local/src/a2billing/common/lib /var/lib/asterisk/agi-bin/lib
chmod 0774 /usr/local/src/a2billing/AGI/a2billing.php
chmod 0774 /usr/local/src/a2billing/AGI/a2billing-monitoring.php
chmod -Rf 0774 /usr/local/src/a2billing/common/lib
chown asterisk:asterisk /usr/local/src/a2billing/AGI/a2billing.php
chown asterisk:asterisk /usr/local/src/a2billing/AGI/a2billing-monitoring.php
chown -Rf asterisk:asterisk /usr/local/src/a2billing/common/lib

20. Install web-based Graphical interfaces

mkdir /var/www/html/a2billing
chown asterisk:asterisk /var/www/html/a2billing
mkdir -p /var/lib/a2billing/script
mkdir -p /var/run/a2billing
ln -s /usr/local/src/a2billing/admin /var/www/html/a2billing/admin
ln -s /usr/local/src/a2billing/agent /var/www/html/a2billing/agent
ln -s /usr/local/src/a2billing/customer /var/www/html/a2billing/customer
ln -s /usr/local/src/a2billing/common /var/www/html/a2billing/common
chmod -R 755 /usr/local/src/a2billing/admin/templates_c
chmod -R 755 /usr/local/src/a2billing/customer/templates_c
chmod -R 755 /usr/local/src/a2billing/agent/templates_c
chown -Rf asterisk:asterisk /usr/local/src/a2billing/admin/templates_c
chown -Rf asterisk:asterisk /usr/local/src/a2billing/customer/templates_c
chown -Rf asterisk:asterisk /usr/local/src/a2billing/agent/templates_c

You should be able to login to the A2Billing Admin site located at:
http://yourip/a2billing/admin/

Username: root
Password: changepassword

NOTE: You should test this to make sure A2Billing works.

NOTE: I also had to set permissions on the /var/lib/php/sessions folder otherwise after logging into the Admin panel, clicking on any of the links would kick me off and force me to log in again. Here are the commands I used to fix this problem:

chmod -R 777 /var/lib/php/session
chown -R asterisk:asterisk /var/lib/php/session

21. Integrating FreePBX with A2Billing

I followed instructions for integrating A2Billing into FreePBX from this web site:
http://sysadminman.net/blog/2009/integrating-freepbx-with-a2billing-621

NOTE: Make sure to change the pipe symbols ‘|’ to commas ‘,’ in the examples in that site as you are using Asterisk 1.8.4.1. The pipe opertator was changed to commas in version 1.6 of Asterisk.


As a final note, A2Billing does not officially support Asterisk versions 1.6.x and 1.8.x; if you have problems, you will need to get help on the A2Billing forum located at: http://forum.asterisk2billing.org/

Good luck with getting all of this working the way you want!

28 responses to “FreePBX 1.8.1.4 (CentOS 5.5) & A2Billing 1.9.4 (Stable) inside VirtualBox 4.0.8 Installation Notes

  1. bao June 18, 2011 at 03:07

    Hi,

    Thanks for great tutorial and it is indeed very helpful.

    In step 19:

    ln -s /usr/local/src/a2billing/AGI/a2billing_monitoring.php /var/lib/asterisk/agi-bin/a2billing-monitoring.php

    should be

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

    Confusion about Step 18:

    I am somehow unable to make this all work. My asterisk complaints as following:

    [2011-06-18 11:02:54] NOTICE[3394]: manager.c:2259 authenticate: 127.0.0.1 tried to authenticate with nonexistent user ‘admin’
    [2011-06-18 11:02:54] NOTICE[3394]: manager.c:2296 authenticate: 127.0.0.1 failed to authenticate as ‘admin’

    Can you elaborate what is ‘myasterisk’ and ‘mycode’ in /etc/asterisk/manager.conf Is it asterisk user or a2billing user?

    [general]
    enabled = yes
    port = 5038
    bindaddr = 0.0.0.0
    [myasterisk]
    secret=mycode
    permit=127.0.0.1/255.255.255.0
    read=system,call,log,verbose,command,agent,user
    write=system,call,log,verbose,command,agent,user

    Thanks,
    bao

    Like

    • André Perron June 18, 2011 at 07:57

      I corrected the typo in Step 19:

      In step 19:

      ln -s /usr/local/src/a2billing/AGI/a2billing_monitoring.php /var/lib/asterisk/agi-bin/a2billing-monitoring.php

      should be

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

      myasterisk is the username used for the Asterisk Manager Interface (AMI).
      mycode would be the password for that user.

      The username and password is made up just for the Asterisk Manager Interface (AMI).

      If you want more detailed information about the AMI, please see the site below:
      http://www.the-asterisk-book.com/unstable/asterisk-manager-api.html

      Like

  2. serhat August 30, 2011 at 15:55

    How can I integrate with freepbx ??? can anyone help me ?? please
    thank you very much

    Like

  3. Hafee December 1, 2011 at 15:01

    Nice tutorial everything working good, but there is some problem when I tried to connect user using soft phone, connection rejected or authentication fail error. I don’t know where is problem. Even I try with disabling iptables and fail2bain but not ok.

    Like

    • André Perron March 4, 2012 at 21:14

      To be honest with you, you’re gonna need to know a lot more about A2Billing and Asterisk to solve those kinds of problems.
      I don’t really have the time to diagnose the problem your describing as it would take hours to nail it down, and that’s if I had access to your installation.
      Keep in mind, these instructions are how to get PBX-in-a-Flash to ‘talk’ to A2Billing, not how to configure PIAF or A2Billing. There is just way too much information to go through.
      If you are implementing this for business purposes, you should contact Star2Billing as they specialize in this kind of setup. If you need free support, check out the PIAF forums at: http://pbxinaflash.com/forum/ and the A2Billing Forums at: http://forum.asterisk2billing.org/
      P.S.: Just so you know, it took me over 10 hours to get this working not including writing these instructions.

      Like

    • André Perron March 4, 2012 at 21:40

      You should check out the PBX-in-a-Flash Forums at: http://pbxinaflash.com/forum/ for help with that issue.

      Like

  4. Hafee December 2, 2011 at 10:19

    Please find below log:
    [2011-12-02 10:11:55] NOTICE[2958] chan_sip.c: Registration from ” failed for ‘192.168.1.4:4434’ – No matching peer found
    [2011-12-02 10:11:55] NOTICE[2958] chan_sip.c: Registration from ” failed for ‘192.168.1.4:4434’ – No matching peer found

    Like

  5. Cường Hoàng December 2, 2011 at 10:33

    Hi guys, i need help, i built asterisk with a2billing successfully, i created account number of a2billing and after that i registered successfully on soft phone but when i want to make a call
    i can not call, i get this error:

    == Using SIP RTP CoS mark 5
    — Executing [123453992318674@a2billing:1] Answer(“SIP/8872948899-00000019”, “”) in new stack
    == Spawn extension (a2billing, 123453992318674, 2) exited non-zero on ‘SIP/8872948899-00000019’

    My Voip system was built asterisk 1.6, freepbx 2.7 and a2billing stable 1.9, Please help me as soon as possible, thanks guys

    Like

  6. Daniel December 16, 2011 at 19:47

    Hi man, that’s awesome post, but i have a question, if I only want to install FreePBX on VirtualBox, I need the guest additions? Thanks

    Like

  7. Peter February 18, 2012 at 12:00

    I am not sure what I missed in this tutorial but I added the “sip” users and defined trunks in a2billing, added the contexts to freepbx.
    When i am in the Asterisk CLI with full verbosity and i try to login with a card number.. it says cannot find peer. As if its (asterisk/freepbx) is not even trying to look at a2billing stuff..
    Obviolsly freepbx runs of config files and a2billing is live.. I am not sure if this makes any issues

    Like

  8. src belgesi December 6, 2012 at 20:28

    Öncelikle yazınız için teşekkür.ederiz. Böyle yazıların bilgilendirici nitelikte olduğunu düşünüyoruz. Tekrar teşekkürler.

    Like

  9. More Info February 20, 2013 at 05:57

    Hey there just wanted to give you a quick heads up. The text in your post seem to be running off the screen in Ie.
    I’m not sure if this is a formatting issue or something to do with web browser compatibility but I figured I’d
    post to let you know. The layout look great though!
    Hope you get the issue resolved soon. Many thanks

    Like

  10. Kim February 25, 2013 at 15:52

    If some one wants expert view about blogging and
    site-building after that i advise him/her to pay a quick visit this website, Keep up the
    pleasant work.

    Like

  11. Ashwim March 8, 2013 at 16:33

    thanks for the great post. I installed a2billing successfully. Webadmin page of freepbx working fine. And webadmin of a2billing is also working fine. But I have a problem which is not letting me go forward. When I add customers from a2billing admin site, the sip voip info of this customer is not getting added to the additional_a2billing_sip.conf in the /etc/asterisk folder. the permissions and owner ship of the file is fine. I mean permission is 777 and owner is apache:apache. How do I solve this problem.

    Like

    • Ashwim March 8, 2013 at 16:35

      I also tried changing ownership of that file /etc/asterisk/additional_a2billing_sip.conf to root:root and also asterisk:asterisk still no help.

      Like

  12. Ashwim Manandhar March 8, 2013 at 17:19

    Thanks for this great post.
    I am currently using a very old version of a2biling on a virtual machine and it is working fine. Now I want to try latest version so I downloaded the destro available on asterisk.org and installed it on another virtual machine. The OS is centos 5.5 with freepbx 1.8.1.4. After the installation of OS i tried the freepbx admin site and could successfully add sip trunks. The trunks were also visible on the asterisk CLI command sip show peers. As far as here everything is ok. Now I followed this post and installed a2billing. Everything went on ok. After the installation was done. I tried adding customers on the a2billing site. Customers were added successfully but the corresponding SIP VOIP data were not written in the additional_a2billing_sip.conf file. thinking it might be because of the permission I changed the permission on this file /etc/asterisk/additional_a2billing_sip.conf file to 777… still no help… also changed the owner ship to apache:apache still no help. I even tried changing the ownership on this file to root:root and also asterisk:asterisk still no help.
    Leaving the default ownership of this file to apache:apache I opened this file from a2billing admin panel from config editor. Here I can make changes to the file and update it and the panel says ‘write completed successfully’. This means it is not the problem regarding permissions and ownership. Can anyone help me in this matter? I want any new a2billing user added on the panel to be reflected in the additional_a2billing_sip.conf file.

    Please help!!!

    Like

  13. how to stop biting your nails May 28, 2014 at 02:56

    Hi.
    I’m at work browsing your blog from my iphone
    4s! Just wanted to say I love reading through your blog and look forward
    to all your posts!

    Like

  14. Onay August 21, 2014 at 10:03

    Cool…….hhhoorreeeeeeeee……finally … It’s work we have billing system thanks

    Like

Leave a comment