CentOS Install

From FusionPBX
Revision as of 08:23, 12 June 2011 by Admin (talk | contribs) (MySQL)
Jump to: navigation, search

Preface

The following instructions were written for CentOS 5.6. http://mirror.centos.org/centos/5/isos/ After installing CentOS follow the instructions below.

Dependencies

Install the following dependencies

yum install subversion autoconf automake libtool gcc-c++ git-core ncurses-devel make expat-devel zlib zlib-devel
yum install nano unixODBC-devel openssl-devel gnutls-devel libogg-devel libvorbis-devel curl-devel libtiff-devel libjpeg-devel python-devel expat-devel zlib zlib-devel bzip2

GIT Install

cd /usr/local/src
yum -y install gcc make gettext-devel curl-devel
wget http://kernel.org/pub/software/scm/git/git-1.7.4.tar.bz2
tar -xvjf git-1.7.4.tar.bz2
cd git-1.7.4
make prefix=/usr/local all
make prefix=/usr/local install

FreeSWITCH Install

Then use the following

cd /usr/src/
git clone git://git.freeswitch.org/freeswitch.git
cd /usr/src/freeswitch
./bootstrap.sh

Edit modules.conf to enable or disable desired modules. To enable a few extra features you may want to go ahead and edit modules.conf. Remove the # in front of the lines with these modules:

mod_spandsp
mod_flite
mod_shout
mod_pocketshpinx

Complete the FreeSWITCH compile.

./configure
make install
make samples
make cd-sounds-install
make cd-moh-install
make hd-moh-install
make hd-sounds-install
+---------- FreeSWITCH install Complete ----------+
+ FreeSWITCH has been successfully installed.     +
+                                                 +
+       Install sounds:                           +
+       (uhd-sounds includes hd-sounds, sounds)   +
+       (hd-sounds includes sounds)               +
+       ------------------------------------      +
+                make cd-sounds-install           +
+                make cd-moh-install              +
+                                                 +
+                make uhd-sounds-install          +
+                make uhd-moh-install             +
+                                                 +
+                make hd-sounds-install           +
+                make hd-moh-install              +
+                                                 +
+                make sounds-install              +
+                make moh-install                 +
+                                                 +
+       Install non english sounds:               +
+       replace XX with language                  +
+       (ru : Russian)                            +
+       ------------------------------------      +
+                make cd-sounds-XX-install        +
+                make uhd-sounds-XX-install       +
+                make hd-sounds-XX-install        +
+                make sounds-XX-install           +
+                                                 +
+       Upgrade to latest:                        +
+       ----------------------------------        +
+                make current                     +
+                                                 +
+       Rebuild all:                              +
+       ----------------------------------        +
+                make sure                        +
+                                                 +
+       Install/Re-install default config:        +
+       ----------------------------------        +
+                make samples                     +
+                                                 +
+                                                 +
+       Additional resources:                     +
+       ----------------------------------        +
+       http://www.freeswitch.org               +
+       http://wiki.freeswitch.org              +
+       http://jira.freeswitch.org              +
+       http://lists.freeswitch.org             +
+                                                 +
+       irc.freenode.net / #freeswitch            +
+                                                 +
+-------------------------------------------------+


To upgrade FreeSWITCH in the future do the following:

cd /usr/src/freeswitch
make current

FreeSWITCH Auto Start

Copy the sample-init-file to /etc/init.d/

 cp build/freeswitch.init.redhat /etc/init.d/freeswitch

Replace /opt/freeswitch with /usr/local/freeswitch in the /etc/init.d/freeswitch

sed -i 's/\/opt\/freeswitch/\/usr\/local\/freeswitch/g' /etc/init.d/freeswitch

Set the permissions and add it to run on startup

chmod 765 /etc/init.d/freeswitch
/sbin/chkconfig --add freeswitch
/sbin/chkconfig --level 5 freeswitch on
/sbin/chkconfig --list freeswitch

FreeSWITCH conf

Disable the following files but leave them for examples

cd /usr/local/freeswitch/conf/dialplan/default
mv 00_ladspa.xml 00_ladspa.noload
mv 00_pizza_demo.xml 00_pizza_demo.noload
mv 01_Talking_Clock.xml 01_Talking_Clock.noload

Repositories

CentOS does not yet ship a recent enough version of PHP in order to use PHP FPM (fast cgi), so we suggest you use the RPMs provided in the REMI repository. To do so:

wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm 
wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
rpm -Uvh epel-release-5-4.noarch.rpm
rpm -Uvh remi-release-5.rpm

Database

SQLite

Is installed with PHP

PostgreSQL

Postgres 8.4 or higher is required. The following instructions install version 9.0 Replace the custom-username and custom-password with the account information.

http://wiki.postgresql.org/wiki/YUM_Installation (additional information)

Locate and edit your distributions .repo file, located: [base] and [updates] sections

nano /etc/yum.repos.d/CentOS-Base.repo

To the section(s) identified above, you need to append a line:

exclude=postgresql*

Download and install PGDG RPM file

wget http://www.pgrpms.org/9.0/redhat/rhel-5-i386/pgdg-centos-9.0-2.noarch.rpm
rpm -ivh pgdg-centos-9.0-2.noarch.rpm
yum install postgresql90-server
service postgresql-9.0 initdb
/sbin/chkconfig postgresql-9.0 on
service postgresql initdb
service postgresql-9.0 start
su postgres
psql
CREATE ROLE custom-username WITH SUPERUSER LOGIN PASSWORD 'custom-password';
\q
exit
sed -i 's/ident/md5/g' /var/lib/pgsql/9.0/data/pg_hba.conf
service postgresql-9.0 restart

MySQL

Check to see if MySQL is installed

yum --enablerepo=remi list mysql mysql-server

If it is installed then update it to a newer version

yum --enablerepo=remi upgrade mysql mysql-server

If it is not installed then add it

yum –-enablerepo=remi install mysql mysql-server
chkconfig mysqld on
service mysqld start

PHP

rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm  
yum --enablerepo=remi install php php-common php-pdo php-soap php-xml php-xmlrpc
yum --enablerepo=remi upgrade php php-common php-pdo

For PostgreSQL add

yum --enablerepo=remi install php-pgsql

For MySQL then add

yum --enablerepo=remi install php-mysql

Web Server

There are multiple choices for a web server to use. These instructions focus on nginx because it takes very little server resources and scales well.

NGINX (pronounced: engine x)

yum --enablerepo=remi install nginx php-fpm
/sbin/chkconfig php-fpm on
/sbin/chkconfig nginx on

Add the following directories.

mkdir /etc/nginx/sites-available
mkdir /etc/nginx/sites-enabled

Remove the original config and add a more flexible one.

rm nginx.conf
wget http://www.fusionpbx.com/downloads/centos/nginx/nginx.conf
cd /etc/nginx/sites-available
wget http://www.fusionpbx.com/downloads/centos/nginx/fusionpbx.conf
ln /etc/nginx/sites-available/fusionpbx.conf /etc/nginx/sites-enabled/fusionpbx.conf

OpenSSL

Make sure the /etc/ssl directory exists

mkdir -p /etc/ssl

Change the directory

cd /etc/ssl

Generate a private key:

openssl genrsa -des3 -passout pass:fusionpbx_cert_password -out fusionpbx.ssl.key 1024

Remove password from private key:

openssl rsa -in fusionpbx.ssl.key -passin pass:fusionpbx_cert_password -out fusionpbx.ssl.key.nopass

Create a CSR (certificate signing request):

openssl req -new -key fusionpbx.ssl.key.nopass -out fusionpbx.ssl.csr -subj "/CN=fusionpbx/OU=Project/O=FusionPBX/L=Boise/C=US"

Generate self-signed cert:

openssl x509 -req -days 3650 -in fusionpbx.ssl.csr -signkey fusionpbx.ssl.key.nopass -out fusionpbx.ssl.crt

FusionPBX

Download FusionPBX source and add it to the web server directory.

cd /var/www
sudo svn checkout http://fusionpbx.googlecode.com/svn/trunk/fusionpbx /var/www/fusionpbx

If you get an error: 'svn: command not found.' Then add subversion. Then run the svn checkout again.

yum install subversion

Permissions

There are multiple ways to handle permissions. FreeSWITCH creates some file on demand such as voicemail and does not give the necessary group permissions because of that the following method is currently recommended. This method adds the www-data user, changes ownership of the files to use www-data and then make the php-fpm and freeswitch services run as www-data.

/usr/sbin/adduser www-data
chown -R www-data:www-data /usr/local/freeswitch
chown -R www-data:www-data /var/www/fusionpbx
sed -i 's/user = apache/user = www-data/g' /etc/php-fpm.d/www.conf
sed -i 's/group = apache/group = www-data/g' /etc/php-fpm.d/www.conf
sed -i 's/${FS_USER-freeswitch}/${FS_USER-www-data}/g' /etc/init.d/freeswitch
chown -R www-data:www-data -R /var/lib/php/session

Network Time Protocol

If NTP is not installed then install it.

yum install ntp
chkconfig ntpd on
ntpdate pool.ntp.org
service ntpd start

If NTP is running then do the following:

service ntpd stop
ntpdate pool.ntp.org
service ntpd start

Fail2ban

Brute force attacks are common. If the SIP and RTP ports are exposed to the Internet then it is important to install and configure Fail2ban. Fail2ban can be configured to analyze the FreeSWITCH logs. When attacker are identified it blocks the offenders.

For more info go to Fail2Ban

Browser

To complete install go to the ip address or domain of the server in your web browser. You can use http or https and follow the instructions.

Login

After completing the install the default login information is:

user: superadmin

pass: fusionpbx

TDM notes

Optional TDM card notes. These notes have not been updated in a while. CentOS Install TDM

Additional Notes

How to start stop FreeSWITCH

service freeswitch start
service freeswitch stop

How to start, stop and restart Apache

service nginx start
service nginx stop
service nginx restart

Change the CentOS root password

su root
passwd