BinaryGuru

Hacking digital systems

Tag Archives: centos

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!

Advertisements