Debian Wheezy + FreePBX 12 + Asterisk 13.1.0 How-To (mostly working with warnings)

Hello,

Here’s an attempt at writing a how-to on installing FreePBX 12 on Debian Wheezy with Asterisk 13.1. It currently works as is, but I would like to request the help of the community for a review and comments on a couple of errors I’m getting. This is mostly based on freepbx wiki articles on installing FreePBX 2.11 on wheezy and FreePBX 12 on Ubuntu 14.10. So here we go:

FreePBX 12 + Asterisk 13 on Debian Wheezy How-To

Install Debian Stable

  1. Use a netinst ISO
  2. Configure partitioning layout according to your needs
  3. Software Selection:
    Web server
    SSH server
    Standard system utilities

Configure network

Login as root and edit the following files according to your needs:

  1. /etc/network/interfaces:
auto eth0
        iface eth0 inet static
        address x.x.x.x
        netmask x.x.x.x
        broadcast x.x.x.x
        gateway x.x.x.x
  1. /etc/resolv.conf:
nameserver x.x.x.x

Then, execute:

/etc/init.d/networking stop
/etc/init.d/networking start

Upgrade your distro

Login as root and:

apt-get update && apt-get dist-upgrade -y

Install Dependencies

apt-get install sudo
apt-get install -y build-essential linux-headers-`uname -r` mysql-server mysql-client bison flex php5 php5-curl php5-cli php5-mysql php-pear php-db php5-gd curl sox libncurses5-dev libssl-dev libmysqlclient-dev mpg123 libxml2-dev libnewt-dev sqlite3 libsqlite3-dev pkg-config automake libtool autoconf git subversion unixodbc-dev uuid uuid-dev libasound2-dev libogg-dev libvorbis-dev libcurl4-openssl-dev libical-dev libneon27-dev libsrtp0-dev libspandsp-dev libiksemel-dev libiksemel-utils libiksemel3

During the installation of the previous package set you will be prompted for the mysql “root” user password. Choose a password and store it in a safe place. This password will be needed later when performing operations on the MySQL database.

apt-get install libmyodbc unixodbc

After installation has finished, restart the machine

reboot

Build and install Asterisk, jansson, pjsip

NOTE: installation of libpri and dahdi is not dealt with in this how-to, you might need these packages if you’re using PCI or USB telephony hardware.

Download sources:

cd /usr/src
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz
git clone https://github.com/akheron/jansson.git
wget http://www.pjsip.org/release/2.3/pjproject-2.3.tar.bz2

Build pjproject:

cd /usr/src
tar -xjvf pjproject-2.3.tar.bz2
cd /usr/src/pjproject-2.3
CFLAGS='-DPJ_HAS_IPV6=0' ./configure --prefix=/usr --enable-shared --disable-sound --disable-resample --disable-video --disable-opencore-amr
make dep
make
make install

Build jansson:

cd /usr/src/jansson/
autoreconf -i
./configure
make
make install

Build asterisk:

cd /usr/src
tar xvfz asterisk-13-current.tar.gz
rm -f asterisk-13-current.tar.gz
cd asterisk-*
./configure
contrib/scripts/get_mp3_source.sh
make menuselect

Consider enabling the following options in menuselect (along with anything else you might need):

  1. format_mp3
  2. res_config_mysql
  3. Sound Packages, including asterisk-extra-sounds

Save and Exit menuconfig. Asterisk sources are now configured. Continue with building:

make
make install
make config
ldconfig

Install and configure FreePBX

cd /usr/src
export VER_FREEPBX=12.0
git clone http://git.freepbx.org/scm/freepbx/framework.git freepbx
cd freepbx
git checkout release/${VER_FREEPBX}
adduser asterisk --disabled-password --gecos "Asterisk User"
chown asterisk. /var/run/asterisk
chown -R asterisk. /etc/asterisk
chown -R asterisk. /var/{lib,log,spool}/asterisk
chown -R asterisk. /usr/lib/asterisk
chown -R asterisk. /var/www/
sed -i 's/\(^upload_max_filesize = \).*/\1120M/' /etc/php5/apache2/php.ini
cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf_orig
sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/apache2/apache2.conf
/etc/init.d/apache2 restart

Prepare databases

Obviously you are to replace instances of “passwd” below with your password. You will be asked to provide the mysql “root” password you chose during the “Install Dependencies” section above when running mysqladmin or mysql commands in this section.

export ASTERISK_DB_PW='passwd'
mysqladmin -u root create asterisk -p
mysqladmin -u root create asteriskcdrdb -p
mysql -u root -e "GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY '${ASTERISK_DB_PW}';" -p
mysql -u root -e "GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY '${ASTERISK_DB_PW}';" -p
mysql -u root -e "flush privileges;" -p

Install FreePBX

First, make sure asterisk is running:

cd /usr/src/freepbx/
./start_asterisk start

Then run (replace x.x.x.x with your local IP address):

./install_amp --installdb --username=asteriskuser --password=${ASTERISK_DB_PW} --dbhost='127.0.0.1' --dbname='asterisk' --freepbxip='x.x.x.x' --cgibin='/var/www/cgi-bin' --bin='/var/lib/asterisk/bin' --sbin='/usr/local/sbin' --asteriskuser=admin --asteriskpass=${ASTERISK_DB_PW} --asteriskip='127.0.0.1' --scripted
./install_amp --update-links
amportal chown
amportal a ma installall
amportal a ma download manager
amportal a ma install manager
amportal a ma installall
amportal chown
amportal a ma refreshsignatures
amportal a reload
ln -s /var/lib/asterisk/moh /var/lib/asterisk/mohmp3
amportal restart

Configure Apache

Edit /etc/apache2/sites-enabled/000-default and replace all instances of:

/var/www

with

/var/www/html

I believe trailing slashes (/) are to be retained, if they exist in the original file, in the paths above.

Within the same file, locate the context (provided you made the changes above to the paths):

<Directory /var/www/html/>

Within that context, replace the following line:

AllowOverride None

with:

AllowOverride All

Lastly, restart apache:

/etc/init.d/apache2 restart

Make CDRs work

Edit and/or create the following files so that contain the text quoted here:

  1. /etc/odbc.ini
[MySQL-asteriskcdrdb]
    Description     = MySQL connection to 'asterisk' database
    Driver          = MySQL
    Database        = asteriskcdrdb
    Server          = localhost
    Port            = 3306
    Option          = 3
    Socket          =
  1. /etc/odbcinst.ini
[MySQL]
    Description     = MySQL driver
    Driver          = libmyodbc.so
    Setup           = libodbcmyS.so
  1. /etc/asterisk/cdr_adaptive_odbc.conf
[first]
    connection=asteriskcdrdb
    table=cdr
    alias start => calldate

And then run as root:

chown asterisk:asterisk /etc/asterisk/cdr_adaptive_odbc.conf
chmod 775 /etc/asterisk/cdr_adaptive_odbc.conf

Enjoy your FreePBX Installation on wheezy!

Issues I need help with

These are only the ones I have noticed. Any suggestions on why/how anything should be done differently are more than welcome.

Warnings produced by install_amp

Running the install_amp script produces the following warnings. I’m not sure if they’re safe to ignore:

Installing new FreePBX files..PHP Warning:  copy(/var/www/html/robots.txt): failed to open stream: No such file or directory in /usr/src/freepbx/libfreepbx.install.php on line 381
PHP Notice:  Undefined variable: db in /var/www/html/admin/libraries/cronmanager.class.php on line 92

The following is printed several times:

PHP Warning:  file_put_contents(/var/log/asterisk/freepbx.log): failed to open stream: Permission denied in /var/www/html/admin/libraries/utility.functions.php on line 111

Said file (/var/log/asterisk/freepbx.log) has the following permissions set after the script has finished running so this is weird:

-rwxrwxr-x  1 asterisk asterisk  4801 Jan 20 19:12 freepbx.log

And finally (not sure if this meant as an error):

no crontab for asterisk

installall does not satisfy all dependencies

Running amportal a ma installall the first time will pull in the cxpanel module, which depends on the manager module, which isn’t there yet:

Failed to install due to the following missing required module(s):<br /><br />manager<br /><br />Unable to install module cxpanel:

So I had to install manager manually (amportal a ma download manager && amportal a ma install manager), then run installall again to continue with the rest. Is this a bug?

framework module signature invalid after running installall

This doesn’t feel right. No files have been modified at this stage, and yet module signature checking somehow fails. Is this a bug? I’m running:

amportal a ma refreshsignatures

as one of the final steps to remedy this.

freepbx does not detect app_confbridge the first time

After logging on the web interface for the first time a warning about both app_confbridge and meetme missing is displayed. A restart seems to fix this.

Some asterisk config files are symlinks to /usr/src/freepbx/amp_conf, wrong permissions

After a reboot (to fix the app_confbridge error) and logging in, freepbx complains about indications.conf not being writeable.

Indeed /etc/asterisk/indications.conf is a symlink to /usr/src/freepbx/amp_conf/astetc/indications.conf

All files within /usr/src/freepbx/amp_conf/astetc/ are still owned by root. I’m assuming these files should have the same permissions as the rest in /etc/asterisk, so I ran:

chown asterisk:asterisk /usr/src/freepbx/amp_conf/astetc/*
chmod 775 /usr/src/freepbx/amp_conf/astetc/*

Which seems to fixes things for now

However, I’m not sure why it should be that these files are symlinked from the freepbx sources directory, instead of being copied over to /etc/asterisk or being symlinked from freepbx’s installation directory (after having been copied there during installation)…

2 Likes

It’s not a bug. You checked out from git which is recommended for developers only. Please start by using the release tarball: http://www.freepbx.org/download-freepbx