User Tools

Site Tools


voice:pbx:freepbx_scratch

This is an old revision of the document!


Build a PBX from Scratch Using CentOS, Asterisk and FreePBX

Minimal CentOS Install

Do a Minimal Install of Centos 6.

After the reboot:

yum update -y

then reboot again.

XenServer Tools

If installing on XenServer (skip otherwise):

  1. Mount the XenServer Tools virtual CD into the VM
  2. mount /dev/xvdd /mnt/
  3. /mnt/Linux/install.sh
  4. reboot

Install Prerequisites

yum -y groupinstall base core

yum -y install gcc gcc-c++ wget bison mysql-devel mysql-server php php-mysql php-pear php-pear-DB php-mbstring php-process 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

yum clean all

Firewall

Pick one of these three firewall options.

iptables

system-config-firewall-tui

The following ports need to be opened:

ProtocolPortsDescription
TCP80HTTP
TCP443HTTPS
TCP4445Flash Operator Panel
UDP5060-5061SIP
UDP10000-20000RTP
UDP4569IAX

Arno's Firewall

No Firewall

service iptables stop
chkconfig iptables off
service ip6tables stop
chkconfig ip6tables off

selinux

Disable selinux:

vim /etc/selinux/config
SELINUX=disabled
setenforce 0

Time Zone

http://www.php.net/manual/en/timezones.php

ln -sf /usr/share/zoneinfo/America/Phoenix /etc/localtime

PHP Settings

Time Zone

vim -c 946 /etc/php.ini

Uncomment and set PHP timezone:

date.timezone = America/Phoenix

Upload File Size

vim -c 878 /etc/php.ini

upload_max_filesize = 20M

Install PBX Software

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

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

make && make install && make samples

Create an 'asterisk' user. The user may already exist but this won't hurt:

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 of various folders:

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

Adjust the manager interface username and password:

vim /etc/asterisk/manager.conf

Add a stanza like:

[admin]
secret = your-manager-password
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

Music on Hold

Here we create a symbolic link so that both FreePBX and Asterisk will find and store MOH files in the same place:

ln -s /var/lib/asterisk/moh /var/lib/asterisk/mohmp3

Asterisk and FreePBX now only use .wav files for MOH so install mpg123 for converting uploaded mp3's to wav's:

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

ln -s /usr/local/bin/mpg123 /usr/bin/mpg123

Web Server

Here we set the web server to run as the 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 Configuration

Start MySQL

service mysqld start

Create Databases and Tables

cd /usr/src/freepbx-2.10.0                       # adjust version if necessary
mysqladmin create asterisk
mysqladmin create asteriskcdrdb
mysql asterisk < SQL/newinstall.sql
mysql asteriskcdrdb < SQL/cdr_mysql_table.sql

Configure MySQL Security

mysql

Run these MySQL commands and adjust for your own password:

GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY 'your-password';

GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY 'your-password';

flush privileges;

exit

Finally, we set the MySQL root password. Don't forget it!

mysqladmin -u root password 'your-mysql-root-password'

Install FreePBX

Get the latest released version.

cd /usr/src
wget http://mirror.freepbx.org/freepbx-2.10.0.tar.gz     # adjust version if necessary
tar zxvf freepbx-2.10.0.tar.gz

:!: MySQL should still be running…

Start asterisk. You can ignore warnings, errors, and notices for now:

/usr/sbin/safe_asterisk

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

You will be asked various questions which will be used to populate /etc/amportal.conf.

Use the defaults, mostly, but change:

VariableValue
AMPMGRUSERadmin
AMPMGRPASSpassword you set when editing manager.conf above
AMPDBPASSpassword you chose when configuring MySQL security above
AMPWEBADDRESSthe IP address of your PBX

Now we delete a few configuration files that may interfere with FreePBX:

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

MySQL CDR Configuration

vim /etc/asterisk/cdr_mysql.conf

loguniqueid=yes             # add to [Global] section which you may need to also un-comment

Services Startup

Enable Apache, MySQL and FreePBX to autostart on boot:

chkconfig httpd on
chkconfig mysqld on
echo /usr/local/sbin/amportal start >> /etc/rc.local

:!: Reboot now!

Using FreePBX

:!: Before using FreePBX, you have to visit the configuration page at: http://IP.of.PBX

:!: Click “Apply Configuration Changes”

:!: Reboot again

Defailt Credentials

FunctionUsernamePasswordComment
FreePBXadminadmin
Voicemail & Recordings (ARI)<none><none>Use the FreePBX admin console to enable

Configuration

The FreePBX administration console: http://IP.of.PBX

Enable ARI Administration

FreePBX → Settings → Advanced System Setup →

  • User Portal Admin Username → your-ari-admin-username
  • User Portal Admin Password → your-ari-admin-password

Save each change and click Apply Configuration.

Troubleshooting

FreePBX Post Install Tips

Asterisk Manager Interface

Verify that the username and password in /etc/asterisk/manager.conf and /etc/amportal.conf match.

http://www.freepbx.org/support/documentation/faq/changing-the-asterisk-manager-password

Pear DB

If you see an error during FreePBX installation like:

Checking for PEAR DB..FAILED

try:

pear install DB

then re-run:

./install_amp

Remote Extensions

:!: If you enable remote access to your PBX, secure it!

:!: NAT is a real hurdle for SIP. The best way to deal with NAT issues is to not use NAT, if possible. NAT on both ends may not be worth attempting.

IAX Protocol

:!: Using phones with IAX protocol support is a good alternative if the PBX is behind NAT.

:!: IAX protocol is pretty much Asterisk-specific.

If your PBX is behind NAT, forward the single UDP port 4569 from your NAT firewall in to the PBX.

SIP Protocol

http://www.freepbx.org/support/documentation/howtos/howto-setup-a-remote-sip-extension

If your PBX is behind NAT and you'd still like to try getting remote SIP extensions to work:

vim /etc/asterisk/sip_nat.conf

localnet=192.168.1.0/255.255.255.0      #your local network
externhost=your.fqdn.hostname           #your resolvable host name
fromdomain=your.fqdn.domain.name        #your domain mane
nat=yes
qualify=yes
externrefresh=10
canreinvite=no

asterisk -rx reload                     #reload Asterisk configuration

PHP Memory Limit

This should be the default:

vim -c 457 /etc/php.ini
memory_limit = 128M

Re-Install Just FreePBX

amportal stop

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

/usr/sbin/safe_asterisk

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

Visit the configuration page at: http://IP.of.PBX

Click “Apply Settings”

Reboot

voice/pbx/freepbx_scratch.1338762242.txt.gz · Last modified: 2012/06/03 16:24 by gcooper