Thursday, November 11, 2010

OpenSIPS Installation notes

1. First install the following dependencies that will be needed to compile OpenSIPS sources:

- bison
- flex
- mysql
- mysql-devel
- subversion (if you intend to use subversion to get its sources

*you can install the said sources via tarballs or rpms or via yum which I did :-)

2. Get the latest source package of OpenSIPs (currently it's 1.5.x series)

wget http://opensips.org/pub/opensips/1.5.0/src/opensips-1.5.0-tls_src.tar.gz

3. Unzip and extract the files

tar xvzf opensips-1.5.0-tls_src.tar.gz

4. cd to the source directory

cd opensips-1.5.0-tls

5. Do following for compilation and installation

make clean
make all
make install ; it seems to be simplified ah ;-) by default everything will be installed at /usr/local

6. Now edit first openserctlrc

vi /usr/local/etc/opensips/opensipsctlrc

uncomment the line that says

DBENGINE=MYSQL

7. Now we can create the database for the OpenSIPs

/usr/local/sbin/opensipsdbctl create

; this will prompt for mysql root password

*Note that upon execution of this command it will create 2 users for OpenSIPs

; by default the mysql database user created is:

username: opensips
password: opensipsrw

8. Now edit opensips.cfg

vi /usr/local/etc/opensips/opensips.cfg

uncomment all lines in configuration file opensips.cfg which are related to
authentication:
- loadmodule "/usr/lib/opensips/modules/db_mysql.so"
- loadmodule "/usr/lib/opensips/modules/auth.so"
- loadmodule "/usr/lib/opensips/modules/auth_db.so"
- modparam("usrloc", "db_mode", 2)
- modparam("auth", "calculate_ha1", yes)
- modparam("auth_db", "password_column", "password")
- if (!www_authorize("sip.org", "subscriber")) {
www_challenge("sip.org", "0");
break;

Make sure you change the two sip.org instances in the above config, to your
domain, or realm. In my case, I changed this to 192.168.2.235 which was the
IP address of this box.

Also, be sure to comment out the following line:

modparam("usrloc", "db_mode", 0)

9. Now let us copy the init script so as to start OpenSIPs as service ( such as starting it at boot). Copy the openser.init which can be found on the base directory of the OpenSIPs source. In my case it is at /usr/src

cp /usr/src/opensips-1.5.0-tls/packaging/rpm/opensips.init /etc/init.d/openser

chmod 755 /etc/init.d/opensips
/sbin/chkconfig --add opensips

also before you start the openser correct the path of its service execution

vi /etc/init.d/opensips

change the following line

osips=/usr/sbin/opensips

with this one since we installed the binaries on path /usr/local

osips=/usr/local/sbin/opensips

10. Now you can start OpenSIPs service

/sbin/service opensips start

To check if it is running issue

ps aux|grep opensips

you should see something like this

root 4210 0.3 0.6 43048 3548 ? S 21:21 0:00 /usr/local/sbin/opensips -P /var/run/opensips.pid
root 4214 0.0 0.2 43048 1216 ? S 21:21 0:00 /usr/local/sbin/opensips -P /var/run/opensips.pid
root 4217 0.0 0.2 43048 1140 ? S 21:21 0:00 /usr/local/sbin/opensips -P /var/run/opensips.pid

11. To test we will create user / SIP account to test our set up. We can do this by using the opensipsctl tool

/usr/local/sbin/opensipsctl add mytest 'abc123!@#'

*Note you might encounter problem once you issued the command above and complaining for the SIP_DOMAiN. To fix that,
issue the command as follows:

export SIP_DOMAIN=192.168.2.235

Now re issue the command for adding new user / SIP account

12. Test it by registering a softphone and filling up the phone's registration info's. You should be able to register already.

No comments:

Post a Comment