Install Procedure for Centos 4.3

Centos 4.3 Installation Walkthrough

CentOS 4.3 (CentOS) is the distribution used throughout this guide.
We believe that the goals of the distribution are in good alignment
with the mission-critical nature of a corporate telephone system.
CentOS ISOs can be downloaded from a number of mirror sites. Check the
official CentOS website for more information.

Detailing a Linux installation is beyond the scope of this
document. There are numerous articles, HOW-TOs and books available to
the individual that deal with this subject. Therefore, for the purposes
of this document it is assumed that the CentOS installation is that of
a Server system. Furthermore, for the purposes of this
document it is assumed that the partitioning of the hard disk drive was
done automatically by selecting Autopartition when prompted, and that no previous partitions existed on the drive prior to installation.

Important Installation Notice During the installation you will be prompted about Firewalls and Selinux. Both of these MUST BE DISABLED.
The Sections to disable are highlighted in red below. After clicking
next, you will be prompted if you are sure this is correct - Click on Proceed.

Package Group Selection
Whilst It is not recommended to use the X Window System on a
production freePBX server, it is possible. If you're only doing this
for a test, or experementation, feel free to install X and Gnome or
KDE. If you are planning on using this as a production system, please
avoid installing X unless it's absoloutely necessary.

freePBX has several requirements (which we will cover in a later
section) but at this point of the CentOS installation ensure that at
least the following package groups are selected

  • Web Server
  • Mail Server (Not selected by default)
  • MySQL Database (Not selected by default)
  • Development Tools (Not selected by default)

After you've done this, the machine will install CentOS, install,
and reboot. At this stage, you have a functioning Linux system!

Post-Install Configuration

After your machine reboots, you need to log in as 'root' - You were
prompted for the root password on installation. When you log in
successfully, you will have a prompt li

For performance and security reasons it is important to update the system immediately after install. CentOS uses yum (or up2date but that is not a recommended way of doing updates) for this purpose. In this document we will use yum:

[root@dhcp1 ~]# yum -y update

Setting up Update Process

Setting up repositories



Update: gnupg.i386 0:1.2.6-3 python.i386 0:2.3.4-14.2 sendmail.i386 0:8.13.1-3.RHEL4.3 tzdata.noarch 0:2006a-2.EL4


root[@dhcp1 ~]#

Additional Package Installation to Satisfy freePBX dependencies
You can check if a particular package is installed by doing either:

[root@dhcp1 ~]# yum info [package]


[root@dhcp1 ~]# rpm -qa | grep [package]

If the package is not installed, install it by using yum:

[root@dhcp1 ~]# yum install [package]

Full documentation on 'yum' is available by typing man yum.

The following packages need to be additionally installed with yum:

[root@dhcp1 ~]# yum install gcc
libxml2-devel libtiff-devel mysql-server php-gd php-mysql kernel-devel
kernel-smp-devel bison ncurses-devel audiofile-devel subversion
libogg-devel openssl-devel mysql-devel

lame is not available through a yum repository; but it can be obtained and installed from Dag Wieers' RPM repository:

[root@dhcp1 ~]# rpm -ivh

Satisfying freePBX's PERL module dependencies
freePBX, from version 2.1 does not have any specific perl
dependancies. There used to be a big list here, but we finally managed
to get rid of all of them!

Get the latest freePBX files
You may wish to check that the link specified here is actually the latest and greatest. Look at the files available on Source Forge and pick the latest one there.

[root@dhcp1 ~]# cd /usr/src

[root@dhcp1 src]# wget

[root@dhcp1s src]# tar zxf freepbx-2.1.1.tar.gz

A pause while the files are extracted...

[root@dhcp1 src]#

Getting all the required Asterisk and Zaptel files.

[root@dhcp1 ~]# cd /usr/src

[root@dhcp1 src]# svn co asterisk

..Lots of files...

[root@dhcp1 src]# svn co asterisk-addons

..Lots of files...

[root@dhcp1 src]# svn co asterisk-sounds

..Lots of files...

[root@dhcp1 src]# svn co zaptel

..Lots of files...

[root@dhcp1 src]# svn co libpri

..Lots of files...

Patch and Compile zaptel (and libpri)
If you plan on useing IAX or conferencing and _don't_ have any digium hardware skip this part and read this ztdummy install guide then continue on at "Compile Asterisk"

[root@dhcp1 src]# cd /usr/src/zaptel

[root@dhcp1 zaptel]# cp ztdummy.c ztdummy.c.orig

[root@dhcp1 zaptel]# sed -i "s/if 0/if 1/" ztdummy.c

[root@dhcp1 zaptel]# make

If you get an error that looks like this:

/usr/src/zaptel/zaptel.c:420: error: syntax error before "zone_lock"

/usr/src/zaptel/zaptel.c:420: warning: type defaults to `int' in declaration of `zone_lock'

/usr/src/zaptel/zaptel.c:420: error: incompatible types in initialization

..10 or so more lines..

it means that your CentOS header files have an error in them.

This is a known bug and is easily repaired by

[root@dhcp1 zaptel]# sed -i s/rw_lock/rwlock/ /usr/src/kernels/`uname -r`-`uname -m`/include/linux/spinlock.h

You can now retry the make command. After it's finished, you need to run make install and make config. If you will be using a Digium or Sangoma telephony card that supports T1/E1 signaling do this step as well:

[root@dhcp1 zaptel]# cd /usr/src/libpri

[root@dhcp1 libpri]# make install

Compile Asterisk
Now you get to compile the centre of the package - asterisk! This is relatively paineless:

[root@dhcp1 libpri]# cd /usr/src/asterisk

[root@dhcp1 asterisk]# mkdir /var/run/asterisk

[root@dhcp1 asterisk]# make install

[root@dhcp1 asterisk]# make config

Take a couple of minutes now and configure your zaptel
files, before continuing. If you think you'll want to have Asterisk and
freePBX itself handle faxing (rather than using a dedicated fax
device), you should read the Faxing page.

Create user and set permissions
Unfortunately, issues in Asterisk 1.2 require us
to run the web server process as the same user as asterisk. In this
situation, it's easier for us to run httpd as 'asterisk', rather than
asterisk as 'httpd', as there's far less configuration that needs to be

[root@dhcp1 ~l]# useradd -c "Asterisk PBX" -d /var/lib/asterisk asterisk

[root@dhcp1 ~]# chown asterisk /var/lib/php/session/

Using nano (or your favourite editor, but nano is fine), you need to change User apache and Group apache to User asterisk and Group asterisk.

[root@dhcp1 ~]# nano +227 /etc/httpd/conf/httpd.conf (Push Control-X to save when you've finished)

You also want to change AllowOverride None to AllowOverride All

[root@dhcp1 ~]# nano +311 /etc/httpd/conf/httpd.conf (Push Control-X to save when you've finished)

Set up MySQL
Before you can do anything to MySQL, you need to make sure it's running:

[root@dhcp1 ~]# /etc/init.d/mysqld start

Initializing MySQL database: [ OK ]

Starting MySQL: [ OK ]

[root@dhcp1 ~]#

Now, to configure the databases for freePBX:

[root@dhcp1 ~]# cd /usr/src/freepbx-2.1.1

[root@dhcp1 freepbx-2.1.1]# mysqladmin create asterisk

[root@dhcp1 freepbx-2.1.1]# mysqladmin create asteriskcdrdb

[root@dhcp1 freepbx-2.1.1]# mysql asterisk < SQL/newinstall.sql

[root@dhcp1 freepbx-2.1.1]# mysql asteriskcdrdb < SQL/cdr_mysql_table.sql

They also need to be secured, so that not just anyone can access
them. freePBX will prompt you for a database 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 Asterisk@Home builds. If anyone's trying
to attack your machine, they will try this.

[root@dhcp1 freepbx-2.1.1]# mysql

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 8 to server version: 4.1.16

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

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


[root@dhcp1 freepbx-2.0.1]

Now, after all of this, you need to pick a root 'mysql' password.
For this, we'll pretend it's 's33kret'. If you need to do anything else
with mysql, you'll need to provide this password.

[root@dhcp1 freepbx-2.1.1]# mysqladmin -u root password 's33kret'

Build the cdr_mysql module for Asterisk (Yep, more compiling!)

[root@dhcp1 freepbx-2.1.1]# cd /usr/src/asterisk-addons

[root@dhcp1 freepbx-2.1.1]# cp Makefile Makefile.orig

[root@dhcp1 freepbx-2.1.1]# sed -i 's/SOURCE/SOURCE -DMYSQL_LOGUNIQUEID/' Makefile

[root@dhcp1 freepbx-2.1.1]# make && make install

Install freePBX at last!
You're there - you've done the hard yards, and finally you can install freePBX!

WARNING! If you have an existing Asterisk installation, the script below will overwrite your Asterisk configuration files. Backup your

/etc/asterisk directory before running.

$cd /usr/src/freepbx-2.1-beta1


Checking for PEAR DB..OK

Checking for PEAR Console::Getopt..OK

Checking for libasteriskperl (perl bindings for asterisk)...Checking user..OK

Checking for /etc/amportal.conf../etc/amportal.conf does not exist, copying default

Creating new /etc/amportal.conf

Enter your USERNAME to connect to the 'asterisk' database: [asteriskuser]

Enter your PASSWORD to connect to the 'asterisk' database: [amp109]

Enter the hostname of the 'asterisk' database: [localhost]

Enter a USERNAME to connect to the Asterisk Manager interface: [admin]

Enter a PASSWORD to connect to the Asterisk Manager interface:[amp111]

Enter the path to use for your AMP web root:[/var/www/html]

Enter the path to use for your FOP web root:[/var/www/html/panel]

Created /var/www/html/panel

Enter the path to your Apache cgi-bin:[/var/www/cgi-bin]

Enter the IP ADDRESS or hostname used to access the AMP web-admin:[xx.xx.xx.xx] The IP Address of your Asterisk Machine

Enter a PASSWORD to perform call transfers with the Flash Operator Panel: [passw0rd]

Use simple Extensions [extensions] admin or separate Devices and Users [deviceanduser]? extensions

Enter directory in which to store AMP executable scripts: [/var/lib/asterisk/bin]

Created /var/lib/asterisk/bin

Enter directory in which to store super-user scripts: [/usr/sbin]

/etc/amportal.conf writtenOK

Reading /etc/amportal.conf..OK

Checking for /etc/asterisk/asterisk.conf../etc/asterisk/asterisk.conf does not exist, copying default


Reading /etc/asterisk/asterisk.conf..OK

Connecting to database..OK

Checking current version of AMP..1.10.010beta1

Installing new AMP files..OK

Configuring install for your environment..OK

Setting permissions on files..OK

Checking for upgrades..5 found

Upgrading to 1.10.010..

Upgrading to 1.10.010..OK

Upgrading to 2.0beta1..

-> Running PHP script /usr/src/freepbx-2.0-beta4/upgrades/2.0beta1/emergencycid.php

-> Running SQL script /usr/src/freepbx-2.0-beta4/upgrades/2.0beta1/tables.sql

PHP Notice: Undefined variable: data in /usr/src/freepbx-2.0-beta4/install_amp on line 305

Upgrading to 2.0beta1..OK

Upgrading to 2.0beta2..

Upgrading to 2.0beta2..OK

Upgrading to 2.0beta3..

-> Running PHP script /usr/src/freepbx-2.0-beta4/upgrades/2.0beta3/fixgotovm.php

Updating existing voicemail destinations..


Upgrading to 2.0beta3..OK

Upgrading to 2.0beta4..

Upgrading to 2.0beta4..OK

Generating AMP configs..

Generating Configurations.conf..

Checking for PEAR DB..OK

Checking for PEAR Console::Getopt..OK

Checking for /etc/amportal.conf..OK

Reading /etc/amportal.conf..OK

Connecting to database..OK

Please Reload Asterisk by visiting http://XXX.XXX.XXX.XX/admin

Generating AMP configs..OK

Restarting Flash Operator Panel..-bash: /var/www/html/admin/ Permission denied


Please Reload Asterisk by visiting http://XXX.XXX.XXX.XX/admin

If you get any warnings or errors in the last part of the output,
they're usually not traumatic, but please use the IRC Support tool to
report a bug to the developers.

amportal control script

Starting with version 1.10.004, freePBX provided a new control
script. The functionality of which is to start, stop or kill services
in the freePBX environment, or to set permissions on directories/files
in the freePBX environment:


----------AMP Control Script-----------

Usage: amportal start|stop|kill|chown

start: Starts Asterisk and Flash Operator Panel server

stop: Gracefully stops Asterisk and the FOP server

restart: Stop and Starts

kill: Kills Asterisk and the FOP server

chown: Sets appropriate permissions on files

The amportal script is the recommended way to stop and start asterisk:

$ /usr/sbin/amportal stop

$ /usr/sbin/amportal start

19.Automatic start-up

echo /usr/sbin/amportal start >> /etc/rc.local

Ensure services are starting at boot time and reboot

In order to access and use freePBX we will want both Apache (httpd)
and MySQL (mysqld) to be started at boot. You can check to see if they
are setup to start at boot by using chkconfig:

[root@dhcp1 freepbx-2.1.1]# chkconfig --list httpd

httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off

[root@dhcp1 freepbx-2.1.1]# chkconfig --list mysqld

mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off

Here we see that both httpd and mysqld have off
across the board (runlevels). chkconfig can also be used to turn on a
particular service, which you would want to do in this case.

^[root@dhcp1 freepbx-2.1.1]# chkconfig httpd on

[root@dhcp1 freepbx-2.1.1]# chkconfig mysqld on

You can now access freePBX with your web browser.

The first time you click on the FreePBX Administration link you
will be prompted for a username and password. Use admin and admin.