System auf den neusten Stand bringen:

apt-get update
apt-get upgrade

Abhängigkeiten installieren:

apt-get install -y build-essential linux-headers-`uname -r` openssh-server apache2 wget net-tools mariadb-server mariadb-client bison flex php-pear curl sox libncurses5-dev libssl-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 libsrtp2-dev libspandsp-dev sudo subversion libmariadbclient-dev unixodbc

PHP 5.6 installieren:

apt-get install -y apt-transport-https lsb-release ca-certificates
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
apt-get update
apt-get install -y php5.6 php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-xml php5.6-mbstring

PHP 5.6 aktivieren:

update-alternatives --config php

System neustarten:

reboot

Legacy pear Abhängigkeiten installieren:

pear install Console_Getopt

Download der aktuellen Certified Asterisk Version:

wget http://downloads.asterisk.org/pub/telephony/certified-asterisk/asterisk-certified-13.21-latest.tar.gz

Asterisk-Sourcen entpacken:

tar xfvz asterisk-certified-13.21-latest.tar.gz

Asterisk-Sourcen entpacken und Abhängigkeiten installieren:

cd asterisk-certified-13.21-cert3
contrib/scripts/get_mp3_source.sh
contrib/scripts/install_prereq install

Asterisk-Module auswählen:

./configure --with-pjproject-bundled
make menuselect

Module Auswählen:

addons/format_mp3
addons/res_config_mysql
applications/app_chanisavail
applications/app_minivm
cdr/cdr_csv
cdr/cdr_odbc
channel drivers/chan_sip
ressource modules/res_hep
ressource modules/res_hep_pjsip
ressource modules/res_hep_rtcp
ressource modules/res_pjsip_history
core sounds/core-sounds-en-alaw
moh/alaw
extra sound packages/extra-sounds-en-alaw

Asterisk compilieren und installieren:

make
make install
make samples
make config
ldconfig

Benutzer und Rechte für Asterisk setzen:

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

Apache2-User bearbeiten:

Runuser und Rungroup auf ‚asterisk‘

nano /etc/apache2/envvars
service asterisk stop
service asterisk start

Asterisk-Konfigurieren:

nano /etc/asterisk/asterisk.conf 

[directories]
...
runuser = asterisk        ; The user to run as.
rungroup = asterisk        ; The group to run as.
...

Einige Einstellungen für das Webinterface setzen:

sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php/5.6/apache2/php.ini
cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf_orig
sed -i 's/AllowOverride None/AllowOverride All/' /etc/apache2/apache2.conf

a2enmod rewrite
service apache2 restart

NodeJs installieren:

curl -sL https://deb.nodesource.com/setup_12.x | bash -
apt-get install -y nodejs

ODBC Treiber installieren:

cd /root
wget https://downloads.mariadb.com/Connectors/odbc/connector-odbc-2.0.18/mariadb-connector-odbc-2.0.18-ga-debian-x86_64.tar.gz
tar xfvz mariadb-connector-odbc-2.0.18-ga-debian-x86_64.tar.gz
cp -R lib/ /usr
cp -R share/ /usr

ODBC Konfiguration setzen:

cat >> /etc/odbcinst.ini << EOF
[MySQL]
Description = ODBC for MySQL
Driver = /usr/lib/libmaodbc.so
Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so
FileUsage = 1

EOF
cat >> /etc/odbc.ini << EOF
[MySQL-asteriskcdrdb]
Description=MySQL connection to 'asteriskcdrdb' database
driver=MySQL
server=localhost
database=asteriskcdrdb
Port=3306
Socket=/var/run/mysqld/mysqld.sock
option=3

EOF

FreePBX herunterladen und entpacken:

cd /usr/src
wget http://mirror.freepbx.org/modules/packages/freepbx/freepbx-14.0-latest.tgz
tar vxfz freepbx-14.0-latest.tgz
rm -f freepbx-14.0-latest.tgz
cd freepbx

Modifikation des FreePBX installers:

nano /usr/src/freepbx/installlib/installcommand.class.php

// Parse Asterisk version.
//if (preg_match('/^Asterisk (?:SVN-|GIT-)?(?:branch-)?(\d+(.\d+))(-?(.)) built/', $astver, $matches)) {
  $determined = true;
  if (version_compare($matches[1], "11", "lt") || version_compare($matches[1], "17", "ge")) {
    $output->writeln("Error!
");
    $output->writeln("Unsupported Version of ". $matches[1]."
");
    $output->writeln("Supported Asterisk versions: 11, 12, 13, 14, 15
");
    //exit(1);
    $astver="13";
  }
  $output->writeln("Yes. Determined Asterisk version to be: ".$matches[1]);
  break;
}

FreePBX installieren:

service asterisk stop
./start_asterisk start
./install -n

Updaten aller Module:

fwconsole ma updateall

Aufräumen:

cd /root
rm asterisk-certified-13.21-latest.tar.gz
rm mariadb-connector-odbc-2.0.18-ga-debian-x86_64.tar.gz
rm -R lib/
rm -R share/
rm -R asterisk-certified-13.21-cert3