openSIPS is a multi-purpose SIP server that is used by many telephony service providers and offers Class 4, Class 5, wholesale VoIP, enterprise PBX, virtual PBX, SBC, load balancing IMS platforms, call centers features and more. In this article, you can find the installation steps of openSIPS on Debian 10.
openSIPS is a high performance SIP server running on Linux that needs very little resources. Therefore, many telecom operators develop solutions with openSIPS. If you want to use openSIPS in your VoIP applications, you can follow the installation instructions below.
openSIPS Installation Steps
1. Components Used in openSIPS Installation & Versions:
- Debian v10 (Buster) x64 minimal install (netinst)
- OpenSips v3.0
- OpenSips GUI v8.3.0
- Apache v2.4
- PHP v7.3
- MariaDB v10
2. Pre Installation Tasks
To install openSIPS, you will first need a fresh Debian installation. You can download and install the amd64 netinst CD image from this link. Debian is very easy to install, you can also install it by following this video that I prepared.
After installing Debian, complete the installation of the following packages:
apt update && apt upgrade -y && apt -y install m4 git nano sudo curl dbus apache2 lsb-release
Normally, you can install the “monit” package as an option for monitoring, but at the time I wrote the article, it was removed from debian repos due to some vulnerabilities on the monit package. In case the situation changes, you can find the related setup command below:
apt -y install monit
3. PHP Installation
First install dependencies:
apt -y install curl apt-transport-https ca-certificates
Add PHP repo:
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > \ /etc/apt/sources.list.d/php.list
After that, install PHP packages:
apt update && apt -y install php7.3 php7.3-gd php7.3-mysql php7.3-xmlrpc php-pear php7.3-cli php-apcu php7.3-curl php7.3-xml libapache2-mod-php7.3
Install PHP MDB2 library with pear:
pear install MDB2#mysql
Edit PHP.ini file and change short_open_tag variable to On:
sed -i "s#short_open_tag = Off#short_open_tag = On#g" /etc/php/7.3/apache2/php.ini
4. MariaDB Installation
Get gpg keys needed for MariaDB repo and install necessary packages:
apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8 curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash apt update && apt -y install mariadb-server
After that edit my.cnf file as below:
nano /etc/mysql/my.cnf
To disable Strict mode and use default openSIPS latin1 character set, add these lines under [mysqld] header:
sql_mode='' character-set-server = latin1
Restart MariaDB service:
systemctl restart mariadb
5. openSIPS Installation
Add gpg key:
apt -y install dirmngr && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 049AD65B
Add openSIPS repos:
echo "deb https://apt.opensips.org $(lsb_release -sc) 3.0-releases" >/etc/apt/sources.list.d/opensips.list echo "deb https://apt.opensips.org $(lsb_release -sc) cli-nightly" >/etc/apt/sources.list.d/opensips-cli.list
Install openSIPS packages:
apt update && apt -y install opensips opensips-cli opensips-*-module opensips-*-modules python3-mysqldb python3-sqlalchemy python3-sqlalchemy-utils
6. Database Installation
Create opensips user on MariaDB and grant rights:
mysql -p > CREATE USER 'opensips'@'localhost' IDENTIFIED BY 'opensipsrw'; GRANT ALL PRIVILEGES ON opensips.* TO 'opensips'@'localhost'; FLUSH PRIVILEGES; exit
Run database installation script:
opensips-cli -x database create
The script will ask you the database URL. Enter mysql://opensips:opensipsrw@localhost and choose default (install all tables).
7. Generating Configuration File
Run configuration generator script to generate configuration file:
/usr/sbin/osipsconfig
Choose GenerateOpenSIPS Script > Residential Script > Configure Residential Script. Choose all items other than TLS by using space bar. Use Q to go to previous menu and schoose Generate Residential Script. Script will generate a configuration file and will promt the file name on screen. Replace opensips.cfg file with the generated one and give necessary rights:
mv /etc/opensips/opensips.cfg /etc/opensips/opensips.cfg.orig cp /etc/opensips/[üretilen konfig dosyası] /etc/opensips/opensips.cfg chmod 644 /etc/opensips/opensips.cfg
8. Additional Configurations:
Write server IP address in opensips.cfg file:
nano /etc/opensips/opensips.cfg
write server IP addresses in two lines starting with listen= :
listen=udp:192.168.0.1:5060 listen=tcp:192.168.0.1:5060
Then check if the configuration file is valid or not:
opensips -C /etc/opensips
If there is an error in the file, it will appear on the screen. Correct the errors, otherwise run the opensips service with the new configuration file by using the following command:
systemctl restart opensips
9. GUI Installation
Download openSIPS GUI via git:
git clone -b 8.3.0 https://github.com/OpenSIPS/opensips-cp.git /var/www/opensips-cp
Create openSIPS GUI table on database:
cd /var/www/opensips-cp/config mysql -p opensips < db_schema.mysql
10. Regular Collection of Statistics
Add the necessary script into cron.d folder and restart cron service:
cd /var/www/opensips-cp/config cp tools/system/smonitor/opensips_stats_cron /etc/cron.d/ systemctl restart cron
11. Monit Configuration (Optional)
Add the necessary line into monitrc file and restart monit service:
echo -e "set httpd port 2812 and\nallow localhost" >> /etc/monit/monitrc systemctl restart monit
12. Global Configurations
Open GUI config PHP file and edit as follows:
nano +30 /var/www/opensips-cp/config/boxes.global.inc.php
// monit host:port $boxes[$box_id]['monit']['conn']="127.0.0.1:2812"; $boxes[$box_id]['monit']['user']="admin"; $boxes[$box_id]['monit']['pass']="admin"; $boxes[$box_id]['monit']['has_ssl']=0;
13. Apache Configuration
Define Virtual Hosts on Apache by using the commands below:
cat >> /etc/apache2/sites-available/opensips.conf << EOF <VirtualHost *:80> DocumentRoot /var/www/opensips-cp <Directory /var/www/opensips-cp/web> Options Indexes FollowSymLinks MultiViews AllowOverride None Require all granted </Directory> <Directory /var/www/opensips-cp> Options Indexes FollowSymLinks MultiViews AllowOverride None Require all denied </Directory> Alias /cp /var/www/opensips-cp/web <DirectoryMatch "/var/www/opensips-cp/web/tools/.*/.*/(template|custom_actions|lib)/"> Require all denied </DirectoryMatch> </VirtualHost> EOF
Disable default site, enable openSIPS GUI site, change owner of the folder and restart Apache:
a2dissite 000-default a2ensite opensips chown -R www-data. /var/www/opensips-cp systemctl restart apache2
Finally the installation is finished. Use http://ipadress/cp URL with admin / opensips credentials to access openSIPS GUI.