FreePBX-12 & Asterisk-12 on Alarm

This forum is for discussion about general software issues.

FreePBX-12 & Asterisk-12 on Alarm

Postby calzon65 » Mon Jul 07, 2014 3:10 am

I have always loved the marriage of Alarm and Asterisk. For a small amount of money, someone can build a nice PBX "appliance".

The current Asterisk AUR PKGBUILD is up-to-date for the latest version of Asterisk (Asterisk-12), but the FreePBX AUR PKGBUILD is way out of date. It didn't matter too much for over half a year because FreePBX was not even compatible with Asterisk-12. But just like Asterisk-12 is a significant advancement for Asterisk, FreePBX is also going through a major overhaul and just a few weeks ago released (beta) their long anticipated version FreePBX-12 that is compatible with Asterisk-12.

Yes there has been a "port" of Asterisk/FreePBX onto the Raspberry Pi and BeagleBone Black running Ubuntu/Debian (it’s an older version of Asterisk and FreePBX), and if you want to install it, it’s a so-called “moron proof” installation as a full system image versus a package installation. I prefer a package installation approach. I do have one of my BeagleBone Black's running a trimmed down Debian installation with Asterisk/FreePBX that I configured myself and it works fine. But my heart is with Arch and I would love to see an ArchLinux ARM version of FreePBX to go with our Asterisk package, maybe we can even be the first to have an Asterisk-12 / FreePBX-12 packaged version running on ARM.

The FreePBX installation instructions are quite clear for Ubuntu, Debian and CentOS, but as there are some differences with Arch, the work centers around knowing how to adjust for the “Arch way”. I've been working on a rough installation script making adjustments for the differences between Ubuntu/Debian and Arch, which impact FreePBX's installation. I have most of the dependencies complete and commands that initialize MySQL (MariaDB) and PHP. My goal is to ultimately update the AUR so we have both a solid Asterisk and FreePBX solution.

Below are my current notes, I know it might look like a script but don't use it like a script. I copy/past commands into a flat file until I have it working. Afterwards I plan to transfer to a PKGBUILD configuration/format. I am at the point now where I am editing the FreePBX install scripts (separate files from my "notes" file), changing paths like /var/www/html to /srv/http and stuff like that.

$this->bbcode_second_pass_code('', '# The instllation of Asterisk first (pacman) actually takes care of some of the
# dependencies and creating certain users/groups

export VER_FREEPBX=12.0
export ASTERISK_DB_PW=amp109

pacman -Sy git apache mariadb php php-apache php-gd php-pear
systemctl enable mysqld.service
systemctl start mysqld.service
systemctl enable httpd.service
systemctl start httpd.service
pear install db

cd /usr/src
git clone http://git.freepbx.org/scm/freepbx/framework.git freepbx
cd freepbx
git checkout release/${VER_FREEPBX}

cp /etc/php/php.ini /etc/php/php.ini_orig
sed -i 's/;extension=mysql.so/extension=mysql.so/' /etc/php/php.ini
sed -i 's/;extension=posix.so/extension=posix.so/' /etc/php/php.ini
sed -i 's/open_basedir =/; open_basedir =/' /etc/php/php.ini
sed -i 's/\(^upload_max_filesize = \).*/\120M/' /etc/php/php.ini

cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf_orig
sed -i 's/^\(User\|Group\).*/\1 asterisk/' /etc/httpd/conf/httpd.conf

systemctl restart httpd.service

mysqladmin -u root create asterisk
mysqladmin -u root create asteriskcdrdb

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

# ./start_asterisk start
# ./install_amp --installdb --username=asteriskuser --password=${ASTERISK_DB_PW}
# amportal a ma installall
# amportal a reload
# amportal chown')

Anyway, I wondered if anyone had any experience with FreePBX on Alarm and if they were interesting in collaborating / sharing notes on the subject. If you might be wondering what is the point of doing this given the fact that there are solid working versions for Debian/Ubuntu/CentOS ... well for me this is one of those "I'm doing it to see if I can do it" projects.
calzon65
 
Posts: 80
Joined: Wed May 25, 2011 9:06 pm

Re: FreePBX-12 & Asterisk-12 on Alarm

Postby WarheadsSE » Mon Jul 07, 2014 1:36 pm

Perhaps update the AUR PKGBUILD for FreePBX ?
Core Developer
Remember: Arch Linux ARM is entirely community donation supported!
WarheadsSE
Developer
 
Posts: 6807
Joined: Mon Oct 18, 2010 2:12 pm

Re: FreePBX-12 & Asterisk-12 on Alarm

Postby calzon65 » Mon Jul 07, 2014 3:16 pm

Thank you for the reply. Yes that is my ultimate goal, to update the AUR PKGBUILD for FreePBX and I hope to team up with someone to adopt that orphaned project. I would love to see our AUR for FreePBX be as updated as the AUR for Asterisk.

So far I have updated all the prerequisite checks and adjustments scripts (e.g., sed adjustments) and I believe most of the dependencies are fixed too, but now I need to make adjustments to the actual FreePBX installation scripts because of the differences between Arch and Debian/Ubuntu. I've already started to do that, updating for the different directory structure (e.g., different Apache folder, different php folders, etc.).

I have as a baseline that I successfully downloaded/compiled/configured from scratch Asterisk & FreePBX on Debian ARM for one of my BeagleBones, and I did not use the image from the FreePBX project on Raspberry Pi/BBB. I am basically going through the same installation steps on Alarm that I did with Debian, but I periodically to run into roadblocks because of the differences between Arch and Debian/Ubuntu. Usually I figure it with enough brute force, so I was hoping to collaborate with someone who may have successfully installed FreePBX on Arch or someone who just has interest in seeing the FreePBX PKGBUILD resurrected and would like to work together.
calzon65
 
Posts: 80
Joined: Wed May 25, 2011 9:06 pm

Re: FreePBX-12 & Asterisk-12 on Alarm

Postby calzon65 » Fri Jul 18, 2014 10:54 pm

I have been working on a script to download and configure FreePBX-12 and Asterisk-12. At the time of this post, FreePBX-12 is still beta but I have it working with Asterisk-12 on a BeagleBone Black. The FreePBX PKGBUILD in the AUR seems to have been abandoned a long time ago, eventually I wish to repair the AUR, but in the meantime, I have to complete a working installation script which I am sharing below.

You will notice there are several changes necessary to configure FreePBX compared to Debian or Ubuntu because of the differences between Arch and those releases. Also, there is a compiled package for asterisk (pacman -Sy asterisk) in the ARM package database, it is based on Asterisk-12, which is the current Standard Release, not the LTR (Long Term Release) which is Asterisk-11.

At the end of my script I have some commands commented out, you may want to uncomment them to run the script or run them manually, they complete the FreePBX installation.

Of particular interest you may notice my script uses the command start_asterisk start to start Asterisk. This script is of the "init" style to startup Asterisk and comes bundled with FreePBX (/usr/src/FreePBX/start_asterisk). During some of the installation process, FreePBX will complain of missing crontabs since FreePBX has not yet caught up with systemd. When you install Asterisk as a package from the ARM package database, it already comes with a systemd script called asterisk.service. If you enable this systemd (e.g., systemctl enable asterisk.service) it will start asterisk each time you boot, but with FreePBX they intended people to use start_asterisk start. So you may wish to have a look at the actual startup line in start_asterisk to determine how you wish to start Asterisk.

Be Advised! This script makes changes to MariaDB, Apache and other modules that are required for FreePBX. It is your responsibility to read the script below to determine if these changes are going to screw up your existing configuration. Installing FreePBX-12 and Asterisk-12 is generally thought of as an "appliance" installation, meaning, the system is dedicated to FreePBX and Asterisk. If you know what you are doing, this is certainly not the case; I run FreePBX/Asterisk with plenty of other applications (Samba, FTP, TFTP, multiple Apache websites, etc.) all on the same system without incident.

Feedback is certainly welcome.

$this->bbcode_second_pass_code('', '# WARNING: This script is under development ... use for reference only!
#
# Version 0.3 - July 11, 2014
# This installation script downloads/installs/configures Asterisk-12 and FreePBX-12
# for ArchLinux ARM. It has not yet been tested on ArchLinux, but there are no
# indications why it would not work on ArchLinux.

# Known Issues:
# - FreePBX still complaining about fail2ban even though it's installed and running
# - ./install_amp still throwning (sed: -e expression #1, char 1: unknown command: `"') error, will eventually dig into this.
# - Running ./install_amp still issues PHP Warning even with /var/log/asterisk permissions set to 777
# PHP Warning: file_put_contents(/var/log/asterisk/freepbx.log): failed to open stream: Permission denied in /srv/http/freepbx/admin/libraries/utility.functions.php on line 111

# Set variables per FreePBX notes
VER_FREEPBX=12.0
ASTERISK_DB_PW=amp109
PHPINI=/etc/php/php.ini
APACHECONF=/etc/httpd/conf/httpd.conf

# Install Asterisk, MySQL (aka MariaDB), Apache, PHP and associated dependencies
pacman -Sy asterisk mariadb apache php php-apache php-gd php-pear git fail2ban

# Enable/start MySQL
echo "Enable/Start MySQL"
systemctl enable mysqld.service
systemctl start mysqld.service

# Enable/start Apache
echo "Enable/Start Apache"
systemctl enable httpd.service
systemctl start httpd.service

# Enable/start Fail2Ban
echo "Enable/Start Fail2Ban"
systemctl enable fail2ban.service
systemctl start fail2ban.service

# Setup pear db
echo "Enable Pear DB"
pear install db

# Move to /usr/src then download/extract the FreePBX files
echo "Download/Extract FreePBX"
cd /usr/src
git clone http://git.freepbx.org/scm/freepbx/framework.git freepbx
cd freepbx
git checkout release/${VER_FREEPBX}

# Changes to PHP
echo "Adjusting PHP"
cp ${PHPINI} ${PHPINI}_orig
# Activate mysql.so
sed -i 's/;extension=mysql.so/extension=mysql.so/' $PHPINI
# Activate posix.so
sed -i 's/;extension=posix.so/extension=posix.so/' $PHPINI
# Deactivate open_basedir
sed -i 's/open_basedir =/; open_basedir =/' $PHPINI
# Increase upload_max_filesize
sed -i 's/\(^upload_max_filesize = \).*/\120M/' $PHPINI
# Activate pro_mysel.so (thanks tm1000)
sed -i 's/;extension=pdo_mysql.so/extension=pdo_mysql.so/' $PHPINI
# Set session.save_path to /usr/include/php/ext/session/
sed -i '/session.save_path/asession.save_path=\"\/usr\/include\/php\/ext\/session\"' $PHPINI

# Changes to Apache
echo "Adjusting Apache"
cp ${APACHECONF} ${APACHECONF}_orig
# Set User & Group to asterisk
sed -i 's/^\(User\|Group\).*/\1 asterisk/' $APACHECONF
# Change to mod_mpm_preform.so allowing libphp5.so to work preventing "threaded MPM" error
sed -i 's/LoadModule mpm_event_module modules\/mod_mpm_event.so/LoadModule mpm_prefork_module modules\/mod_mpm_prefork.so/' $APACHECONF
# Add LoadModule for libphp5.so after "LoadModule dir_module modules/mod_dir.so"
sed -i '/LoadModule dir_module modules\/mod_dir.so/aLoadModule php5_module modules\/libphp5.so' $APACHECONF
# Add Include php5_module.conf at end of Includes
sed -i '/Include conf\/extra\/httpd-default.conf/aInclude conf\/extra\/php5_module.conf' $APACHECONF
# Enable .htaccess (hypertext access)
echo " " >> $APACHECONF
echo "# HTAccess for FreePBX" >> $APACHECONF
echo "<Directory \"/srv/http/freepbx\">" >> $APACHECONF
echo "AllowOverride all" >> $APACHECONF
echo "</Directory>" >> $APACHECONF

# Changes to install_amp - change webroot directory from /var/www/html to /srv/http/freepbx
# Leaving this here for now, but I am generally against making any changes to any FreePBX scripts
cp install_amp install_amp_orig
sed -i 's/\/var\/www\/html/\/srv\/http\/freepbx/' install_amp

# Change permissions on /var/log/asterisk
# Still not sure if this command is needed, but leaving it here for now
chmod 777 /var/log/asterisk

# Restart Apache
echo "Restart Apache"
systemctl restart httpd.service

# Create MySQL (MariaDB) databases
echo "Configure MySQL Database"
mysqladmin -u root create asterisk
mysqladmin -u root create asteriskcdrdb

# Set privileges on database
echo "Set Privileges on Database"
mysql -u root -e "GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY '${ASTERISK_DB_PW}';"
mysql -u root -e "GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY '${ASTERISK_DB_PW}';"
mysql -u root -e "flush privileges;"

# Subsiquent commands to be run to finalize intallation
# ./start_asterisk start
# ./install_amp --installdb --username=asteriskuser --password=${ASTERISK_DB_PW}
# amportal a ma installall
# amportal a reload
# amportal chown')
calzon65
 
Posts: 80
Joined: Wed May 25, 2011 9:06 pm

Re: FreePBX-12 & Asterisk-12 on Alarm

Postby calzon65 » Mon Jul 21, 2014 10:12 pm

This is my most recent FreePBX-12 (plus Asterisk-12) to ArchLinux ARM installation script. I have added additional PHP dependencies and additional sed scripts to enable more PHP extensions. It is still a work in progress.

$this->bbcode_second_pass_code('', '# WARNING: This script is under development ... use for reference only!
#
# Version 0.4 - July 20, 2014
# This installation script downloads/installs/configures Asterisk-12 and FreePBX-12
# for ArchLinux ARM. It has not yet been tested on ArchLinux, but there are no
# indications why it would not work on ArchLinux.

# Known Issues:
# - FreePBX still complaining about fail2ban even though it's installed and running
# - ./install_amp still throwning (sed: -e expression #1, char 1: unknown command: `"') error, will eventually dig into this.
# - Running ./install_amp still issues PHP Warning even with /var/log/asterisk permissions set to 777
# PHP Warning: file_put_contents(/var/log/asterisk/freepbx.log): failed to open stream: Permission denied in /srv/http/freepbx/admin/libraries/utility.functions.php on line 111

# Set variables per FreePBX notes
VER_FREEPBX=12.0
ASTERISK_DB_PW=amp109
PHPINI=/etc/php/php.ini
APACHECONF=/etc/httpd/conf/httpd.conf

# Install Asterisk, MySQL (aka MariaDB), Apache, PHP and associated dependencies
pacman -Sy asterisk mariadb apache php php-apache php-gd php-pear php-ldap php-sqlite php-xsl git fail2ban

# Enable/start MySQL
echo "Enable/Start MySQL"
systemctl enable mysqld.service
systemctl start mysqld.service

# Enable/start Apache
echo "Enable/Start Apache"
systemctl enable httpd.service
systemctl start httpd.service

# Enable/start Fail2Ban
echo "Enable/Start Fail2Ban"
systemctl enable fail2ban.service
systemctl start fail2ban.service

# Setup pear db
echo "Enable Pear DB"
pear install db

# Move to /usr/src then download/extract the FreePBX files
echo "Download/Extract FreePBX"
cd /usr/src
git clone http://git.freepbx.org/scm/freepbx/framework.git freepbx
cd freepbx
git checkout release/${VER_FREEPBX}

# Changes to PHP
echo "Adjusting PHP"
cp ${PHPINI} ${PHPINI}_orig
# Activate gd.so
sed -i 's/;extension=gd.so/extension=gd.so/' $PHPINI
# Activate ldap.so
sed -i 's/;extension=ldap.so/extension=ldap.so/' $PHPINI
# Activate mysqli.so
sed -i 's/;extension=mysqli.so/extension=mysqli.so/' $PHPINI
# Activate mysql.so
sed -i 's/;extension=mysql.so/extension=mysql.so/' $PHPINI
# Activate openssl.so
sed -i 's/;extension=openssl.so/extension=openssl.so/' $PHPINI
# Activate pdo_mysql.so (thanks tm1000)
sed -i 's/;extension=pdo_mysql.so/extension=pdo_mysql.so/' $PHPINI
# Activate pdo_sqlite.so (thanks tm1000)
sed -i 's/;extension=pdo_sqlite.so/extension=pdo_sqlite.so/' $PHPINI
# Activate phar.so
sed -i 's/;extension=phar.so/extension=phar.so/' $PHPINI
# Activate posix.so
sed -i 's/;extension=posix.so/extension=posix.so/' $PHPINI
# Activate sysvmsg.so
sed -i 's/;extension=sysvmsg.so/extension=sysvmsg.so/' $PHPINI
# Activate sysvsem.so
sed -i 's/;extension=sysvsem.so/extension=sysvsem.so/' $PHPINI
# Activate sysvshm.so
sed -i 's/;extension=sysvshm.so/extension=sysvshm.so/' $PHPINI
# Activate xmlrpc.so
sed -i 's/;extension=xmlrpc.so/extension=xmlrpc.so/' $PHPINI
# Activate xsl.so
sed -i 's/;extension=xsl.so/extension=xsl.so/' $PHPINI
# Activate zip.so
sed -i 's/;extension=zip.so/extension=zip.so/' $PHPINI
# Deactivate open_basedir
sed -i 's/open_basedir =/; open_basedir =/' $PHPINI
# Increase upload_max_filesize
sed -i 's/\(^upload_max_filesize = \).*/\120M/' $PHPINI
# Set session.save_path to /usr/include/php/ext/session/
sed -i '/session.save_path/asession.save_path=\"\/usr\/include\/php\/ext\/session\"' $PHPINI

# Changes to Apache
echo "Adjusting Apache"
cp ${APACHECONF} ${APACHECONF}_orig
# Set User & Group to asterisk
sed -i 's/^\(User\|Group\).*/\1 asterisk/' $APACHECONF
# Change to mod_mpm_preform.so allowing libphp5.so to work preventing "threaded MPM" error
sed -i 's/LoadModule mpm_event_module modules\/mod_mpm_event.so/LoadModule mpm_prefork_module modules\/mod_mpm_prefork.so/' $APACHECONF
# Add LoadModule for libphp5.so after "LoadModule dir_module modules/mod_dir.so"
sed -i '/LoadModule dir_module modules\/mod_dir.so/aLoadModule php5_module modules\/libphp5.so' $APACHECONF
# Add Include php5_module.conf at end of Includes
sed -i '/Include conf\/extra\/httpd-default.conf/aInclude conf\/extra\/php5_module.conf' $APACHECONF
# Enable .htaccess (hypertext access)
echo " " >> $APACHECONF
echo "# HTAccess for FreePBX" >> $APACHECONF
echo "<Directory \"/srv/http/freepbx\">" >> $APACHECONF
echo "AllowOverride all" >> $APACHECONF
echo "</Directory>" >> $APACHECONF

# Changes to install_amp - change webroot directory from /var/www/html to /srv/http/freepbx
# Leaving this here for now, but I am generally against making any changes to any FreePBX scripts
cp install_amp install_amp_orig
sed -i 's/\/var\/www\/html/\/srv\/http\/freepbx/' install_amp

# Change permissions on /var/log/asterisk
# Still not sure if this command is needed, but leaving it here for now
chmod 777 /var/log/asterisk

# Restart Apache
echo "Restart Apache"
systemctl restart httpd.service

# Create MySQL (MariaDB) databases
echo "Configure MySQL Database"
mysqladmin -u root create asterisk
mysqladmin -u root create asteriskcdrdb

# Set privileges on database
echo "Set Privileges on Database"
mysql -u root -e "GRANT ALL PRIVILEGES ON asterisk.* TO asteriskuser@localhost IDENTIFIED BY '${ASTERISK_DB_PW}';"
mysql -u root -e "GRANT ALL PRIVILEGES ON asteriskcdrdb.* TO asteriskuser@localhost IDENTIFIED BY '${ASTERISK_DB_PW}';"
mysql -u root -e "flush privileges;"

# Subsequent commands to be run to finalize intallation
# At some point may need to embrace systemctl for starting/stopping/restarting Asterisk
# but for now leaving the FreePBX script "start_asterisk" as the method for controlling Asterisk
./start_asterisk start
./install_amp --installdb --username=asteriskuser --password=${ASTERISK_DB_PW}
./start_asterisk stop
./start_asterisk start
amportal a ma installall
amportal a reload
amportal chown

# Additional commands as a reference
# ./install_amp --cleaninstall
# ./install_amp --installdb
# ./install_amp --uninstall
# ./install_amp --installdb
')
calzon65
 
Posts: 80
Joined: Wed May 25, 2011 9:06 pm

Re: FreePBX-12 & Asterisk-12 on Alarm

Postby habusho » Sun Aug 17, 2014 11:23 pm

Thank you very much for this!

I've actually used many of the hints from your script to install Asterisk and FreePBX manually. I have a quad core UDOO and it's running really nicely.

I'm not able to log in to the GUI though. I've run all the commands specified on your script and still no go.
habusho
 
Posts: 3
Joined: Sun Aug 17, 2014 11:17 pm

Re: FreePBX-12 & Asterisk-12 on Alarm

Postby habusho » Mon Aug 18, 2014 3:38 pm

I just had one question about this script.
The FreePBX wiki lists many other dependencies than what is listed with your script. Off the top of my head, curl, bison, ncurses and a couple of others come to mind. Are you saying that this script works without those dependencies?
habusho
 
Posts: 3
Joined: Sun Aug 17, 2014 11:17 pm

Re: FreePBX-12 & Asterisk-12 on Alarm

Postby calzon65 » Sun Aug 24, 2014 7:08 pm

habusho, thank you for the feedback. I'm glad to see the script is providing some help for folks.

I can not say 100% if the other dependencies you mention are required are not. Please keep in mind that when you install Asterisk via pacman (which installs Asterisk 12), it automatically installs a number of dependencies as well. Also, FreePBX 12, which is the version this script installs, is still in beta so changes / issues should be expected. If you check the ArchLinux AUR, lookup Asterisk to see the dependencies loaded with that package.

I haven't worked on this script in about a month but when I last posted the script I was able to run Asterisk-12 and FreePBX-12 after using the script. If it's any help, I start with a completely clean install of ArchLinux ARM on a Beagle Bone Black and use the script. I still notice a few errors during installation, but I am able to connect to FreePBX-12 and then manage Asterisk-12.

Please, if you have any suggestions, bug fixes, or feedback, I would very much welcome it to improve the script.

Edit: I do see curl is installed when you use pacman to install Asterisk. I am not sure as to the requirement and/or dependency of ncurses or bison.
calzon65
 
Posts: 80
Joined: Wed May 25, 2011 9:06 pm

Re: FreePBX-12 & Asterisk-12 on Alarm

Postby hecatae » Tue Nov 18, 2014 9:19 pm

hi Calzon65,

thankyou for the script I'm currently testing it out.

as Freepbx12 is now stable, will you be committing any further time to this?
hecatae
 
Posts: 32
Joined: Tue Nov 18, 2014 9:17 pm


Return to General

Who is online

Users browsing this forum: No registered users and 20 guests