FreePBX 2.8 Installation on Debian 5 (Lenny)
FreePBX is a GUI for managing a PBX based on Asterisk (and recently compatible also with FreeSwitch).
Is wrote in PHP and can use MySQL and PostgreSQL as the database engine.
Index
- Why
- What’s outside the scope
- Introduction
- Preparing the environment for Asterisk
- Download and unpack Asterisk
- Pre-building configuration
- Building
- Installation
- Installing sample configuration files
- Installing Asterisk Add-Ons
- Preparing Asterisk Manager
- Preparing user and group
- Editing PID path
- Edit permissions
- Install Environment
- Configuring PHP
- Configuring web server
- Download and unpack FreePBX
- Create database
- Populate database
- First execution of Asterisk
- Installing FreePBX
- First access to FreePBX
- Start FreePBX at boot
- What now ?
Why
Why install FreePBX on Debian when there are plenty of distributions which already include everything ?
For a number of reasons, for example because you are already using Debian or perhaps because you generally prefer it among others, being ‘stable by definition’ and fast to update.
Or also because you want to keep control over each single element of the system, resulting in a more easy debugging if some problem arises.
The purpose of this guide is to install vanilla FreePBX on vanilla Debian, in less time possible and in the simplest way.
What’s outside the scope
A number of subjects have been omitted for shortness.
For example:
- It is advised to create a MySQL user for FreePBX
- It is advised to use FreePBX GUI over HTTPS (SSL)
- It is advised to protect the FreePBX GUI with a password
- It is advised to sync the server’s clock with ntp
- It is not advised to use default password, never
- It is advised to have a firewall, an IDS and an IPS
- It is advised to configure logrotate to rotate Asterisk’s logs
- It is advised to configure a mail server to allow FreePBX (and the whole server) to send notifies and voicemail emails
- It is possible to use a number of solutions to monitor the server
- It is mandatory to install some drivers if using telephony hardware, for example Dahdi, mISDN, Wanpipe, …
- Much more, for example it is possible to integrate FreePBX with the vTiger CRM and bill the calls with A2Billing
Introduction
FreePBX is a complex application: it uses many libraries and their dependencies must be satisfied.
This guide will only deal with the SysAdmin aspect of the subject: it will be explained how to install FreePBX bot not how to use it.
This guide is based on Debian installed as minimal, that means using the netinst cd version and without installing any additional software selection (as in this picture).
This means that more packages are requested to be installed compared to a Debian with installed for example the web and the database software selections.
If starting from an already installed Debian, nothing changes: apt-get will simply notify that the package is already installed.
Instead, to install Debian from scratch, you can follow this guide: Debian 5 (lenny) Step-by-Step Installation with Screenshots or this: Debian 5 (lenny) Step-by-Step Installation with software RAID 1, with Screenshots.
Good, minimal Debian means that many packages which one may expect are missing.
Firstly I suggest to install Bash Completion, to improve to commands auto-completion.
Type:
apt-get install bash-completion
- If apt-get prints some 404 Not Found errors, update the internal database, with the command:
apt-get update
Also the OpenSSH must be manually installed, with the command:
apt-get install openssh-server.
It is now possible to remotely login to the server with a terminal (an ssh client).
Preparing the environment for Asterisk
We will now prepare the environment to build Asterisk.
- First install the dependencies, with the command:
apt-get install gcc g++ make libncurses5-dev
Download and unpack Asterisk
tar xzvf asterisk-1.4.x.x.tar.gz
a new folder will be created named “asterisk-1.4.x.x”
cd asterisk-1.4.x.x
Pre-building configuration
Stay in the “asterisk-1.4.x.x” folder, which holds the source code of Asterisk and run the script:
./configure
which will check the usability of the system libraries and create a ’Makefile’, based on your system.
The ’Makefile’ will later on be used by ’make’ to build Asterisk
If the ’configure’ script ran fine, you should read on the screen something like:
configure: OS type : linux-gnu
configure: Host CPU : i686
Building
Stay in the “asterisk-1.4.x.x” folder, which now holds also the ’Makefile’ and run make:
make
consider that on an 800MHz AMD Athlon CPU system, the building of Asterisk takes around 7 minutes
and less than 3 on an Athlon 4800+ CPU PC.
However, rebuilding Asterisk from the same source tree will take much less because only the files affected from changes to the ’Makefile’ with the ./configure script will be rebuilt.
If the building ran fine, you should read on the screen:
+——— Asterisk Build Complete ———
+ Asterisk has successfully been built, and
+ can be installed by running:
+
+ make install
+——————————————-
Installation
While staying in the “asterisk-1.4.x.x” folder, write the command:
make install
which will finally install Asterisk.
You should then read something like:
+—- Asterisk Installation Complete ——-+
…
…
…
Installing sample configuration files
To install the sample configuration files, required by FreePBX, while staying in the “asterisk-1.4.x.x” folder, type che command:
make samples
Installing Asterisk Add-Ons
FreePBX read the CDR from the database.
If using MySQL, as in this guide, the cdr_mysql add-on module for Asterisk must be installed.
- First install the dependencies, with the command:
apt-get install libmysqlclient15-dev - Download the latest version of the 1.4 series of the asterisk-addons, here or from the handy shortcut asterisk-addons-1.4-current.tar.gz
- Unpack the downloaded archive using tar, with the command:
tar xzvf asterisk-addons-1.4.x.x.tar.gz
a new folder will be created named “asterisk-addons-1.4.x.x” - Change the current working directory to that folder, with cd:
cd asterisk-addons-1.4.x.x - Run the pre-building configuration script, with the command:
./configure - Then build, with the command:
make - Proceed with the Installation, with the command:
make install - And then install the sample configuration files, with the command:
make samples
Preparing Asterisk Manager
To allow FreePBX to communicate with Asterisk, the Asterisk Manager must be enabled.
Edit the file /etc/asterisk/manager.conf with your favourite text editor
- Enable the manager, by editing the line 25 from:
enabled = no
to:
enabled = yes - Create a user, by appending at the end of the file the lines:
[aabbccAABBCC]
secret = ddeeffDDEEFF
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
where aabbccAABBCC is the username
and ddeeffDDEEFF is his password. If you choose your own username and password, take note of them.
Preparing user and group
Asterisk, FreePBX and the web environment must run as the same system user.
- Create the group asterisk, with the command:
addgroup asterisk - Create the user asterisk, with the command:
useradd -g asterisk -c "Asterisk PBX" -d /var/lib/asterisk asterisk
Editing PID path
Change the path of the file which stores the Asterisk’s Process ID
- Create the folder /var/run/asterisk, with the command:
mkdir -p /var/run/asterisk - Edit the file /etc/asterisk/asterisk.conf with your favourite text editor and change the line:
astrundir => /var/run
into:
astrundir => /var/run/asterisk - Change the permissions of the folder /var/run/asterisk, with the command:
chown asterisk.asterisk /var/run/asterisk
Edit permissions
Change the user and the group ownership of some folders to have them consistent with the new configuration
- Type the command:
chown -Rf asterisk.asterisk /var/log/asterisk
Install Environment
Install the LAMP environment and satisfy FreePBX dependencies
- Digitare il comando:
apt-get install apache2 libapache2-mod-php5 mysql-common mysql-server-5.0 mysql-client-5.0 php5-mysql php-pear php-db php5-gd
you will be asked to insert MySQL’s (the database) root password.
Choose one and take note of it.
Configuring PHP
Edit the PHP configuration so that some variables are not automatically created
- Edit the file /etc/php5/apache2/php.ini with your favourite text editor and change the line:
magic_quotes_gpc = On
into
magic_quotes_gpc = Off
Configuring web server
Edit the web server configuration to have it running as the same user and group as Asterisk
- Edit the file /etc/apache2/envvars with your favourite text editor and change the lines:
export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
into
export APACHE_RUN_USER=asterisk
export APACHE_RUN_GROUP=asterisk - Restart the web server, with the command:
/etc/init.d/apache2 restart
Download and unpack FreePBX
tar xzvf freepbx-2.x.x.tar.gz
a new folder will be created named “freepbx-2.x.x”
cd freepbx-2.x.x
Create database
It is now necessary to create two databases.
- Lunch the MySQL console, with the command:
mysql -p
the MySQL’s root password will be asked, type it and press enter. - Create the database which will hold the FreePBX configuration, with the command:
create database asterisk; - Create the database which will hold the CDR, with the command:
create database asteriskcdrdb; - Logout from the MySQL console, type:
exit
Populate database
While in the FreePBX’s source files folder “freepbx-2.x.x”
- Populate the database “asterisk”, with the command:
mysql -p asterisk < SQL/newinstall.sql
the MySQL’s root password will be asked, type it and press enter - Populate the database “asteriskcdrdb”, with the command:
mysql -p asteriskcdrdb < SQL/cdr_mysql_table.sql
the MySQL’s root password will be asked, type it and press enter
First execution of Asterisk
To install FreePBX it is first necessary to start Asterisk, to allow it to communicate throught the Asterisk Manager
- Open a new terminal and always being root write the command:
asterisk -U asterisk -G asterisk -vvvc
Asterisk will load its modules and its configuration, you should then read:
Asterisk Ready.
*CLI>
Installing FreePBX
While in the FreePBX’s source files folder “freepbx-2.x.x”
- Lunch the script to install FreePBX, with the command:
./install_amp
and answer:
Enter your USERNAME to connect to the ‘asterisk’ database: root
Enter your PASSWORD to connect to the ‘asterisk’ database: <type MySQL’s root password>
Enter the hostname of the ‘asterisk’ database: <press enter or type ‘localhost’>
Enter a USERNAME to connect to the Asterisk Manager interface: <type the created username of the Asterisk Manager, in this example ‘aabbccAABBCC’>
Enter a PASSWORD to connect to the Asterisk Manager interface: <type the password of the created username of the Asterisk Manager, in this example ‘ddeeffDDEEFF’>
Enter the path to use for your AMP web root: /var/www
Enter the IP ADDRESS or hostname used to access the AMP web-admin: <type the IP address of the server, usually the IP address inside the LAN>
Enter a PASSWORD to perform call transfers with the Flash Operator Panel: <confirm the default passw0rd by pressing enter>
Use simple Extensions [extensions] admin or separate Devices and Users [deviceanduser]? <specify if each extension will correspond to a user or if they will be dynamic. If not sure type extensions or press enter>
Enter directory in which to store AMP executable scripts: <confirm the default /var/lib/asterisk/bin by pressing enter>
Enter directory in which to store super-user scripts: <confirm the default /usr/local/sbin by pressing enter>
The FreePBX installation should now proceed to the end.
If it breaks printint the error Cannot redeclare __parse_dialrulesfile, repeat again the installation, with the command:
./install_amp
and this time the script should end successfully.
This is a known bug.
Also, you must delete a file, which will later be automatically symlinked by FreePBX. Type:
rm /etc/asterisk/sip_notify.conf
First access to FreePBX
Access FreePBX, using a web browser to the address:
http://<Server’s IP address>
Press FreePBX Administration and once inside FreePBX press the Apply Configuration Changes orange button at the center top of the page.
Start FreePBX at boot
I’ve published the script to have FreePBX start at Debian’s boot here
- Download the script, with the command:
wget http://asteriskipcop.berlios.de/fpfa/amportal - Make the script executable, with the command:
chmod +x amportal - Move the script, with the command:
mv amportal /etc/init.d/ - Make it run at boot, with the command:
ln -s /etc/init.d/amportal /etc/rc2.d/S99amportal - Reboot the system, with the command:
reboot
What now ?
Till here the installed system can manage VoIP technologies.
If you are a novice, I suggest to experiment with some softphones (or IP phones) and SIP carriers.
An excellent wiki is voip-info.org
while here you will find the FreePBX forums.
|
|
This guide is also available in Italian |
![]() |
|



October 1, 2010 at 10:13 pm
Congrats to make this procedure, it’s working fine to me.
BR,
Clistenes
October 7, 2010 at 1:40 pm
very good, thanks
November 17, 2010 at 8:33 pm
Thanks a million, it worked like a charm.
November 23, 2010 at 12:59 am
EXCELENTE TUTORIAL!!!!!!!!!!!!!!!!!!!!
February 11, 2011 at 6:49 am
Very nice
this is very clear and precise!!
February 18, 2011 at 5:59 am
So far the best help in this particular subject. For users like me just remember dependencies, follow instructions carefully, be patient… thanks, gracias
I did it after uninstalling previous non functioning installation and then following instructions == > instalar freepbx 2.8 en debian lenny fue posible