FreeSwitch and FreePBX-v3

by quinnebert
241 deployments · 35 still active · last rev. 4 years ago

"The quickest way to roll out FreeSwitch and FreePBX-V3 on a Linode!"
--Me, in an interview with myself ;-)

TO ANSWER THE BLUE.BOX QUESTION: I *am* looking into making a version of this StackScript that uses Blue.Box. I have heard mixed reviews of it from folks I respect, but if you let me know you want it (see the IRC info a bit further down this description), it will increase my willingness to do this.

Update: October 31, 2011:
Fixed issues that have cropped up over time. Debian 6 x86_32 is now the ONLY supported distribution for sake of ease of maintenance.

Update: May 17, 2010:
I welcome you to join me on IRC.TBRN.NET (port 6667, if you're picky) if you wish to speak with me, or a fair-sized group of my co-workers and friends. :)

Update: May 12, 2010:
Thanks to FreeSwitch.org for the 8-day-early birthday present of covering my script on their home page! If you're coming here from their review, and want to give me a birthday gift, might I simply ask you make me happy and visit my web site?
http://www.QuinnEbert.net/

This i386-Debian-6 StackScript installs FreeSwitch PBX Software, standard-definition sound and MoH packs, and FreePBX V3.

The steps of rolling out this stack go as-follows:
1. Deploy a Linode.with this StackScript.
2. Go to the web server (standard HTTP port - 80) on the node's default IP address.
3. Simply run through the FreePBX Setup Wizard that appears in the web browser. Use the "root" MySQL user (with the password you'll give at deploy-time) in the wizard, and it will create the MySQL database for you.

I *am* available to customize PBX system configurations, including custom deployment solutions for Linode (and possibly others, including Amazon EC2), contact me on the IRC channel listed below for further information...

Questions, Comments, Bug Reports, or Feedback?
Visit #TheLobby on IRC.TBRN.NET

This stack script (minus the included portions from Linode's StackScript Library) is provided under a CreativeCommons.org Attribution-Noncommercial-Share Alike 3.0 United States License
Details at: http://creativecommons.org/licenses/by-nc-sa/3.0/us/

Compatible with: No distros currently supported
						#!/bin/bash
# <UDF name="db_password" Label="MySQL root Password" />

# Import the Linode standard StackScript Library
source <ssinclude StackScriptID="1">

# Bring The System Up-to-date
system_update

# Ensure APT package list is up-to-date 
apt-get -y update

# Ensure OpenSSH Service is installed...
apt-get -y install openssh-server

# MySQL Install and Configure first DB
mysql_install "$DB_PASSWORD" && mysql_tune 40

# Install bulk of packages we need...
apt-get -y install php5 php5-xcache php5-xmlrpc php5-mysql php5-gd php5-cli build-essential git git-core autoconf libgdbm-dev libdb-dev subversion php5-curl automake libtool libncurses5 libncurses5-dev php-db

# less pager, wget, and vim editor
goodstuff

# Install new packages needed by FS as of our Q4-2011 checkup...
apt-get -y install pkg-config automake autoconf libsigc++-2.0-dev libssl-dev libjpeg-dev

# CD into the sourcecode directory...
cd /usr/local/src

# Use GIT to grab freeswitch...
git clone git://git.freeswitch.org/freeswitch.git

# CD into the freeswitch code directory...
cd /usr/local/src/freeswitch

##
## FREESWITCH INSTALLATION
##
#
# All of this is done in one line, to allow fallthrough on-failure...
#
# Bootstrap for the freeswitch configuration...
./bootstrap.sh
# Configure the freeswitch code for compilation...
./configure
# BUILD FREESWITCH -- 5 parallel jobs (Linodes have 4 cores)...
make -j5
# INSTALL FREESWITCH
make install
# INSTALL FREESWITCH SOUNDS -AND- MOH
make all cd-sounds-install cd-moh-install
# BRING UP FREESWITCH IN DAEMON MODE
cd /usr/local/freeswitch/bin
./freeswitch -ncwait

# Install PHP with Apache, and tune PHP
php_install_with_apache && php_tune
# Post-Setup and Tune Apache
apache_install && apache_tune 40

##
## FREEPBX INSTALLATION
##
# 
# Put ourselves in the proper directory...
# 
cd /var/www
# 
# Grab the FreePBX codebase...
# 
svn co http://www.freepbx.org/v3/svn/trunk/ freepbx-v3/
# 
# Set up filesystem permissions proper...
# 
chgrp -R www-data /usr/local/freeswitch/conf/*
chmod -R g+w /usr/local/freeswitch/conf/*
chmod 777 freepbx-v3/freepbx/logs/
chmod 777 freepbx-v3/freepbx/cache/
chgrp -R www-data freepbx-v3/freepbx/config/*
chmod -R g+w freepbx-v3/freepbx/config/*
mkdir freepbx-v3/upload
chgrp -R www-data freepbx-v3/upload
chmod -R g+w freepbx-v3/upload

# Redirect direct HTTP request to FreePBX3 Interface...
echo '<?php header("Location: /freepbx-v3/");' > /var/www/index.php

# cleanup after stackscripts
restartServices

# enable "default" apache "site"
a2ensite default
# restart apache for good measure
/etc/init.d/apache2 stop
echo -n 'Sleeping 5 seconds for sanity...' && sleep 5 && echo 'Moving on...'
/etc/init.d/apache2 start
# enable mod_rewrite on apache
a2enmod rewrite
# restart apache (again) for good measure
/etc/init.d/apache2 stop
echo -n 'Sleeping 5 seconds for sanity...' && sleep 5 && echo 'Moving on...'
/etc/init.d/apache2 start

# OK, make fixups for FreePBX's PHP warnings:
echo 'post_max_size = 10M' >> '/etc/php5/apache2/conf.d/freepbx3.ini'
echo 'upload_max_filesize = 10M' >> '/etc/php5/apache2/conf.d/freepbx3.ini'
echo 'max_execution_time = 120' >> '/etc/php5/apache2/conf.d/freepbx3.ini'
echo 'max_input_time = 240' >> '/etc/php5/apache2/conf.d/freepbx3.ini'
# And, one FINAL Apache restart (to apply those settings)
/etc/init.d/apache2 stop
echo -n 'Sleeping 5 seconds for sanity...' && sleep 5 && echo 'Moving on...'
/etc/init.d/apache2 start

# Finally, let's remove that stupid "It Works!" page, allowing the PHP redirect
# to be used...
rm -f /var/www/index.htm /var/www/index.html

# Finished...Let them know...
echo 'All done!  If you REALLY want to use Lish for administration, you can'
echo 'press CTRL+C to do so immediately, or pause 5 minutes for this script'
echo 'to exit on its own.  NOTE: exiting this script MAY clear the console!'

# Wait for five minutes...
sleep 300

# Clean up the view...
clear

#               #
# ALL DONE HERE #
#               #