Install OpenSIPs 1.8 on Ubuntu 12

How to Install OpenSIPs 1.8 on Ubuntu 12

 

1. Install libraries before installing Opensips

root@ubuntu:~# apt-get install build-essential openssl bison flex perl libdbi-pe rl libdbd-mysql-perl libdbd-pg-perl libfrontier-rpc-perl libterm-readline-gnu-pe rl libberkeleydb-perl ncurses-dev
Reading package lists… Done
Building dependency tree
Reading state information… Done
Note, selecting ‘libncurses5-dev’ instead of ‘ncurses-dev’
The following extra packages will be installed:
binutils cpp cpp-4.6 dpkg-dev fakeroot g++ g++-4.6 gcc gcc-4.6 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libbison-dev libc-bin libc-dev-bin libc6 libc6-dev
libdpkg-perl libencode-locale-perl libfile-listing-perl libfl-dev libfont-afm-perl libgmp10 libgomp1 libhtml-form-perl libhtml-format-perl libhtml-parser-perl libhtml-tagset-perl
libhtml-tree-perl libhttp-cookies-perl libhttp-daemon-perl libhttp-date-perl libhttp-message-perl libhttp-negotiate-perl libio-socket-inet6-perl libio-socket-ssl-perl liblwp-mediatypes-perl
liblwp-protocol-https-perl libmailtools-perl libmpc2 libmpfr4 libmysqlclient18 libnet-daemon-perl libnet-http-perl libnet-ssleay-perl libplrpc-perl libpq5 libquadmath0 libsocket6-perl
libstdc++6-4.6-dev libtinfo-dev liburi-perl libwww-perl libwww-robotrules-perl libxml-parser-perl linux-libc-dev m4 make manpages-dev mysql-common patch perl-base perl-modules
Suggested packages:
binutils-doc bison-doc cpp-doc gcc-4.6-locales debian-keyring g++-multilib g++-4.6-multilib gcc-4.6-doc libstdc++6-4.6-dbg gcc-multilib autoconf automake1.9 libtool gdb gcc-doc gcc-4.6-multilib
libmudflap0-4.6-dev libgcc1-dbg libgomp1-dbg libquadmath0-dbg libmudflap0-dbg binutils-gold glibc-doc libdata-dump-perl libcrypt-ssleay-perl ncurses-doc libstdc++6-4.6-doc libauthen-ntlm-perl
make-doc diffutils-doc perl-doc libpod-plainer-perl
The following NEW packages will be installed:
binutils bison build-essential cpp cpp-4.6 dpkg-dev fakeroot flex g++ g++-4.6 gcc gcc-4.6 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libberkeleydb-perl
libbison-dev libc-dev-bin libc6-dev libdbd-mysql-perl libdbd-pg-perl libdbi-perl libdpkg-perl libencode-locale-perl libfile-listing-perl libfl-dev libfont-afm-perl libfrontier-rpc-perl libgmp10
libgomp1 libhtml-form-perl libhtml-format-perl libhtml-parser-perl libhtml-tagset-perl libhtml-tree-perl libhttp-cookies-perl libhttp-daemon-perl libhttp-date-perl libhttp-message-perl
libhttp-negotiate-perl libio-socket-inet6-perl libio-socket-ssl-perl liblwp-mediatypes-perl liblwp-protocol-https-perl libmailtools-perl libmpc2 libmpfr4 libmysqlclient18 libncurses5-dev
libnet-daemon-perl libnet-http-perl libnet-ssleay-perl libplrpc-perl libpq5 libquadmath0 libsocket6-perl libstdc++6-4.6-dev libterm-readline-gnu-perl libtinfo-dev liburi-perl libwww-perl
libwww-robotrules-perl libxml-parser-perl linux-libc-dev m4 make manpages-dev mysql-common patch
The following packages will be upgraded:
libc-bin libc6 openssl perl perl-base perl-modules
6 upgraded, 69 newly installed, 0 to remove and 48 not upgraded.
Need to get 51.7 MB of archives.
After this operation, 106 MB of additional disk space will be used.
Do you want to continue [Y/n]? yGet:1 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main perl i386 5.14.2-6ubuntu2.2 [3,695 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main perl-base i386 5.14.2-6ubuntu2.2 [1,480 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main perl-modules all 5.14.2-6ubuntu2.2 [3,391 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libc-bin i386 2.15-0ubuntu10.3 [1,131 kB]
Get:5 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libc6 i386 2.15-0ubuntu10.3 [3,940 kB]
Get:6 http://us.archive.ubuntu.com/ubuntu/ precise/main m4 i386 1.4.16-2ubuntu1 [195 kB]
Get:7 http://us.archive.ubuntu.com/ubuntu/ precise/main libfl-dev i386 2.5.35-10ubuntu3 [19.2 kB]
Get:8 http://us.archive.ubuntu.com/ubuntu/ precise/main flex i386 2.5.35-10ubuntu3 [216 kB]
Get:9 http://us.archive.ubuntu.com/ubuntu/ precise/main libgmp10 i386 2:5.0.2+dfsg-2ubuntu1 [264 kB]
Get:10 http://us.archive.ubuntu.com/ubuntu/ precise/main libgomp1 i386 4.6.3-1ubuntu5 [28.3 kB]
Get:11 http://us.archive.ubuntu.com/ubuntu/ precise/main libmpfr4 i386 3.1.0-3ubuntu2 [199 kB]
Get:12 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main mysql-common all 5.5.28-0ubuntu0.12.04.2 [13.5 kB]
Get:13 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libmysqlclient18 i386 5.5.28-0ubuntu0.12.04.2 [922 kB]
Get:14 http://us.archive.ubuntu.com/ubuntu/ precise/main libquadmath0 i386 4.6.3-1ubuntu5 [195 kB]
Get:15 http://us.archive.ubuntu.com/ubuntu/ precise/main libmpc2 i386 0.9-4 [40.7 kB]
Get:16 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main openssl i386 1.0.1-4ubuntu5.5 [519 kB]
Get:17 http://us.archive.ubuntu.com/ubuntu/ precise/main binutils i386 2.22-6ubuntu1 [2,385 kB]
Get:18 http://us.archive.ubuntu.com/ubuntu/ precise/main libbison-dev i386 1:2.5.dfsg-2.1 [33.2 kB]
Get:19 http://us.archive.ubuntu.com/ubuntu/ precise/main bison i386 1:2.5.dfsg-2.1 [275 kB]
Get:20 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libc-dev-bin i386 2.15-0ubuntu10.3 [77.7 kB]
Get:21 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main linux-libc-dev i386 3.2.0-34.53 [873 kB]
Get:22 http://us.archive.ubuntu.com/ubuntu/ precise-updates/main libc6-dev i386 2.15-0ubuntu10.3 [5,100 kB]
Get:23 http://us.archive.ubuntu.com/ubuntu/ precise/main cpp-4.6 i386 4.6.3-1ubuntu5 [4,659 kB]………………………………………………………………………………………………………………….Setting up libstdc++6-4.6-dev (4.6.3-1ubuntu5) …
Setting up g++-4.6 (4.6.3-1ubuntu5) …
Setting up g++ (4:4.6.3-1ubuntu5) …
update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode.
Setting up perl (5.14.2-6ubuntu2.2) …
Setting up libdpkg-perl (1.16.1.2ubuntu7) …
Setting up dpkg-dev (1.16.1.2ubuntu7) …
Setting up build-essential (11.5ubuntu2.1) …
Setting up libalgorithm-diff-perl (1.19.02-2) …
Setting up libalgorithm-diff-xs-perl (0.04-2build2) …
Setting up libalgorithm-merge-perl (0.08-2) …
Setting up libberkeleydb-perl (0.49-1) …
Setting up libnet-daemon-perl (0.48-1) …
Setting up libplrpc-perl (0.2020-2) …
Setting up libdbi-perl (1.616-1build2) …
Setting up libdbd-mysql-perl (4.020-1build2) …
Setting up libdbd-pg-perl (2.19.0-1) …
Setting up libencode-locale-perl (1.02-2) …
Setting up libhttp-date-perl (6.00-1) …
Setting up libfile-listing-perl (6.03-1) …
Setting up libfont-afm-perl (1.20-1) …
Setting up liburi-perl (1.59-1) …
Setting up libhtml-tagset-perl (3.20-2) …
Setting up libhtml-parser-perl (3.69-1build1) …
Setting up liblwp-mediatypes-perl (6.01-1) …
Setting up libhttp-message-perl (6.01-1) …
Setting up libhttp-daemon-perl (6.00-1) …
Setting up libhtml-tree-perl (4.2-1) …
Setting up libhttp-cookies-perl (6.00-2) …
Setting up libhttp-negotiate-perl (6.00-2) …
Setting up libnet-http-perl (6.02-1) …
Setting up libnet-ssleay-perl (1.42-1build1) …
Setting up libio-socket-ssl-perl (1.53-1) …
Setting up libwww-robotrules-perl (6.01-1) …
Setting up libwww-perl (6.03-1) …
Setting up libxml-parser-perl (2.41-1build1) …
Setting up libfrontier-rpc-perl (0.07b4-6) …
Setting up libhtml-form-perl (6.00-1) …
Setting up libhtml-format-perl (2.10-1) …
Setting up libsocket6-perl (0.23-1build2) …
Setting up libio-socket-inet6-perl (2.69-2) …
Setting up libmailtools-perl (2.08-1) …
Setting up libterm-readline-gnu-perl (1.20-2build1) …
Setting up liblwp-protocol-https-perl (6.02-1) …
Processing triggers for libc-bin …
ldconfig deferred processing now taking placeroot@ubuntu:~#
root@ubuntu:~#

 

2. Install mysql server

root@ubuntu:~# apt-get install mysql-server libmysqlclient-dev
Reading package lists… Done
Building dependency tree
Reading state information… Done
The following extra packages will be installed:
libhtml-template-perl mysql-client-5.5 mysql-client-core-5.5 mysql-server-5.5 mysql-server-core-5.5 zlib1g-dev
Suggested packages:
libipc-sharedcache-perl libterm-readkey-perl tinyca mailx
The following NEW packages will be installed:
libhtml-template-perl libmysqlclient-dev mysql-client-5.5 mysql-client-core-5.5 mysql-server mysql-server-5.5 mysql-server-core-5.5 zlib1g-dev
0 upgraded, 8 newly installed, 0 to remove and 48 not upgraded.
Need to get 26.0 MB of archives.
After this operation, 91.2 MB of additional disk space will be used.
Do you want to continue [Y/n]? yâââââââ⤠Configuring mysql-server-5.5 âââââââââ
â â
â â
â Repeat password for the MySQL “root” user: â
â â
â *********__________________________________ â
â â
â <Ok> â
â â
âââââââââââââââââââââââââââââââââââââââââââââââmysql start/running, process 8993
Setting up libhtml-template-perl (2.10-1) …
Setting up zlib1g-dev (1:1.2.3.4.dfsg-3ubuntu4) …
Setting up libmysqlclient-dev (5.5.28-0ubuntu0.12.04.2) …
Setting up mysql-server (5.5.28-0ubuntu0.12.04.2) …
root@ubuntu:~#

3. Download lastest Opensips package at  http://opensips.org/pub/opensips/latest/src/

root@ubuntu:/usr/src# wget http://opensips.org/pub/opensips/latest/src/opensips-1.8.2_src.tar.gz
–2012-12-07 20:20:48– http://opensips.org/pub/opensips/latest/src/opensips-1.8.2_src.tar.gz
Resolving opensips.org (opensips.org)… 78.46.64.50
Connecting to opensips.org (opensips.org)|78.46.64.50|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 4662465 (4.4M) [application/x-gzip]
Saving to: `opensips-1.8.2_src.tar.gz’19% [============================> ] 895,522 –.-K/s eta 3m 25s
100%[===========================================================================================================================================================>] 4,662,465 422K/s in 83s2012-12-07 20:22:12 (55.1 KB/s) – `opensips-1.8.2_src.tar.gz’ saved [4662465/4662465]root@ubuntu:/usr/src#
root@ubuntu:/usr/src#

4. Unzip that file and install to our server

root@ubuntu:/usr/src# tar zxvf opensips-1.8.2_src.tar.gzroot@ubuntu:/usr/src# cd opensips-1.8.2-tls/
root@ubuntu:/usr/src/opensips-1.8.2-tls# make allCompiling blacklists.c
Compiling core_stats.c
Compiling crc.c
Compiling daemonize.c
Compiling data_lump.c
Compiling data_lump_rpl.c
Compiling dprint.c
Compiling dset.c
Compiling errinfo.c
Compiling error.c
Compiling flags.c……………………..root@ubuntu:/usr/src/opensips-1.8.2-tls# make install

5. Create run folder for opensips process

root@ubuntu:/usr/src/opensips-1.8.2-tls# mkdir /var/run/opensips
root@ubuntu:/usr/src/opensips-1.8.2-tls#

6. Create deamon for OpenSIPs and add to startup

root@ubuntu:/usr/src/opensips-1.8.2-tls# cd packaging/debian
root@ubuntu:/usr/src/opensips-1.8.2-tls/packaging/debian# cp opensips.default /etc/default/opensips
root@ubuntu:/usr/src/opensips-1.8.2-tls/packaging/debian# cp opensips.init /etc/init.d/opensips
root@ubuntu:/usr/src/opensips-1.8.2-tls/packaging/debian# chmod +x /etc/init.d/opensips
root@ubuntu:/usr/src/opensips-1.8.2-tls/packaging/debian# useradd opensips
root@ubuntu:/usr/src/opensips-1.8.2-tls/packaging/debian# update-rc.d opensips defaults 99
Adding system startup for /etc/init.d/opensips …
/etc/rc0.d/K99opensips -> ../init.d/opensips
/etc/rc1.d/K99opensips -> ../init.d/opensips
/etc/rc6.d/K99opensips -> ../init.d/opensips
/etc/rc2.d/S99opensips -> ../init.d/opensips
/etc/rc3.d/S99opensips -> ../init.d/opensips
/etc/rc4.d/S99opensips -> ../init.d/opensips
/etc/rc5.d/S99opensips -> ../init.d/opensips
root@ubuntu:/usr/src/opensips-1.8.2-tls/packaging/debian#

root@ubuntu:/usr/src/opensips-1.8.2-tls/packaging/debian#vi /etc/default/opensips

Replace the RUN_OpenSIPS to Yes

root@ubuntu:/usr/src/opensips-1.8.2-tls/packaging/debian# vi /etc/init.d/opensips

Replace the line DAEMON=/usr/sbin/opensips to:
DAEMON=/usr/local/sbin/opensips

7.  OpenSIPs configuration (change IP listening on OpenSIPs)

 

vi /usr/local/etc/opensips/opensips.cfg#
# $Id: opensips.cfg 8758 2012-02-29 11:59:26Z vladut-paiu $
#
# OpenSIPS residential configuration script
# by OpenSIPS Solutions <team@opensips-solutions.com>
#
# This script was generated via “make menuconfig”, from
# the “Residential” scenario.
# You can enable / disable more features / functionalities by
# re-generating the scenario with different options.#
#
# Please refer to the Core CookBook at:
# http://www.opensips.org/Resources/DocsCookbooks
# for a explanation of possible statements, functions and parameters.
#
####### Global Parameters #########debug=3
log_stderror=no
log_facility=LOG_LOCAL0fork=yes
children=4/* uncomment the following lines to enable debugging */
#debug=6
#fork=no
#log_stderror=yes/* uncomment the next line to enable the auto temporary blacklisting of
not available destinations (default disabled) */
#disable_dns_blacklist=no/* uncomment the next line to enable IPv6 lookup after IPv4 dns
lookup failures (default disabled) */
#dns_try_ipv6=yes

/* comment the next line to enable the auto discovery of local aliases
based on revers DNS on IPs */
auto_aliases=no
listen=udp:127.0.0.1:5060 # CUSTOMIZE ME
listen=udp:192.168.11.35:5060

disable_tcp=yes

disable_tls=yes
####### Modules Section ########

#set module path
mpath=”/usr/local/lib/opensips/modules/”

#### SIGNALING module
loadmodule “signaling.so”

#### StateLess module
loadmodule “sl.so”

#### Transaction Module
loadmodule “tm.so”
modparam(“tm”, “fr_timer”, 5)
modparam(“tm”, “fr_inv_timer”, 30)
modparam(“tm”, “restart_fr_on_each_reply”, 0)
modparam(“tm”, “onreply_avp_mode”, 1)

#### Record Route Module
loadmodule “rr.so”
/* do not append from tag to the RR (no need for this script) */
modparam(“rr”, “append_fromtag”, 0)

#### MAX ForWarD module
loadmodule “maxfwd.so”

#### SIP MSG OPerationS module
loadmodule “sipmsgops.so”

#### FIFO Management Interface
loadmodule “mi_fifo.so”
modparam(“mi_fifo”, “fifo_name”, “/tmp/opensips_fifo”)
#### URI module
loadmodule “uri.so”
modparam(“uri”, “use_uri_table”, 0)
#### USeR LOCation module
loadmodule “usrloc.so”
modparam(“usrloc”, “nat_bflag”, 10)
modparam(“usrloc”, “db_mode”, 0)

#### REGISTRAR module
loadmodule “registrar.so”
modparam(“registrar”, “tcp_persistent_flag”, 7)

/* uncomment the next line not to allow more than 10 contacts per AOR */
#modparam(“registrar”, “max_contacts”, 10)

#### ACCounting module
loadmodule “acc.so”
/* what special events should be accounted ? */
modparam(“acc”, “early_media”, 0)
modparam(“acc”, “report_cancels”, 0)
/* by default we do not adjust the direct of the sequential requests.
if you enable this parameter, be sure the enable “append_fromtag”
in “rr” module */
modparam(“acc”, “detect_direction”, 0)
modparam(“acc”, “failed_transaction_flag”, 3)
/* account triggers (flags) */
modparam(“acc”, “log_flag”, 1)
modparam(“acc”, “log_missed_flag”, 2)

 

 
####### Routing Logic ########

# main request routing logic

route{

if (!mf_process_maxfwd_header(“10”)) {
sl_send_reply(“483″,”Too Many Hops”);
exit;
}

if (has_totag()) {
# sequential request withing a dialog should
# take the path determined by record-routing
if (loose_route()) {

if (is_method(“BYE”)) {
setflag(1); # do accounting …
setflag(3); # … even if the transaction fails
} else if (is_method(“INVITE”)) {
# even if in most of the cases is useless, do RR for
# re-INVITEs alos, as some buggy clients do change route set
# during the dialog.
record_route();
}

 

# route it out to whatever destination was set by loose_route()
# in $du (destination URI).
route(1);
} else {

if ( is_method(“ACK”) ) {
if ( t_check_trans() ) {
# non loose-route, but stateful ACK; must be an ACK after
# a 487 or e.g. 404 from upstream server
t_relay();
exit;
} else {
# ACK without matching transaction ->
# ignore and discard
exit;
}
}
sl_send_reply(“404″,”Not here”);
}
exit;
}

# CANCEL processing
if (is_method(“CANCEL”))
{
if (t_check_trans())
t_relay();
exit;
}

t_check_trans();

if ( !(is_method(“REGISTER”) ) ) {

if (from_uri==myself)

{

} else {
# if caller is not local, then called number must be local

if (!uri==myself) {
send_reply(“403″,”Rely forbidden”);
exit;
}
}

}

# preloaded route checking
if (loose_route()) {
xlog(“L_ERR”,
“Attempt to route with preloaded Route’s [$fu/$tu/$ru/$ci]”);
if (!is_method(“ACK”))
sl_send_reply(“403″,”Preload Route denied”);
exit;
}

# record routing
if (!is_method(“REGISTER|MESSAGE”))
record_route();

# account only INVITEs
if (is_method(“INVITE”)) {

setflag(1); # do accounting
}
if (!uri==myself) {
append_hf(“P-hint: outbound\r\n”);

route(1);
}

# requests for my domain

if (is_method(“PUBLISH|SUBSCRIBE”))
{
sl_send_reply(“503”, “Service Unavailable”);
exit;
}

if (is_method(“REGISTER”))
{

if ( 0 ) setflag(7);

if (!save(“location”))
sl_reply_error();

exit;
}

if ($rU==NULL) {
# request with no Username in RURI
sl_send_reply(“484″,”Address Incomplete”);
exit;
}

 

 

 

# do lookup with method filtering
if (!lookup(“location”,”m”)) {

t_newtran();
t_reply(“404”, “Not Found”);
exit;
}

 

# when routing via usrloc, log the missed calls also
setflag(2);
route(1);
}
route[1] {
# for INVITEs enable some additional helper routes
if (is_method(“INVITE”)) {

t_on_branch(“2”);
t_on_reply(“2”);
t_on_failure(“1”);
}

 

if (!t_relay()) {
send_reply(“500″,”Internal Error”);
};
exit;
}
branch_route[2] {
xlog(“new branch at $ru\n”);
}
onreply_route[2] {

xlog(“incoming reply\n”);
}
failure_route[1] {
if (t_was_cancelled()) {
exit;
}

# uncomment the following lines if you want to block client
# redirect based on 3xx replies.
##if (t_check_status(“3[0-9][0-9]”)) {
##t_reply(“404″,”Not found”);
## exit;
##}
}

 

 

8. Start OpenSIPs

root@ubuntu:/usr/src/opensips-1.8.2-tls/packaging/debian# /etc/init.d/opensips start
grep: /etc/opensips/opensips.cfg: No such file or directory
Starting opensips: opensipsListening on
udp: 127.0.0.1 [127.0.0.1]:5060
udp: 192.168.11.35 [192.168.11.35]:5060
Aliases:.
root@ubuntu:/usr/src/opensips-1.8.2-tls/packaging/debian#

That’s all. Thanks for using IThelpblog.

To be continued…..

 

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>