Acer Revo M1-601: How to install Asterisk & Freepbx

acer-m1-601To begin you need to install Debian 8.1.

Critical step in the installation process.
Non-free firmware
When the installation process ask for “Some of you hardware needs non-free firmware  – the missing firmware files are rtl_nic/rtl8168g-2.fw”, you need to download from Debian Packaged web site package named firmware-realtek (see linkografia), uncompress it to an USB stick (using 7zip for example): after that you can insert USB key in your Acer and continue with installation process.

Disk Partition
My choice: Guided – use entire – all file in one partition

Software Selection
My choice: SSH server and standard system utilities

Root SSH Access
You need to permit root user to get via SSH in order to facilitate the configuration steps.

> sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config
> service sshd restart

Optimization for SSD
Enable Trim. Create a new file in  /etc/cron.daily/trim

fstrim -v /

Decrease swap utilization.

> echo -e "vm.swappiness=10" | sudo tee -a /etc/sysctl.conf

From here basically I’ll follow the tutorial “Installing FreePBX 13 on Debian 8.1” from FreePbx website (see in linkografia), with some additional notes.

Install dependencies

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

Att.: Do not set root mysql password: leave blank.

At the end my advice is to restart the server, and check logs to verify that all works fine.

Install Legacy pear requirements

> pear install Console_Getopt

Download Asterisk source files.

> cd /usr/src
> wget
> wget
> wget
> wget -O jansson.tar.gz
> wget

Compile and install pjproject
PJSIP is a library implementing SIP, SDP, RTP, STUN and other stuff.

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

Compile and Install jansson
Jansson is a library for encoding, decoding and manipulating JSON data.

> cd /usr/src
> tar vxfz jansson.tar.gz
> cd jansson-*
> autoreconf -i
> ./configure
> make
> make install

Compile and install Asterisk

> cd /usr/src
> tar xvfz asterisk-13-current.tar.gz
> cd asterisk-*
> contrib/scripts/
> contrib/scripts/install_prereq install
> make menuselect

In menu select if you want to have MP3 support (eg, for Music on Hold), you need to manually turn on ‘format_mp3’ on the first page: usually all the other options usually are correctly selected. After selecting ‘Save & Exit’ you can continue.

> make
> make install
> make config
> ldconfig
> update-rc.d -f asterisk remove

Install Asterisk Soundfiles

> cd /var/lib/asterisk/sounds
> wget
> wget
> tar xvf asterisk-core-sounds-en-wav-current.tar.gz
> tar xfz asterisk-extra-sounds-en-wav-current.tar.gz
> wget
> wget
> tar xfz asterisk-extra-sounds-en-g722-current.tar.gz
> tar xfz asterisk-core-sounds-en-g722-current.tar.gz

Install and Configure FreePBX

> useradd -m asterisk
> chown asterisk. /var/run/asterisk
> chown -R asterisk. /etc/asterisk
> chown -R asterisk. /var/{lib,log,spool}/asterisk
> chown -R asterisk. /usr/lib/asterisk
> rm -rf /var/www/html
> sed -i 's/\(^upload_max_filesize = \).*/\120M/' /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
> sed -i 's/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf
> a2enmod rewrite
> service apache2 restart

In /etc/php5/apache2/php.ini change memory_limit to 256M.

memory_limit = 256M

Add a new file /etc/odbcinst.ini

Description = ODBC for MySQL
Driver = /usr/lib/x86_64-linux-gnu/odbc/
Setup = /usr/lib/x86_64-linux-gnu/odbc/
FileUsage = 1

Add a new file /etc/odbc.ini

Description=MySQL connection to 'asteriskcdrdb' database

Install FreePbx

> cd /usr/src
> wget
> tar vxfz freepbx-13.0-latest.tgz
> cd freepbx
> ./start_asterisk start
> ./install -n
> fwconsole ma refreshsignatures 

Configure for automatic startup on boot
Add a new file /etc/systemd/system/freepbx.service

Description=FreePBX VoIP Server

ExecStart=/usr/sbin/fwconsole start
ExecStop=/usr/sbin/fwconsole stop


From console.

> systemctl enable freepbx.service

Debian Package: firmware-realtek
Installing FreePBX 13 on Debian 8.1