Support #667
Install FreeSWITCH and FusionPBX on FreeBSD
Status:
Suspended
Priority:
High
Assignee:
Category:
Voice over IP Server
Target version:
Description
This is a guide for setting up FreeSWITCH with Nginx, PostgreSQL, and FusionPBX on FreeBSD 9.
Prepare the Environment¶
- Make sure the system is up to date:
pkg update && pkg upgrade && portsnap fetch extract
- Install a few dependencies:
pkg install portmaster screen sox cmake autoconf automake lua51 curl git gmake jpeg ldns libedit binutils freetype2 libtool openssl pcre pkgconf flex speex sqlite3 wget subversion postgresql94-client sofia-sip x264 libvpx opus ffmpeg pkg2ng
Install FreeSWITCH¶
NOTE: I could not build FreeSWITCH from ports, so this guide will compile from GitHub.
- Make a source directory and switch to it:
mkdir /usr/local/src && cd /usr/local/src
- Clone the latest version of freeswitch:
git clone -b v1.6 https://freeswitch.org/stash/scm/fs/freeswitch.git
- Build and install freeswitch:
./bootstrap.sh -j ./configure --enable-core-pgsql-support gmake gmake install cd-sounds-install cd-moh-install
- While running gmake, I encountered an error. To work around this I disabled mod_fsv:
sed -i '' -e 's/applications\/mod_fsv/#applications\/mod_fsv/' modules.conf
- While running gmake, I encountered an error. To work around this I disabled mod_fsv:
Freeswitch rc script¶
- Create the rc script:
vi /usr/local/etc/rc.d/freeswitch
- And add the following
#!/bin/sh # # PROVIDE: freeswitch # REQUIRE: LOGIN cleanvar # KEYWORD: shutdown # # Add the following lines to /etc/rc.conf to enable freeswitch: # freeswitch_enable: Set it to "YES" to enable freeswitch. # Default is "NO". # freeswitch_flags: Flags passed to freeswitch-script on startup. # Default is "". # . /etc/rc.subr name="freeswitch" rcvar=${name}_enable load_rc_config $name : ${freeswitch_enable="NO"} : ${freeswitch_pidfile="/usr/local/freeswitch/run/freeswitch.pid"} start_cmd=${name}_start stop_cmd=${name}_stop pidfile=${freeswitch_pidfile} freeswitch_start() { /usr/local/freeswitch/bin/freeswitch ${freeswitch_flags} echo -n "Starting FreeSWITCH: " } freeswitch_stop() { /usr/local/freeswitch/bin/freeswitch -stop } run_rc_command "$1"
- And add the following
- Make the script executable:
chmod +x /usr/local/etc/rc.d/freeswitch
- Start and enable freeswitch to start at boot:
echo 'freeswitch_enable="YES"' >> /etc/rc.conf echo 'freeswitch_flags="-nc"' >> /etc/rc.conf service freeswitch start
- NOTE: If your Freeswitch server has a IP address and not behind a NAT router, add the
-nonat
parameter to the freeswitch_flags. This will disable NAT traversal feature of FreeSWITCH.
- NOTE: If your Freeswitch server has a IP address and not behind a NAT router, add the
Install FusionPBX¶
- Install fusionpbx:
portmaster www/fusionpbx
- NOTE: Make sure to enable [X]PDOPGSQL while configuring fusionpbx.
Install Nginx¶
- Install Nginx
pkg install nginx
- Start and enable nginx at boot:
echo 'nginx_enable="YES"' >> /etc/rc.conf service nginx start
- Create a configuration directory to make managing individual server blocks easier
mkdir /usr/local/etc/nginx/conf.d
- Edit the main nginx config file:
vi /usr/local/etc/nginx/nginx.conf
- And strip down the config file and add the include statement at the end to make it easier to handle various server blocks:
#user nobody; worker_processes 1; error_log /var/log/nginx-error.log; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; # Load config files from the /etc/nginx/conf.d directory include /usr/local/etc/nginx/conf.d/*.conf; }
- And strip down the config file and add the include statement at the end to make it easier to handle various server blocks:
- Now create a config for pbx.example.com:
vi /usr/local/etc/nginc/conf.d/pbx.example.com.conf
- And add the following:
server{ listen 80; server_name pbx.example.com; access_log /var/log/nginx-access.log; error_log /var/log/nginx-error.log; client_max_body_size 10M; client_body_buffer_size 128k; root /usr/local/www/fusionpbx; location / { root /usr/local/www/fusionpbx; index index.php; } location ~ \.php$ { fastcgi_pass unix:/var/run/php-fpm.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } # Disable viewing .htaccess & .htpassword & .db location ~ .htaccess { deny all; } location ~ .htpassword { deny all; } location ~^.+.(db)$ { deny all; } }
- And add the following:
- Change the freeswitch config file ownership to the www user:
chown -R www:www /usr/local/freeswitch/conf
- Change the fusionpbx files ownership to the www user:
chown -R www:www /usr/local/www/fusionpbx
Configure PHP¶
- Configure the default PHP settings
cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
- Edit the php-fpm config file:
vi /usr/local/etc/php-fpm.conf
- Make the following changes:
listen = /var/run/php-fpm.sock listen.owner = www listen.group = www listen.mode = 0660
- Make the following changes:
- Start and enable PHP-FPM at boot:
echo 'php_fpm_enable="YES"' >> /etc/rc.conf service php-fpm start
Setup Database¶
NOTE: This guide has an external postgresql server and does not cover setting up the server.
- Create the database and user:
su postgres createuser -s -e fusionpbxuser createdb -O fusionpbxuser fusionpbxdb psql -d fusionpbxdb -U fusionpbxuser ALTER USER fusionpbxuser with PASSWORD 'SuperSecretPassword';
- Then open http://pbx.example.com in a web browser and finish the installation; make sure to select the postgresql database adapter.
Resources¶
Updated by Daniel Curtis about 9 years ago
- Description updated (diff)
- Status changed from New to In Progress
- % Done changed from 0 to 20
Updated by Daniel Curtis about 9 years ago
- Description updated (diff)
- % Done changed from 20 to 30
Updated by Daniel Curtis about 9 years ago
- Description updated (diff)
- % Done changed from 30 to 50
Updated by Daniel Curtis about 9 years ago
- Description updated (diff)
- % Done changed from 50 to 70