OpenSIPS and Control Panel Install Guide

OpenSIPSThis install guide was tested using the Redhat Enterprise Linux v5 distribution known as CentOS . 


Most of the install procedures for OpenSIPS assume Debian.  I prefer working with RHEL which is the reason for this install procedure.  This guide should work on Debian with some minor modifications but I haven't tried.

Software used:

CentOS v5
OpenSIPS v1.6
OpenSIPS-CP v4

Linux commands executed at a command prompt are in courier font.

Let's get started

It's assumed you already have a server with a base CentOS installation before you begin.  Do NOT install a GUI such as Gnome or KDE.  We only want to be running in console text mode not GUI graphics mode.  If you already have a desktop or server GUI installed you will want to exit to console mode.  You do that by typing init 3 from a terminal or console window.  You will need to be logged in as root in order to do this so if not you can su root.  All instructions in this guide are assuming you are always logged in as root running in level 3 console text mode.

Get rid of all installed groups except 'Yum Utilities' so we are starting with a clean slate.  Check the delete list before entering 'y' to make sure none of these remove 'sshd' or 'yum' (they don't but check just in case things change with newer revisions).

yum grouplist installed

Installed Groups:
   DNS Name Server
   Legacy Network Server
   Mail Server
   Network Servers
   System Tools
   Text-based Internet
   Web Server
   Windows File Server
   Yum Utilities

yum groupremove 'DNS Name Server'
yum groupremove 'Editors'
yum groupremove 'Legacy Network Server'
yum groupremove 'Mail Server'
yum groupremove 'Network Servers'
yum groupremove 'System Tools'
yum groupremove 'Text-based Internet'
yum groupremove 'Web Server'
yum groupremove 'Windows File Server'

 Now update the base install

yum -y update

Install OpenSIPS and OpenSIPS-CP required packages, other useful packages, and their dependencies

yum groupinstall core
yum groupinstall base

yum install nano gcc gcc-c++ bison flex zlib-devel openssl-devel mysql-server mysql-devel subversion pcre-devel php-mysql php-pear

Selinux is not required or recommended.  This will create the required file if it does not already exist.  If it already exists copy paste or edit the contents indicated here to be sure selinux never runs.

nano /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.

# SETLOCALDEFS= Check local definition changes

(Ctrl-x> y >Enter)

Make sure selinux is turned off for this session

setenforce 0

OpenSIPS and xmlrpc
Thanks to the author of this post for the valuable information

Compile the library xmlrpc-c which is required for OpenSIPS-CP.  If you forget to use --disable-abyss-threads the system will dump the core because OpenSIPS is multiprocess but not multithreaded.  The newer versions of xmlrpc compile by default with threads enabled.  This problem does not occur with Debian or Ubuntu because they use an older version of xml-rpc (0.9.1) that does not support threads.

If the --prefix=/usr is not used the sofware will install in /usr/local which will result in CentOS not able to find the xmlrpc libraries which will be in /usr/local/lib instead of /usr/lib.  So you would have to copy/paste and then /sbin/ldconfig -v.  Or you would have to create a symbolic link.  Using the --prefix=/usr so it is put in the expected place to begin with is simpler IMHO.

cd /usr/src

tar -xzvf xmlrpc-c-1.16.36.tgz
cd xmlrpc-c-1.16.36
./configure --disable-abyss-threads --prefix=/usr
make install

Download the latest OpenSIPS v6 source

cd /usr/src
svn co opensips

Remove from the “Exclude=” (line 52) the modules db_mysql and mi_xmlrpc so that they are included in the compilation process.

cd /usr/src/opensips
nano Makefile

remove the db_mysql and mi_xmlrpc in the section starting on line 52 and then save.

Now compile OpenSIPS
cd /usr/src/opensips
make prefix=/ all
make prefix=/ install

uncomment (#) DBENGINE=MYSQL
nano /etc/opensips/opensipsctlrc

start mysql
service mysqld start

Create OpenSIPS database.  NOTE: when it asks for a root password it will be blank unless you have previously set it to something else.
opensipsdbctl create
Answer 'y' to both questions

edit the opensips.cfg file
nano /etc/opensips/opensips.cfg

uncomment the following lines:
loadmodule ""
loadmodule ""
loadmodule ""
modparam("usrloc", "db_mode", 2)
modparam("auth_db", "calculate_ha1", yes)  
modparam("auth_db", "password_column", "password")

Uncomment and modify the following section adding or your IP if it is a remote server.

#authenticate the REGISTER requests (uncomment to enable auth)
if (!www_authorize("", "subscriber"))  
    www_challenge("", "0");  
Add the following 2 lines in the appropriate areas:
loadmodule "" 
modparam("mi_xmlrpc", "port", 8000)

Check if OpenSIPS starts
opensipsctl start
you should see

INFO: Starting OpenSIPS :
INFO: started (pid: xxxx)
Copy startup script
cp /usr/src/opensips/packaging/fedora/opensips.init /etc/init.d/opensips
chmod 755 /etc/init.d/opensips
And modify for our install
nano /etc/init.d/opensips
# chkconfig: - 85 15
# chkconfig: 345 96 15
and change
Now test it.
service opensips stop
Stopping opensips: OK
service opensips status
opensips is stopped
service opensips start
Starting opensips: OK
service opensips status
opensips (pid xxxx xxxx xxxx....xxxx) is running...
Now add the script to start on boot and set other services to start on boot
chkconfig --add opensips
chkconfig httpd on
chkconfig mysqld on
now reboot
Install OpenSIPS-CP
cd /var/www/html
tar -xzvf opensips-cp_4.0.tgz
rm -rf /var/www/html/opensips-cp_4.0.tgz
chown -R apache:apache opensips-cp
pear install MDB2
pear install MDB2#mysql
pear install log
nano /etc/httpd/conf/httpd.conf
At the very bottom add:
Alias /cp "/var/www/html/opensips-cp/web"
The next part of this install guide assumes you have already installed the OpenSIPS MySQL database.  If not please refer to that section higher up in this guide.  Also, you will need your MySQL root password which is blank if you have not entered one yet.

Install the admin privileges table schema.

cd /var/www/html/opensips-cp/config/tools/admin/add_admin
mysql -D opensips -p < ocp_admin_privileges.mysql
add admin account to database
mysql -D opensips -p
>INSERT INTO ocp_admin_privileges (username,password,ha1,available_tools,permissions) values ('admin','admin',md5('admin:admin'),'all','all');
The above line creates an 'admin' user account with password 'admin'.  This is what you use to log into OpenSIPS-CP initially.
Install CDRviewer table schema
cd /var/www/html/opensips-cp/config/tools/system/cdrviewer
mysql -D opensips -p < cdrs.mysql
Add new column in the acc table (cdr_id)
mysql -D opensips -p
Install stored procedure schema that generates cdr records from acc table.
cd /var/www/html/opensips-cp/config/tools/system/cdrviewer
mysql -D opensips -p < opensips_cdrs_1_6.mysql
Add smonitor module tables
cd /var/www/html/opensips-cp/config/tools/system/smonitor
mysql -D opensips -p < tables.mysql
Add cron jobs
nano /var/www/html/opensips-cp/cron_job/
modify the names/passwords accordingly.
Default names/passwords are found in /etc/opensips/opensipsctlrc.
Add the following to crontab
nano /etc/crontab
*/3 * * * * root /var/www/opensips-cp/cron_job/
* * * * *   root   php /var/www/opensips-cp/cron_job/get_opensips_stats.php > /dev/null
First line generates cdrs in 3 minute intervals.  Second line collects data every minute using smonitor and should not be changed.
Configuration files
There are global and local .php config files .  Global is used for parameters being accessed in more than one module.  Global config files are in the /config directory.  They should be self explanatory and need to be edited accordingly.  Read the documentation in /doc for more information.
Finally, after all of this, you need to pick a root 'mysql' password and update the config files above as necessary. We'll make it 'abcdef' just for this example.  You should use a reasonably strong password. If you need to do anything else with mysql, you'll need to provide this password.

mysqladmin -u root password 'abcdef'

For working with OpenSIPS manually from command line type:
which will return a list of commands.  This can also be used to verify/troubleshoot OpenSIPS-CP.