installingFreepbx

Revision 7 as of 2008-12-20 14:47:29

Clear message

Installing FreePBX and Asterisk on Ubuntu Server Intrepid

This install procedures where tested successfully in Hardy Heron and in Debian Lenny.

Preparing to install, things to do first

Install Intrepid server as usual. Mark LAMP when installing the services. This will add Apache, MySQL and PHP5. Log in the server and access the super user account by issuing

sudo su

If you want to be sure about MySQL and PHP do this

apt-get install php5-mysql libapache2-mod-php5 mysql-server

You may need to set up apache appropriately, at the least be sure php5 is enabled. In Intrepid Ibex this is not needed:

a2enmod php5

For the localization to work properly you may have to edit /etc/php5/apache2/php.ini and modify as follow (leny/sid):

; PHP's built-in default is text/html
default_mimetype = "text/html"
;default_charset = "ISO-8859-1"
default_charset = "utf8";

Adding the last line forces the default charset for php pages (override apache charset) to be utf8.

From http://www.freepbx.org/trac/wiki/UbuntuServer >I had the problem with others i18n php websites too and this modification works fine for all of them

other Php.ini settings you should change to make FreePBX happy.

; Magic quotes for incoming GET/POST/Cookie data.
magic_quotes_gpc = Off

;max_input_nesting_level = 64 ; Maximum input variable nesting level
memory_limit = 100M      ; Maximum amount of memory a script may consume (16MB)


Install Asterisk

apt-get install asterisk asterisk-mysql asterisk-mp3 php-db php5-gd php-pear sox curl

There is no reason to install zaptel if you are using kernel 2.6 or above as it will provide the timing device unless of course you are using zaptel hardware. Ztdummy is no longer necessary.

I am installing these also, sounds and prompts in spanish

apt-get install asterisk-prompt-es asterisk-sounds-extra 

There are two approaches to solve the permissions problem, one is to add the asterisk group to the user www-data default in apache.

1. Keep Apache running as www-data

adduser www-data asterisk

With this approach, FreePBX gives an error copying /usr/share/asterisk/bin/agi-bin. Change the owner doing this

chown www-data.asterisk -R /usr/share/asterisk

After installing FreePBX you will need to change the user in amportal.conf.

2. Change Apache to run as asterisk

The other one is to edit the /etc/apache2/envvars file and change apache's user to asterisk. I tested this one and it works.

#export APACHE_RUN_USER=www-data
#export APACHE_RUN_GROUP=www-data
export APACHE_RUN_USER=asterisk
export APACHE_RUN_GROUP=asterisk

If you switched from approach 1 to approach 2, you should delete the session files in /var/lib/php5 or change ownership to asterisk

Reload apache

apache2ctl graceful

To make the FOP server start, I changed the default shell for the user asterisk that was set to false:

usermod -s /bin/bash asterisk

In /usr/sbin/safe_asterisk I changed the variable BACKGROUND which is in 0 to 1


Installing FreePBX

Download freepbx from http://www.freepbx.org

cd /tmp
wget http://mirror.freepbx.org/freepbx-2.5.1.tar.gz
cd /usr/src
tar xvfz /tmp/freepbx-2.5.1.tar.gz
cd freepbx-2.5.1

Prepare database:

mysqladmin create asterisk
mysqladmin create asteriskcdrdb
mysql asterisk < SQL/newinstall.sql 
mysql asteriskcdrdb < SQL/cdr_mysql_table.sql

mysql

GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY 'amp109';
GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY 'amp109';
flush privileges;
quit

VERY IMPORTANT BEFORE INSTALLING FREEPBX Make a copy of /etc/asterisk/modules.conf. FreePBX rewrites the file and trashes Asterisk installation. If you restart Asterisk after installing FreePBX Asterisk dies with no message.

cp /etc/asterisk/modules.conf ~/asterisk-modules.conf

Start installation of freepbx:

./install_amp

This is the only thing you should change when installing FreePBX (and the IP address it asks with xx.xx.xx.xx, of course). FreePBX will default to /var/www/html.

AMPWEBROOT=/var/www/freepbx

Warning: If you have put FreePBX on a subdirectory, the panel will not work under the admin pages.

There are two approaches to make it work

1. Fix the error

  • Change the file /var/www/freepbx/admin/views/panel.php

// where it reads
//       '<iframe width="97%" height="600" frameborder="0" align="top" src="../../panel/index_amp.php?context='.$deptname.'"></iframe>'.
// you should erase one step back in the uri, as it shows here
         '<iframe width="97%" height="600" frameborder="0" align="top" src="../panel/index_amp.php?context='.$deptname.'"></iframe>'.

2. Create a virtual server and access your freepbx as http://freepbx

If you have access to the dns you can add a virtual server in Apache and avoid this last . Edit the file /etc/apache2/sites-available/freepbx and put this.

################# Named VirtualHosts
<VirtualHost *:80>

    ServerName freepbx
    ServerAlias freepbx

    ServerAdmin yourname@yourdomain.com
    ErrorLog /var/log/apache2/freepbx.error.log
    CustomLog /var/log/apache2/freepbx.access.log combined

    DocumentRoot /var/www/freepbx
    <Directory /var/www/freepbx>
        Options Indexes FollowSymLinks MultiViews
        Order allow,deny
        AllowOverride All
        Allow from all
    </Directory>

    <Directory /var/www/freepbx/admin>
        AuthType Basic
        AuthName "Restricted Area"
        AuthUserFile freepbx-passwd
        Require user admin
    </Directory>


</VirtualHost>

##################################################################

Make a symlink to make it available

ln -s /etc/apache2/sites-available/freepbx /etc/apache2/sites-enabled/099-freepbx

And add a password file with the password you want.

htpasswd -c /etc/apache2/freepbx-passwd admin

Restart Apache

/etc/init.d/apache2 restart

Restore the backup you've made of your modules.conf

cp ~/asterisk-modules.conf /etc/asterisk/modules.conf

If you have forgoten to make that backup, disable two libraries that are stopping asterisk to work. To disable a library you can add lines in /etc/asterisk/modules.conf. The autoload directive will load anything in the lib directory (/usr/lib/asterisk/modules) unless you put the line noload in the configuration file, before the global directive.

noload =>app_directory.so
noload =>res_adsi.so

In Ubuntu Hardy Heron, you should disable also

noload => app_voicemail_imap.so 
noload => app_voicemail_odbc.so

From http://www.voip-info.org/wiki/view/Asterisk+modules

If you kept Apache running as www-data add this lines at the end of /etc/amportal.conf

AMPASTERISKUSER=www-data
AMPASTERISKGROUP=asterisk

To make it start at the end of everything, edit the /etc/rc.local file before the line exit 0.

/usr/local/sbin/amportal start
exit 0

Asterisk will start on its own after package installation. If you want to run it under safe_asterisk and managed by amportal, remove asterisk from starting on its own

update-rc -f asterisk remove

Other References

http://www.freepbx.org/support/documentation/installation/install-process-for-ubuntu-6-06