Centos - RHEL

Setup you server with only the base packages and text based internet.

Asterisk

Install the EPEL repo

For CentOS/RHEL Version 6

rpm -i http://be.mirror.eurid.eu/epel/6/i386/epel-release-6-5.noarch.rpm

For CentOS/RHEL Version 5

 rpm -i http://be.mirror.eurid.eu/epel/5/i386/epel-release-6-5.noarch.rpm
 yum upgrade

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

 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


RHEL v6 NOTES:

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://download.fedora.redhat.com/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
  1. This file controls the state of SELinux on the system.
  2. SELINUX= can take one of these three values:
  3. enforcing - SELinux security policy is enforced.
  4. permissive - SELinux prints warnings instead of enforcing.
  5. disabled - SELinux is fully disabled.

SELINUX=disabled

  1. SELINUXTYPE= type of policy in use. Possible values are:
  2. targeted - Only targeted network daemons are protected.
  3. strict - Full SELinux protection.

SELINUXTYPE=targeted

  1. SETLOCALDEFS= Check local definition changes

SETLOCALDEFS=0

(Ctrl-x> y >Enter)

Make sure selinux is turned off for this session

 setenforce 0

Enable the tftp server on startup if required (for configuring phones)

 nano /etc/xinetd.d/tftp

change “disable=yes” to “disable=no”

(Ctrl-X>y>ENTER)

Set Timezone

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


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.9.0.tar.gz
 tar zxvf freepbx-2.9.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.13.4/mpg123-1.13.4.tar.bz2/download
 tar -xjvf mpg123-1.13.4.tar.bz2
 cd mpg123-1.13.4
 ./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:

 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.9.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.

 mysql
 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 will 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.9.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.


Misc. optional settings

Change the “upload_max_filesize” from 2M to 20M to allow larger music on hold files RHEL 5

 nano +582 /etc/php.ini

RHEL 6

 nano +878 /etc/php.ini

Edit Apache web server for GUI access using a port other than 80:

 nano +134 /etc/httpd/conf/httpd.conf

change "Listen 80" to "Listen 8888" or whatever port you want

Change default Apache setting of AllowOverride None to All so that Apache obeys directives in .htaccess files which by default prevents viewing sensitive directories on Freepbx.

 nano +338 /etc/httpd/conf/httpd.conf

AllowOverride All

 service httpd restart

Instead of accessing FreePBX by http://xxx.xxx.xxx.xxx You now access it by http://xxx.xxx.xxx.xxx:8888 setup external sip extensions if going through NAT

 nano /etc/asterisk/sip_nat.conf

nat=yes externip=<your fixed external IP> or

externhost=yourdns.com

localnet=192.168.1.0/255.255.255.0

change the above to whatever your local subnet is

externrefresh=10

(Ctrl-X>y>ENTER)

Also, when adding the external SIP extension in FreePBX, make sure to change the nat=never default in the configuration to nat=yes for the extension that will be external. logrotate setup

Set up configuration to rotate log files otherwise they get too big after a short while. Create the following file.

 nano /etc/logrotate.d/asterisk

Now add the following to make sure the asterisk log files are rotated weekly along with all the other log files.

/var/log/asterisk/messages /var/log/asterisk/*log /var/log/asterisk/full {

  missingok
  notifempty
  sharedscripts
  create 0640 asterisk asterisk
  postrotate
  /usr/sbin/asterisk -rx 'logger reload' > /dev/null 2> /dev/null
  endscript

}

A2Billing

Follow the instructions at http://trac.asterisk2billing.org/cgi-bin/trac.cgi/browser/trunk/INSTALL.Centos


Installation Prerequisites

Install Dependencies

 yum -y install perl-DBD-Pg subversion

get A2Billing

 mkdir /usr/local/src/a2billing
 cd /usr/local/src/a2billing
 svn co --username guest --password guest http://svn.a2billing.net/svn/asterisk2billing/trunk/ /usr/local/src/a2billing

copy a2billing.conf in /usr/local/src/a2billing/a2billing.conf to /etc/a2billing.conf

Edit a2billing.conf to suit your installation. e.g. change dbtype to mysql.

Install Database

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

Answer the questions appropriately with reference to /etc/a2billing.conf

You should now have a database called mya2billing with over 70 tables in it.

Install the AGI and Sound Files

So that we can easily update the system when changes are made during this period of change, we are going to use links back to the location where we installed the SVN download, so that an update from the SVN will immediately reflect in your A2Billing install.

Note that Database changes will not be included using this methodology, so these will have to be done by hand.

This is not the usual way of doing it, but for testing, it works well. You can also simply move or copy the files into the appropriate location.

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

set ownership and permissions on AGI

 chown asterisk:asterisk /var/lib/asterisk/agi-bin/a2billing.php
 chmod +x /var/lib/asterisk/agi-bin/a2billing.php

Set up sounds

 cd /usr/local/src/a2billing/addons/sounds
 ./install_a2b_sounds.sh

set ownership on sounds

 chown -R asterisk:asterisk /var/lib/asterisk/

Asterisk Manager

Now edit /etc/asterisk/manager_custom.conf (or manager.conf for those not using a pre-rolled distribution including FreePBX). Add the following lines

 [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

Install Web Pages

Assumption is that apache2 root folder is /var/www/html

 mkdir /var/www/html/a2billing

Common

 ln -s /usr/local/src/a2billing/common /var/www/html/a2billing/common

Admin pages

 ln -s /usr/local/src/a2billing/admin /var/www/html/a2billing/admin

Agent

 ln -s /usr/local/src/a2billing/agent /var/www/html/a2billing/agent

Customer

 ln -s /usr/local/src/a2billing/customer /var/www/html/a2billing/customer

Now we need to set permissions for Apache.

If you are using a pre-rolled Distro, then web group and ownership are asterisk and asterisk, if you are not using a distro, then you probably know what to set anyway.

 chown -R asterisk:asterisk /var/www/html/a2billing/
 chown -R asterisk:asterisk /usr/local/src/a2billing/common
 chown -R asterisk:asterisk /usr/local/src/a2billing/admin
 chown -R asterisk:asterisk /usr/local/src/a2billing/customer
 chown -R asterisk:asterisk /usr/local/src/a2billing/agent

Cronjobs

Create folder directory for Cronts PID

 mkdir -p /var/run/a2billing
 echo "
 # Automatically added for A2Billing
 0 * * * * php /usr/local/src/a2billing/Cronjobs/a2billing_alarm.php
 0 12 * * * php /usr/local/src/a2billing/Cronjobs/a2billing_archive_data_cront.php
 0 10 21 * * php /usr/local/src/a2billing/Cronjobs/a2billing_autorefill.php
 #Batch process at 00:20 each day
 20 0 * * * php /usr/local/src/a2billing/Cronjobs/a2billing_batch_process.php
 #Bill DID usage at 00:00 each day
 0 0 * * * php /usr/local/src/a2billing/Cronjobs/a2billing_bill_diduse.php
 #Generate Invoices at 6am everyday
 0 6 * * * php /usr/local/src/a2billing/Cronjobs/a2billing_batch_billing.php
 #Check if balance below preset value, and email user if so.
 1 * * * * php /usr/local/src/a2billing/Cronjobs/a2billing_notify_account.php
 #Charge subscriptions at 06:05 on the 1st of each month
 0 6 1 * * php /usr/local/src/a2billing/Cronjobs/a2billing_subscription_fee.php
 #Update currencies at 01:00 each day
 0 1 * * * php /usr/local/src/a2billing/Cronjobs/currencies_update_yahoo.php
 " >> /var/spool/cron/asterisk

Add directory for monitoring Script

 mkdir -p /var/lib/a2billing/script

Create Log Files

Log files and Permissions

 touch /var/log/asterisk/a2billing-daemon-callback.log
 touch /var/log/a2billing-daemon-callback.log
 touch /var/log/cront_a2b_alarm.log
 touch /var/log/cront_a2b_autorefill.log
 touch /var/log/cront_a2b_batch_process.log
 touch /var/log/cront_a2b_bill_diduse.log
 touch /var/log/cront_a2b_subscription_fee.log
 touch /var/log/cront_a2b_currency_update.log
 touch /var/log/cront_a2b_invoice.log
 touch /var/log/a2billing_paypal.log
 touch /var/log/a2billing_epayment.log
 touch /var/log/api_ecommerce_request.log
 touch /var/log/api_callback_request.log
 touch /var/log/a2billing_agi.log

Callback

Here is a little script to install the call-back Daemon. Change the LOAD_LOC variable to reflect where you have downloaded A2Billing.

Callback Daemon installation Script

 LOAD_LOC=/usr/local/src/a2billing
 yum -y install python-setuptools.noarch
 yum -y install MySQL-python
 easy_install sqlalchemy
 cd $LOAD_LOC/Callback/callback-daemon-py
 cp $LOAD_LOC/CallBack/callback-daemon-py/build/lib/callback_daemon/a2b-callback-daemon.rc /etc/init.d/a2b-callback-daemon
 chmod +x /etc/init.d/a2b-callback-daemon


 cd $LOAD_LOC/CallBack/callback-daemon-py/
 python setup.py build
 python setup.py bdist_egg
 easy_install dist/callback_daemon-1.0.prod_r1528-py2.4.egg
 chkconfig --add a2b-callback-daemon
 service a2b-callback-daemon start
 chkconfig a2b-callback-daemon on

Dialplan

The dialplan you put into Asterisk is the same as it was for A2Billing 1.3.4. I've not got round to writing the dialplan as yet.

 Reboot

Login

  http://Your-Switch/a2billing

Log into the admin pages with root and changepassword

General Setup

The general setup is similar to 1.3.4, and the order of events is approximately similar

  • Set up trunk * Set up callplan * Setup rate plan * add rate table to callplan * add rates * add customer * test.

Guidelines

Keep an eye on the development of A2Billing here.

 http://www.asterisk2billing.org/cgi-bin/trac.cgi/browser/trunk

Make sure that you are running the latest version before reporting a bug by periodically running.

Bugs can be dicussed in the bugs section here - http://forum.asterisk2billing.org/viewforum.php?f=22 before reporting them on the bug tracker.

Bugs tracking and reporting can be done here:- http://www.asterisk2billing.org/cgi-bin/trac.cgi/report

Afrimesh

Doesn't install at this moment (ubuntu only)

SPUD

1. Install dependencies

 yum install subversion

2. Get the code

 cd /var/www/html
 svn co http://dev.villagetelco.org/svn/villagetelco/spud/trunk spud

3. Database

a) Create a new database

 mysqladmin -u root -p create spud

b) Edit SPUD database settings

vi /var/www/html/spud/app/config/database.php

var $default = array( 'driver' => 'mysql', 'persistent' => false, 'host' => 'localhost', 'login' => 'root', 'password' => , 'database' => 'spud', 'prefix' => , );

c) Create database schema>

 cd /var/www/html/spud/app/install
 mysql -u root spud -p < spud_db_schema.sql

4. Change file permission

 cd /var/www/html/spud/app/
 chown -Rf www-data.www-data tmp/

5. Enable Apache rewrite module

 todo
 

6. Edit Apache2 000-default file

todo


               Options Indexes FollowSymLinks MultiViews
               AllowOverride All
       

Restart Apache

 /etc/init.d/httpd restart

7. Configure VIS server

a) Set the IP address/domain name of your webserver. Default value is 127.0.0.1

b) Set the IP addres of your VIS server. The default settings will point to the Bo Kaap VIS server.

c) Configure the vis mode. SPUD supports two VIS modes ('mode' => 'batman') and ('mode' => 'batman-adv') depending if you run your mesh protocol in L3 or L2

d) Configure the vis_version. If you run a L3 mesh network you need also to define the vis_version variable. The legacy value supports the broken JSON output of some old implementations. Recent L3 VIS servers should be set up as vis_version: trunk

 vi /var/www/html/spud/app/config/config.php
    $config['SPUD']= array(
              'host'     => '127.0.0.1'
              );
     
    $config['VIS']= array(                                                   
              'host'     => '41.223.35.110',
              'port'     => '2015',
              'timeout'  => '30'
  	       'vis_version' => 'legacy',

'mode' => 'batman',

              );
              

8. Add VIS update to cronjob

a) Open cronjob editor

 crontab -e

b) Add the follwing line

 */5 * * * * root /usr/bin/wget -O - -q -t 1 http://localhost/spud/nodes/update  >/dev/null 2>&1

9. Get started with SPUD

Navigate to SPUD:

 http://localhostname_or_ip/spud