How to Install Google TTS in Freepbx

Written by admin on March 13, 2015. Posted in Applications and addons, Asterisk

Many times you need a free voice in Freepbx since voice offered by Flite engine is horrible. The other offered by Swift is good but not cheap. Google TTS offers a free but averagely good conversion on text to speech. Problem is you get bits and pieces of information to such an extenst that a novice would not be able to fit these bits together to come up with a solution.

This article seeks to show step by step how to  install Google TTS on a freepbx machine. (PLEASE NOTE the Freepbx installation referred here is on Centos 6   64bit

After you have installed your freepbx you need to login as root on ssh and do the following

1. Install google tts

yum -y install perl perl-libwww-perl sox cpan
rpm -Uhv http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
yum -y install mpg123
PERL_MM_USE_DEFAULT=1 perl -MCPAN -e "install Bundle::LWP"
PERL_MM_USE_DEFAULT=1 perl -MCPAN -e "install CGI::Util"
wget https://github.com/zaf/asterisk-googletts/blob/master/googletts.agi
mv googletts.agi /var/lib/asterisk/agi-bin/
chmod 755 /var/lib/asterisk/agi-bin/googletts.agi

cd /tmp
git clone git://github.com/zaf/asterisk-googletts
cd asterisk-goo*
cd cli
mv googletts-cli.pl /usr/local/sbin/googletts-cli.pl


2. Configure propolys-tts.agi

nano /var/lib/asterisk/agi-bin/propolys-tts.agi

 

Find

case 'swift':
exec($enginebin." -p audio/channels=1,audio/sampling-rate=8000 -o $wavefile -f $textfile");
break;

and below add

case 'googleTTS':
exec($enginebin." -l de -f $textfile -r 8000 -o $wavefile");
break;

when done the file should  be able to look like this at the portion you edited

 

case 'swift':
exec($enginebin." -p audio/channels=1,audio/sampling-rate=8000 -o $wavefile -f $textfile");
break;
case 'googleTTS':
exec($enginebin." -l de -f $textfile -r 8000 -o $wavefile");
break;
default:
}

You are done configuring google TTS but before you start using it, Go to freepbx GUI and look under Settings for Text to speech Engines

add engine and name it whatever you want. If you dont have this module make sure you install it using module admin.

 

For the engine path use

/usr/local/sbin/googletts-cli.pl

Now you can select text to speech under applications in Freepbx you will now be able to see google tts on the dropdown along with flite.

 

I hope this tutorial helps


How to install data4voip

Written by admin on January 25, 2015. Posted in Asterisk, data4voip

Installation instructions for data4voip are so lean that to someone who is new to linux it will be a mountain to climb. This is probably why most people would prefer a2billing for wholesale than data4voip switch. Below is a simplified step by step how to install it. we also have an automated script for it. Visit our store to purchase it. The installation must be done on Centos 6. Please also note that the installed product is not the same exactly the same with the demo. Probably some features are available if you make them install for you. This defeats though the purpose why it is opensource.

1. Install Epel repos and update yum

# yum -y update
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo rpm -Uvh epel-release-6*.rpm

2. Install php

# yum -y install httpd nano php
yum --enablerepo=centosplus install mod_php

3. Correct time zone

Edit the file "/etc/php.ini", find the line ";date.timezone =", uncomment it and add your timezone

# nano +946 /etc/php.ini

4. Install other dependencies

# yum -y install mysql-server
yum -y install php-mysql php-gd php-domxml-php4-php5 unixODBC mysql- connector-odbc asterisk-odbc mod_ssl

5. Start mysql and set mysql password you can keep it as root now and change later

# service mysqld restart
mysqladmin -u root password 'root'

6. Install data4voip web interface

# cd /usr/src
wget http://www.data4voip.com/billing/data4voip_billing.tar.gz
tar -xzf data4voip_billing.tar.gz -C /var/www/html/

chown -R apache:apache /var/www/html/

find /var/www/html/ -type d -exec chmod 755 {} \;

find /var/www/html/ -type f -exec chmod 644 {} \;

find /var/www/html/agi/ -type f -exec chmod 744 {} \;

find /var/www/html/cron/ -type f -exec chmod 744 {} \;
7. Create database

# mysql -u root -p
<mysql> CREATE DATABASE v_billing;

exit

8. Populate the database

# wget http://www.data4voip.com/billing/billing_database.sql
mysql -u root -p v_billing < billing_database.sql

cd /etc/
wget http://www.data4voip.com/billing/database.inc
chown -Rf apache:apache /etc/database.inc
chmod 400 /etc/database.inc

9. Install asterisk

# sed -i s/SELINUX=enforcing/SELINUX=disabled/g /etc/selinux/config
setenforce 0

yum install -y make wget openssl-devel ncurses-devel newt-devel libxml2-devel kernel-devel gcc gcc-c++ sqlite-devel libuuid-devel
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-current.tar.gz
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-11-current.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 /usr/src/asterisk*
./configure --libdir=/usr/lib64 && make menuselect && make && make install
make clean && make distclean
make samples
make config
service dahdi start
service asterisk start

10. Replace config files or change the parameters in these files to suit your details if you used different mysql password

#  cd /etc/
wget http://www.data4voip.com/billing/odbcinst.ini
wget http://www.data4voip.com/billing/odbc.ini
cd /etc/asterisk/
wget http://www.data4voip.com/billing/res_odbc.conf
wget http://www.data4voip.com/billing/manager.conf
wget http://www.data4voip.com/billing/extensions.conf
wget http://www.data4voip.com/billing/sip.conf
wget http://www.data4voip.com/billing/extconfig.conf

How to limit concurrent calls for asterisk extensions

Written by admin on November 22, 2014. Posted in Asterisk

Sometime you need to limit the number of simultaneous calls that an extension can be allowed to make. freepbx has a trunk simultaneous calls limitation but does not have the SIP account limitation facility. the workaround  is to do the following.

Login to your server via ssh and do the following

# nano sip_custom_post.conf

suppose the extension you want to limit is 3500  and you want to limit the call limit to 3 simultaneous calls. hen you must copy and paste the following.

[3500](+)
call-limit=3

Save the file by clicking  CTRL + X   and then confirm with a Y

Restart asterisk

# amportal restart

How to transfer calls between extensions

Written by admin on November 22, 2014. Posted in Asterisk

Many clients keep asking  how to transfer calls between extensions. Here is how you do it. Please note that i we will be launching a forum where such specific questions can be answered.

When you receive a call on an extension and you wish to transfer it to another extension here is what you do:

Press## in quick succession

You will here a music on hold sound.

Enter the extension you wish to transfer the call to. Your call will start ringing on the other extension.

How to limit concurrent calls for asterisk extensions

Written by admin on November 22, 2014. Posted in Asterisk, Server Security

Sometime you need to limit the number of simultaneous calls that an extension can be allowed to make. freepbx has a trunk simultaneous calls limitation but does not have the SIP account limitation facility. the workaround  is to do the following.

Login to your server via ssh and do the following

# nano sip_custom_post.conf

suppose the extension you want to limit is 3500  and you want to limit the call limit to 3 simultaneous calls. hen you must copy and paste the following.

[3500](+)
call-limit=3

Save the file by clicking  CTRL + X   and then confirm with a Y

Restart asterisk

# amportal restart

How to install Asterisk and FreePBX on an OPENVZ server

Written by admin on November 22, 2014. Posted in Asterisk, Freepbx

yum grouplist installed

Installed Groups:
DNS Name Server
Editors
Legacy Network Server
Mail Server
Network Servers
System Tools
Text-based Internet
Web Server
Windows File Server
Yum Utilities

yum groupremove 'DNS Name Server'
yum groupremove 'Editors'
yum groupremove 'Legacy Network Server'
yum groupremove 'Mail Server'
yum groupremove 'Network Servers'
yum groupremove 'System Tools'
yum groupremove 'Text-based Internet'
yum groupremove 'Web Server'
yum groupremove 'Windows File Server'

Now update the base install

yum -y update

Install Asterisk/FreePBX required packages, other useful packages, and their dependencies

yum groupinstall core
yum groupinstall base

yum install gcc gcc-c++ wget bison mysql-devel mysql-server php php-mysql php-pear php-pear-DB php-mbstring nano tftp-server httpd make ncurses-devel libtermcap-devel sendmail sendmail-cf caching-nameserver sox newt-devel libxml2-devel libtiff-devel php-gd audiofile-devel gtk2-devel subversion nano kernel-devel selinux-policy

RHEL v5 NOTES:
Skip this section if you are using a RHEL6 distribution.

On RHEL 5 shutdown unnecessary daemon brcm-iscsi which is enabled by default and tends to do a lot of logging even when not used. This creates unnecessary I/O load.

chkconfig iscsi off
chkconfig iscsid off
service iscsi stop
service iscsid stop

Replace syslog with the improved and backwards compatible rsyslog (standard in RHEL6 but not RHEL5).  This also prevents a problem that comes up with improper timestamps in /var/log/secure when you get disconnects.

NOTE:This is only for RHEL5 based systems.  You do not need to do this for RHEL6.

yum -y install rsyslog
chkconfig syslog off
chkconfig rsyslog on
service syslog stop
service rsyslog start

--END of RHEL v5 NOTES--
RHEL v6 NOTES: 
Skip this section if you are using a RHEL5 based distribution.

On RHEL v6 and it's clone distributions the php-pear-DB package is not included.  You need to download it from an official mirror and install otherwise the FreePBX install will fail.  Click the link to check for the latest version.

cd /usr/src
wget http://dl.fedoraproject.org/pub/epel/6/i386/php-pear-DB-1.7.13-3.el6.noarch.rpm

rpm -ivh php-pear-DB*

RHEL v6 uses a newer version of php.  In this version php-posix is no longer in php-common, it is in php-process.  So you need to install php-process if using RHEL v6 or it's clones otherwise the FreePBX install will fail.

yum -y install php-process

Check if the firewall (iptables) is enabled by default and if the RHEL v6 default configuration blocks the FreePBX web GUI.  If you know what services/ports are required you can run "system-config-firewall-tui" and configure the firewall as required.

At a minimum, the following ports need to be opened:
TCP 80 (www)
TCP 4445 (Flash Operator Panel)
UDP 5060-5061 (SIP)
UDP 10,000 - 20,000 (RTP)
UDP 4569 (IAX)

Another option is to remove existing settings from the firewall and save.
iptables -F
service iptables save

Alternatively, you can disable the firewall for now and prevent it from starting on reboot.

service iptables stop
chkconfig iptables off

--END of RHEL v6 NOTES--
Selinux is not required or recommended.  This will create the required file if it does not already exist.  If it already exists copy paste or edit the contents indicated here to be sure selinux never runs.

nano /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.

SELINUXTYPE=targeted
# SETLOCALDEFS= Check local definition changes
SETLOCALDEFS=0

(Ctrl-x> y >Enter)

Make sure selinux is turned off for this session

setenforce 0

TFTP

Enable the tftp server on startup if required (for configuring phones)
nano /etc/xinetd.d/tftp
change server_args = from "-s /var/lib/tftpboot" to "-s /tftpboot"
change “disable=yes” to “disable=no”
(Ctrl-X>y>ENTER)

mkdir /tftpboot
chmod 777 /tftpboot
service xinetd restart

Set Timezone
Copy your timezone from this link

System timezone
Create a symbolic link to the appropriate timezone from /etc/localtime.
Example:
ln -sf /usr/share/zoneinfo/America/Vancouver /etc/localtime

PHP timezone (required since PHP v5.3):
if not set and using php v5.3+ (the version included with RHEL6) it will revert to the default timezone which may not be the correct one depending on your location.  The FreePBX install will throw out a bunch of warnings if you are using RHEL 6 and don't set this.
for RHEL5:
nano +633 /etc/php.ini
for RHEL6
nano +946 /etc/php.ini
Uncomment (;) date.timezone = and add your timezone
Restart apache for the changes to take effect
service httpd restart

Memory Limit

The recommended setting is 128M otherwise you may get warnings in FreePBX.  RHEL 5 installs will probably already have this set correctly.  RHEL 6 may need to have this changed.

For RHEL 5
nano +302 /etc/php.ini
memory_limit = 128M

For RHEL 6
nano +457 /etc/php.ini
memory_limit = 128M

As always after php.ini changes, apache needs to be restarted for the changes to take effect.
service httpd restart
Download and untar source files.   Zaptel/Dahdi is not included in this install procedure.  Starting with Asterisk 1.6.2/FreePBX2.9, it is possible to use ConfBridge in place of MeetMe conferencing.  Meetme conferencing was the last Asterisk application that required a timing source. The only reason to install zaptel/dahdi now is if you are installing telephony hardware.  Meetme still has some features that confbridge does not and is still required if you also require paging.  To install meetme conferencing you must install dahdi and ensure meetme is selected during the asterisk menuselect installation part of the procedure.  You can also install confbridge but FreePBX will default to use MeetMe if it detects it.

Get FreePBX.  Check if this is the latest released version.
cd /usr/src
wget http://mirror.freepbx.org/freepbx-2.10.0.tar.gz
tar zxvf freepbx-2.10.0.tar.gz

Get Asterisk v1.8.
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-1.8-current.tar.gz
tar zxvf asterisk-1.8-current.tar.gz

NOTE: There is no separate asterisk addons package to download starting with Asterisk v1.8

cd /usr/src/asterisk-1.8*
make clean
./configure && make menuselect

Select all addons.  I believe these are all needed or recommended for FreePBX.  Select base and addon sounds.  I suggest ulaw as they sound better than gsm especially if you are using ulaw as your default codec.  I usually just check both.  Then make sure to press the "save" button afterwards.

When you select 'format_mp3' above as an addon you must run a script before going any further otherwise the install will fail.

./contrib/scripts/get_mp3_source.sh

You must also have subversion installed to run the above script and be in the root directory of the Asterisk source code.

Now install Asterisk.  NOTE: If upgrading Asterisk on an already running FreePBX system do NOT run make samples.

make && make install && make samples

Create user.  May already exist but just to make sure
useradd -c "Asterisk PBX" -d /var/lib/asterisk asterisk

The following directory may already exist but just to make sure
mkdir /var/run/asterisk

Set ownership
chown -R asterisk /var/run/asterisk
chown -R asterisk /var/log/asterisk
chown -R asterisk /var/lib/asterisk/moh
chown -R asterisk /var/lib/php/session

Music on Hold
The Asterisk default moh directory is "/moh" and the Freepbx default moh directory is "/mohmp3".  If we create a symbolic link instead everything is in one place and can still be found by both FreePBX and Asterisk.  FreePBX uses mohmp3 by default so moh just sits there unused if we do not create a symbolic link.  You can switch between these two moh directories in the new Advanced Settings GUI.  I still include this symbolic link procedure for legacy reasons.  If you do it everything is in one directory always no matter what.  That simplifies things and simpler is often better.
ln -s /var/lib/asterisk/moh /var/lib/asterisk/mohmp3

The new default behaviour for Asterisk and Freepbx is to only use wav files for moh due to transcoding overhead and Asterisk stability issues with mp3's. So we want to install mpg123 for converting uploaded mp3's to wav automagically.  If you won't be uploading or streaming mp3's or won't be using FreePBX (new) default behaviour then you probably don't need to install mpg123.

cd /usr/src
wget http://sourceforge.net/projects/mpg123/files/mpg123/1.14.2/mpg123-1.14.2.tar.bz2/download
tar -xjvf mpg123-1.14.2.tar.bz2

cd mpg123-1.14.2
./configure && make && make install

Freepbx php script cannot find mpg123 by default so we need to create a symbolic link.
ln -s /usr/local/bin/mpg123 /usr/bin/mpg123

 

CHANGE APACHE USER

Change User apache and Group apache to User asterisk and Group asterisk.

sed -i "s/User apache/User asterisk/" /etc/httpd/conf/httpd.conf
sed -i "s/Group apache/Group asterisk/" /etc/httpd/conf/httpd.conf

 

MYSQL SETUP

Before you can do anything to MySQL, you need to make sure it's running:
NOTE: If running RHEL/CENTOS/SL 6 you may need to run this first.
mysql_install_db
Try without and see if it starts first.

service mysqld start
Initializing MySQL database:                               [  OK  ]
Starting MySQL:                                            [  OK  ]

Now, to configure the databases for freePBX:
Note: If mysql admin password is already configured, add "-p" after the command and enter password when asked.  For example, "mysqladmin -p create asterisk"

cd /usr/src/freepbx-2.10.0
mysqladmin create asterisk
mysqladmin create asteriskcdrdb
mysql asterisk < SQL/newinstall.sql
mysql asteriskcdrdb < SQL/cdr_mysql_table.sql

They also need to be secured.  FreePBX will prompt you for a database username/password when you do the install. You need to pick that now. We'll assume that you've picked 'asteriskuser' and 'amp109' - you probably shouldn't use these, as they are well known passwords for Freepbx.  If you use these well know defaults and your server is not firewalled make sure to set bind-address = 127.0.0.1 further down in this procedure so that MySQL only listens to localhost.  Or better yet do both.

Security check: It's very important to check that Allow Login With DB Credentials is set to FALSE in FreePBX Advanced Settings GUI.  This is the default setting.  If it were set to TRUE and you were using the default credentials ofasteriskuser/amp109 and your FreePBX GUI were exposed to the internet (ie. the http port), anyone could log into yourFreePBX GUI as administrator using those credentials.

MySQL creates a test database and 2 anonymous user accounts by default which we don't need so first we delete them.  MySQL also creates a non-local root@hostname account and assuming you don't want to access the database remotely as root (other than via SSH) you should probably delete that for security reasons.  DO NOT DELETE the root@localhost account.

mysql

mysql> DROP DATABASE test;
Query OK, 0 rows affected (0.00 sec)

mysql> SHOW VARIABLES LIKE 'hostname';
+---------------+----------------+
| Variable_name | Value          |
+---------------+----------------+
| hostname      | somehostname.com |
+---------------+----------------+
1 row in set (0.00 sec)

mysql> DROP USER ''@'localhost';
Query OK, 0 rows affected (0.00 sec)

mysql> DROP USER ''@'somehostname.com';
Query OK, 0 rows affected (0.00 sec)

mysql> DROP USER 'root'@'somehostname.com';

mysql> GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY 'amp109';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY 'amp109';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> \q
Bye

Now, after all of this, you need to pick a root 'mysql' password. We'll make it 'abcdef' just for this example.  You should use a reasonably strong password. If you need to do anything else with mysql, you'll need to provide this password.
mysqladmin -u root password 'abcdef'
Install FreePBX

/usr/sbin/safe_asterisk
You may get a bunch of warnings, errors, and notices at this point.  Don't worry about them.  Hit ENTER to get a command prompt.

cd /usr/src/freepbx-2.10.0
./install_amp

If you get any warnings or errors in the last part of the output, they're usually not traumatic.

Default username is: admin
Default pw is: admin
Freepbx 2.10 now wants to create symlinks to some .conf files and complains if actual files already exist as is the case when Asterisk make samples is run.  So we need to delete these files.  In FreePBX 2.9 you should only have to delete sip_notify.conf and ccss.conf.  Not sure what would happen if you try delete the rest.  After deleting the following files, the next time we make a change in FreePBX and apply settings these symlinks will be created.

rm -f /etc/asterisk/sip_notify.conf
rm -f /etc/asterisk/iax.conf
rm -f /etc/asterisk/logger.conf
rm -f /etc/asterisk/features.conf
rm -f /etc/asterisk/sip.conf
rm -f /etc/asterisk/extensions.conf
rm -f /etc/asterisk/ccss.conf
rm -f /etc/asterisk/chan_dahdi.conf

Edit /etc/asterisk/cdr_mysql.conf and add 'loguniqueid=yes' to the global section which will give each call record a unique identifier number.

nano /etc/asterisk/cdr_mysql.conf

loguniqueid=yes
set FreePBX to start on boot
echo /usr/local/sbin/amportal start >> /etc/rc.local

Enable Apache and MySQL to start on boot
chkconfig httpd on
chkconfig mysqld on

Now reboot at which point you should be able to access FreePBX with your web browser.  The very first thing you need to do when you enter the FreePBX Admin GUI for the first time is "Apply Configuration Changes" so all the *.conf files are created then reboot again or 'amportal restart' from command prompt.

You may get an error in the FreePBX GUI saying "symlink failed for /etc/asterisk/sip_notify.conf" or something along those lines.  If that is the case just delete or rename /etc/asterisk/sip_notify.conf.  The next time you "Apply Configuration Changes" in the FreePBX GUI after some change this file will be recreated and the error should be gone.

AMPORTAL.conf changes

FreePBX v2.9+ now includes an "advanced settings" gui that is designed to replace amportal.conf and the requirements to edit it directly.  There are also some settings in a new file /etc/freepbx.conf

At this point you should go into this new advanced settings GUI on the FreePBX webpage and edit the following settings:

http://IPaddressOFyourFreePBXserver/

In the GUI Go to: Tools>Advanced Administration>Advanced Settings>System Setup>User Portal Admin Password

Choose your admin password for accessing the Voicemail & Recordings (ARI) section of the front webpage.

In the same GUI go to: System Setup>FreePBX Web Address

Remove the "xx.xx.xx.xx" and leave blank.  If that does not work use your public (ie. web facing) IP address for this server.

After saving these changes by pressing the green arrow on the right hand side of each box make sure to "Apply Configuration Changes" at the top of the GUI.

How to install G.729 and G.723 open source codecs on Elastix

Written by admin on November 22, 2014. Posted in Asterisk, Elastix

Please note that this tutorial is for education purposes only. If you want to use the codecs you should consider paying royalties to the creators of the codecs.

Precompiled codec modules can be found here: http://asterisk.hosting.lv  choose the one that is for your system architecture.

To find the details of your server architecture do the following

# uname -a

# cat /proc/cpuinfo

Use the information to select the codec suitable for your server.

Navigate to the modules folder

#  cd /usr/lib/asterisk/modules

or  if using 64 bit centos

# cd /usr/lib64/asterisk/modules

Download the codecs e.g

# wget http://asterisk.hosting.lv/bin/codec_g723-ast18-gcc4-glibc-pentium4.so

# wget http://asterisk.hosting.lv/bin/codec_g729-ast18-gcc4-glibc-pentium4.so

# /etc/init.d/asterisk restart

# asterisk -r

#CLI> core show translation

You should now see the codecs populated.

How to install AsteriskNow with Freepbx on Centos 6 VPS

Written by admin on November 22, 2014. Posted in Asterisk, Freepbx

It is a little complex to install freepbx and asterisk from scratch on a vps. However installing the AsteriskNow packagees ensure a smooth and simple installation procedure. In this tutorial we are going to be installing Freepbx 2.11 and AsteriskNow.

 

Installing asterisk now

# yum -y install dnsmasq 

# rpm -Uvh http://packages.asterisk.org/centos/6/current/i386/RPMS/asterisknow-version-3.0.0-1_centos6.noarch.rpm

# yum -y update

# yum -y install asterisk asterisk-configs --enablerepo=asterisk-11

 #  yum -y install dahdi-linux dahdi-tools libpri
Installing Freepbx

# yum -y install gcc gcc-c++ wget bison mysql-devel mysql-server php php-mysql php-process php-pear php-mbstring tftp-server httpd make ncurses-devel libtermcap-devel sendmail sendmail-cf caching-nameserver sox newt-devel libxml2-devel libtiff-devel php-gd audiofile-devel gtk2-devel subversion nano kernel-devel selinux-policy sqlite-devel openssl-devel

***Install CDR ODBC required packages

# yum -y  install libtool-ltdl-devel unixODBC unixODBC-devel mysql-connector-odbc

***Install optional packages

****chan_gtalk, chan_motif, and res_xmpp will not compile unless iksemel-devel and it's dependencies are installed. If you plan to use Google Voice ****you will need to install this. For CentOS 6, iksemel is in the EPEL repository.

#rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
yum -y install iksemel-devel

****Install pear DB

****Don't worry about the warning message.

# pear install db

# yum -y install asterisk-odbc php-pear-DB asterisk-sounds-extra-en-gsm
# nano /usr/sbin/safe_asterisk

Find the line with TTY=9 and comment it out like this #TTY=9
# /usr/sbin/safe_asterisk
# rpm -Uvh http://packages.asterisk.org/centos/6/current/x86_64/RPMS/freepbx-2.11.0-1_centos6.x86_64.rpm

# amportal chown /etc/dahdi/modules

# amportal chown /etc/dahdi/system.conf

Navigate to http://youripaddress  and enter your login credentials. Then login with those credentials

How to install A2billing on a VPS

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

1. We need to install php 5.2 first because a2billing uses 5.2 but Centos 5 comes with php 5.1

# nano /etc/yum.repos.d/centos-testing.repo

and add the following:

[c5-testing]
name=CentOS-5 Testing
baseurl=http://dev.centos.org/centos/$releasever/testing/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing
includepkgs=php*

press Ctrl X>Y> Enter

Now update

# yum update

2. Install additional required packages if not already installed

# yum -y install php-mcrypt perl-DBD-Pg

3. Change php folder permission back to what it was set to during Asterisk/FreePBX install before PHP update

# chown -R asterisk:asterisk /var/lib/php/session

4. Add php timezone:

# nano +639 /etc/php.ini

Uncomment date.timezone =Africa/Cairo

Change # date.timezone = to date.timezone =Africa/Cairo
5. Restart apache for the changes to take effect

# service httpd restart

6. Get a2billing source

# cd /usr/src
wget --no-check-certificate https://github.com/Star2Billing/a2billing/tarball/v1-current

If you are installing on Centos 6 better grab the latest version on

wget https://github.com/Star2Billing/a2billing/archive/master.tar.gz

Note the filename of the downloaded file and use it as follows:

# tar zxvf   v1-current

# mv Star2Billing-a2billing-xxxxxxx   a2billing

7. Prepare MySQL database

# cd /usr/src/a2billing
# mysql -u root -p < DataBase/mysql-5.x/a2billing-createdb-user.sql
# cd /usr/src/a2billing/DataBase/mysql-5.x
./install-db.sh
Answer questions as follows:

Enter Database Name: mya2billing
Enter Hostname: localhost
Enter UserName: root
Enter Password: 'mysqlrootpassword'
# cp /usr/src/a2billing/a2billing.conf /etc/
nano /etc/a2billing.conf

Make sure the following parameters are set as shown.

[database]
hostname = localhost
port = 3306
user = a2billinguser
password = a2billing
dbname = mya2billing
dbtype = mysql

8. Create files and set permissions

# 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_custom.conf
echo \#include additional_a2billing_iax.conf >> /etc/asterisk/iax_custom.conf
chown -Rf asterisk:asterisk /etc/asterisk/additional_a2billing_iax.conf
chown -Rf asterisk:asterisk /etc/asterisk/additional_a2billing_sip.conf

9. Run sound installation script

# cd /usr/src/a2billing/addons/sounds
./install_a2b_sounds.sh
chown -R asterisk:asterisk /var/lib/asterisk/sounds/

# nano /etc/asterisk/manager_custom.conf

[myasterisk]
secret=mycode
deny=0.0.0.0/0.0.0.0
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

10. Set up a2billing web folder

# mkdir /var/www/html/a2billing
cp -Rf /usr/src/a2billing/admin /var/www/html/a2billing/admin
cp -Rf /usr/src/a2billing/agent /var/www/html/a2billing/agent
cp -Rf /usr/src/a2billing/customer /var/www/html/a2billing/customer
cp -Rf /usr/src/a2billing/common /var/www/html/a2billing/common

# chown -R asterisk:asterisk /var/www/html/a2billing
chmod 755 /var/www/html/a2billing/admin/templates_c
chmod 755 /var/www/html/a2billing/customer/templates_c
chmod 755 /var/www/html/a2billing/agent/templates_c

11. Set up AGI

# mkdir /var/lib/asterisk/agi-bin
cd /usr/src/a2billing/AGI
cp a2billing.php /var/lib/asterisk/agi-bin/
chown -R asterisk:asterisk /var/lib/asterisk/agi-bin
chmod 755 /var/lib/asterisk/agi-bin/a2billing.php
ln -s /var/www/html/a2billing/common/lib /var/lib/asterisk/agi-bin/lib

# nano /etc/asterisk/extensions_custom.conf

[macro-dialout-trunk-predial-hook]
exten => s,1,GotoIf($["${OUT_${DIAL_TRUNK}:4:4}" = "A2B/"]?custom-freepbx-a2billing,${OUTNUM},1:2)
exten => s,2,MacroExit

[custom-freepbx-a2billing]
exten => _X.,1,DeadAGI(a2billing.php,${OUT_${DIAL_TRUNK}:8})
exten => _X.,n,Hangup()

[a2billing]
exten => _X.,1,Answer
exten => _X.,n,Wait(1)
exten => _X.,n,deadAGI(a2billing.php,1)
exten => _X.,n,Hangup

[a2billing-callback]
exten => _X.,1,deadAGI(a2billing.php,1,callback)
exten => _X.,n,Hangup

[a2billing-cid-callback]
exten => _X.,1,deadAGI(a2billing.php,1,cid-callback,34) ;last parameter is the callback area code
exten => _X.,n,Hangup

[a2billing-all-callback]
exten => _X.,1,deadAGI(a2billing.php,1,all-callback,34) ;last parameter is the callback area code
exten => _X.,n,Hangup

[a2billing-did]
exten => _X.,1,deadAGI(a2billing.php,1,did)
exten => _X.,2,Hangup

[a2billing-voucher]
exten => _X.,1,deadAGI(a2billing.php,1,voucher)
exten => _X.,n,Hangup

[custom-a2billing-did]
exten => _X.,1,deadAGI(a2billing.php,1,did)
exten => _X.,2,Hangup

[custom-a2billing]
exten => _X.,1,deadAGI(a2billing.php,1)
exten => _X.,n,Hangup

Go into FreePBX GUI>Setup>Trunks>Add Custom Trunk give it a name and add the following dial string

Local/$OUTNUM$@a2billing/n
12. Add custom destinations to FreePBX via FreePBX GUI>Tools>Custom Destinations

Custom Destination: custom-a2billing,${EXTEN},1
Destination Quick Pick: (pick destination)
Description: A2Billing - Callthrough
Custom Destination: custom-a2billing-did,${EXTEN},1
Destination Quick Pick: (pick destination)
Description: A2Billing - DID

13. Start or restart FreePBX

# amportal restart

Recurring Services
Recurring services are handled via the /etc/crontab.

14 Make directory for A2Billing cron PID

mkdir -p /var/run/a2billing
chown asterisk:asterisk /var/run/a2billing
Copy cron files to some permanent location such as /usr/local
mkdir -p /usr/local/a2billing
cp -R /usr/src/a2billing/Cronjobs /usr/local/a2billing/
ln -sf /var/www/html/a2billing/common/lib /usr/local/a2billing/Cronjobs/lib
chown -R asterisk:asterisk /usr/local/a2billing

15. Add the cron jobs to /var/spool/cron/asterisk.

# nano /var/spool/cron/asterisk

# update the currency table
0 6 * * * php /usr/local/a2billing/Cronjobs/currencies_update_yahoo.php
# manage the monthly services subscription
0 6 1 * * php /usr/local/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/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/a2billing/Cronjobs/a2billing_bill_diduse.php
# This script will take care of the recurring service.
0 12 * * * php /usr/local/a2billing/Cronjobs/a2billing_batch_process.php
# To generate invoices and for each user.
0 6 * * * php /usr/local/a2billing/Cronjobs/a2billing_batch_billing.php
# to proceed the autodialer
*/5 * * * * php /usr/local/a2billing/Cronjobs/a2billing_batch_autodialer.php
# manage alarms
0 * * * * php /usr/local/a2billing/Cronjobs/a2billing_alarm.php
# manage archive
0 12 * * * php /usr/local/a2billing/Cronjobs/a2billing_archive_data_cront.php
#autorefill
0 10 21 * * php /usr/local/a2billing/Cronjobs/a2billing_autorefill.php
15 * * * * php /usr/local/a2billing/Cronjobs/a2billing_batch_cache.php

16. Add log files:

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

# chown -R asterisk:asterisk /var/log/a2billing

Add index file to prevent browsing of root folder
touch /var/www/html/a2billing/index.html

# Log into the webpage

http://<ip-addr>/a2billing/admin

user: root
pass: changepassword

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

Written by admin on November 22, 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 pgp.mit.edu --recv-keys 175E41DF

#add-apt-repository "deb http://packages.asterisk.org/deb `lsb_release -cs` main"
#sudo add-apt-repository "deb-src http://packages.asterisk.org/deb `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 https://github.com/Star2Billing/a2billing/tarball/v1-current

# 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

# ./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 = 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
./install_a2b_sounds_deb.sh
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
nano -w a2billing

/var/log/a2billing/*.log {
daily
missingok
rotate 4
sharedscripts
postrotate
endscript
}

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

 

REMEMBER TO CHANGE YOUR PASS WORD