How to install asterisk and freepbx [9.10]

Status
Not open for further replies.

Julian124

Cadet
Joined
Jun 17, 2016
Messages
1
Introduction
This is a how i installed asterisk 13 with freepbx 13 on a default jail on FreeNAS 9.10

Installation

Console in jail userland

Code:
pkg update
pkg upgrade
pkg install -y jpeg-turbo libslang2 asterisk13
pkg install -y asterisk13


Why ever but asterisk13 needs to be installed twice. jpeg-turbo and libslang2 needs to be installed before
otherwise there are weird conflicts and asterisk wasn't installable.

Code:
pkg install -y apache24 mysql56-server

pkg install -y sudo sox py27-fail2ban bash

pkg install -y php56 php56-pdo php56-pdo_mysql php56-mysql php56-simplexml \
            php56-zlib php56-xml pear php56-gettext php56-json mod_php56 \
            php56-posix  php56-ctype php56-gd php56-session gnupg php56-filter \
            php56-dom php56-xmlreader php56-hash php56-mbstring php56-curl


- Bash is needed for some freepbx scripts
- sudo is also needed by freepbx

Enabling services:
Code:
echo ' \
    mysql_enable="YES" \
    asterisk_enable="YES" \
    apache24_enable="YES" \
' > /etc/rc.conf


Configuring / Setting up apache / php for freepbx
Code:
echo 'export PATH=$PATH:/usr/local/bin:/usr/local/sbin:/usr/local/freepbx/bin:/usr/local/freepbx/sbin' > /usr/local/etc/apache24/envvars.d/path.env

echo '<FilesMatch "\.php$"> \
    SetHandler application/x-httpd-php \
</FilesMatch> \
<FilesMatch "\.phps$"> \
    SetHandler application/x-httpd-php-source \
</FilesMatch>' > /usr/local/etc/apache24/Includes/php.conf

sed -i '' 's/\(^upload_max_filesize = \).*/\120M/' /usr/local/etc/php.ini-production
sed -i '' 's/\(^memory_limit = \).*/\1256M/'  /usr/local/etc/php.ini-production

sed -i '' 's/^(User|Group).*/\1 asterisk/' /usr/local/etc/apache24/httpd.conf
sed -i '' 's/AllowOverride None/AllowOverride All/' /usr/local/etc/apache24/httpd.conf
sed -i '' 's/DirectoryIndex index.html/DirectoryIndex index.php index.html/' /usr/local/etc/apache24/httpd.conf
sed -i '' 's/\/usr\/local\/www\/apache24\/data/\/usr\/local\/www\/freepbx/' /usr/local/etc/apache24/httpd.conf


Setting up asterisk so that freepbx is able to install.
Code:
sed -i '' 's/\[directories\](\!)/[directories]/' /usr/local/etc/asterisk/asterisk.conf


Creating a home directory for the service user..
Yeah thats odd, but the user is used by freepbx and imports some gpg keys with that user.

Code:
mkdir /home/asterisk
chown asterisk:asterisk /home/asterisk
pw usermod asterisk -d /home/asterisk/ -m


Starting the first services:
Code:
service asterisk start
service mysql-server start


If you are like me, you will change the mysql default root pw
Code:
mysqladmin -u root password


Get the freepbx source and extract it
Code:
cd /root
curl -O http://mirror.freepbx.org/modules/packages/freepbx/freepbx-13.0-latest.tgz
tar xfz freepbx-13.0-latest.tgz
cd freepbx


Install freepbx.
I kept everything at the defaults besides the mysql root pw created.
Some error will occur at the very end of the installation script.
Code:
./install


Sometimes i saw that the asterisk user did not get all keys needed so heres a little script:
What you should see:
Code:
gpg --list-keys
pub   rsa4096/69D2EAD9 2014-05-05 [SC]
uid         [ unknown] FreePBX Mirror 1 (Module Signing - 2014/2015) <security@freepbx.org>
sub   rsa4096/CCEBF9CB 2014-05-05 [E]

pub   rsa4096/B33B4659 2014-04-30 [SC]
uid         [ unknown] FreePBX Module Signing (This is the master key to sign FreePBX Modules) <modules@freepbx.org>
sub   rsa4096/5C2FE148 2014-04-30 [E]


IF you miss one of them you could do:
Code:
gpg --recv-key 9F9169F4B33B4659
gpg --recv-key 86CE877469D2EAD9
gpg --export-key -a 9F9169F4B33B4659 > 9F9169F4B33B4659.key
gpg --export-key -a 86CE877469D2EAD9 > 86CE877469D2EAD9.key
sudo -u asterisk gpg --import 9F9169F4B33B4659.key
sudo -u asterisk gpg --import 86CE877469D2EAD9.key


There seems to be an issue with a with the rights of the created directory at
/usr/local/freepbx, thats why at the end of the install script a command might fail.
At least at my jail it did.
Heres the fix:
Code:
chmod 0755 /usr/local/freepbx


Now we need to reload the configuration, but before we do, we also need to fix a certificate location issue in freepbx. It defaults to /etc/asterisk/keys even if its empty so we change that.
Code:
/usr/local/freepbx/bin/fwconsole set CERTKEYLOC /usr/local/etc/asterisk/keys
/usr/local/freepbx/sbin/fwconsole reload


Now we start the apache and can go to the Server ip at port 80.
Code:
service apache24 start


Actually im working on hylafax maybe i'll add that later.

fail2ban asterisk security will be added here.
Code:
....fail2ban....
 
Last edited:

vafk

Contributor
Joined
Jun 22, 2017
Messages
132
I want to install Asterisk and Free PBX on FreeNAS-11.1-U5. Later I want tooperate several Cisco IP Phones 7945 with my SIP provider.
I followed the above instructions. I installed new jail and all the above steps.

During the installation I received en error No packages available to install matching 'pear' while installing the above pkg install -y pear

I did the following workaround:
enabled ports
pkg install wget
wget http://pear.php.net/go-pear.phar
php go-pear.phar

But I am not sure this is the same as in the above instructions o_O

Now I like to know how to modify Asterisk configuration files and how to access the web interface. I understand there should be a new directory at /etc/asterisk which is not the case. The result of search for new asterisk files/directories is attached.

How can I test that my installation fo far was successful and how to get further?
 

Attachments

  • Screenshot - 03_07.png
    Screenshot - 03_07.png
    8.3 KB · Views: 692
Status
Not open for further replies.
Top