Skip to main content

Install on Debian Opensip

add opensips-cli

curl https://apt.opensips.org/opensips-org.gpg -o /usr/share/keyrings/opensips-org.gpg
echo "deb [signed-by=/usr/share/keyrings/opensips-org.gpg] https://apt.opensips.org bookworm cli-nightly" >/etc/apt/sources.list.d/opensips-cli.list

add opensips 

curl https://apt.opensips.org/opensips-org.gpg -o /usr/share/keyrings/opensips-org.gpg
echo "deb [signed-by=/usr/share/keyrings/opensips-org.gpg] https://apt.opensips.org bookworm 3.5-releases" >/etc/apt/sources.list.d/opensips.list

this will add new source lists to download opensips and components

sudo apt update

sudo apt install opensips

sudo apt install opensips-cli

sudo apt install opensips-mysql-module

or install all modules by doing apt install opensips*

systemctl start opensps

systemctl status opensips

root@opensips:~# systemctl start opensips
root@opensips:~# systemctl status opensips
● opensips.service - OpenSIPS is a very fast and flexible SIP (RFC3261) server
     Loaded: loaded (/lib/systemd/system/opensips.service; enabled; preset: enabled)
     Active: active (running) since Wed 2025-02-12 00:23:01 CST; 1s ago
       Docs: man:opensips
    Process: 15897 ExecStart=/usr/sbin/opensips -P /run/opensips/opensips.pid -f /etc/opensips/opensips.cfg -m $S_MEMORY -M $P_MEMORY $OPTIONS (code=exited, status=0/SUCCESS)
   Main PID: 15899 (opensips)
      Tasks: 9 (limit: 2305)
     Memory: 9.4M
        CPU: 28ms
     CGroup: /system.slice/opensips.service
             ├─15899 /usr/sbin/opensips -P /run/opensips/opensips.pid -f /etc/opensips/opensips.cfg -m 64 -M 4
             ├─15900 /usr/sbin/opensips -P /run/opensips/opensips.pid -f /etc/opensips/opensips.cfg -m 64 -M 4
             ├─15901 /usr/sbin/opensips -P /run/opensips/opensips.pid -f /etc/opensips/opensips.cfg -m 64 -M 4
             ├─15902 /usr/sbin/opensips -P /run/opensips/opensips.pid -f /etc/opensips/opensips.cfg -m 64 -M 4
             ├─15903 /usr/sbin/opensips -P /run/opensips/opensips.pid -f /etc/opensips/opensips.cfg -m 64 -M 4
             ├─15904 /usr/sbin/opensips -P /run/opensips/opensips.pid -f /etc/opensips/opensips.cfg -m 64 -M 4
             ├─15905 /usr/sbin/opensips -P /run/opensips/opensips.pid -f /etc/opensips/opensips.cfg -m 64 -M 4
             ├─15906 /usr/sbin/opensips -P /run/opensips/opensips.pid -f /etc/opensips/opensips.cfg -m 64 -M 4
             └─15907 /usr/sbin/opensips -P /run/opensips/opensips.pid -f /etc/opensips/opensips.cfg -m 64 -M 4

Feb 12 00:23:01 opensips /usr/sbin/opensips[15899]: INFO:core:evi_publish_event: Registered event <E_UL_LATENCY_UPDATE(12)>
Feb 12 00:23:01 opensips /usr/sbin/opensips[15899]: INFO:registrar:mod_init: initializing...
Feb 12 00:23:01 opensips /usr/sbin/opensips[15899]: INFO:acc:mod_init: initializing...
Feb 12 00:23:01 opensips /usr/sbin/opensips[15899]: INFO:core:evi_publish_event: Registered event <E_ACC_EVENT(13)>
Feb 12 00:23:01 opensips /usr/sbin/opensips[15899]: INFO:core:evi_publish_event: Registered event <E_ACC_CDR(14)>
Feb 12 00:23:01 opensips /usr/sbin/opensips[15899]: INFO:core:evi_publish_event: Registered event <E_ACC_MISSED_EVENT(15)>
Feb 12 00:23:01 opensips /usr/sbin/opensips[15899]: INFO:core:mod_init: initializing UDP-plain protocol
Feb 12 00:23:01 opensips /usr/sbin/opensips[15899]: INFO:core:evi_publish_event: Registered event <E_CORE_LOG(16)>
Feb 12 00:23:01 opensips opensips[15897]: INFO:core:daemonize: pre-daemon process exiting with 0
Feb 12 00:23:01 opensips systemd[1]: Started opensips.service - OpenSIPS is a very fast and flexible SIP (RFC3261) server.

We also need to install apache, sql and php

apt install -y apache2

apt install -y php php-curl php-gd php-pear php-cli php-mysql php-apcu

apt install libapache2-mod-php unzip

now install mysql 

wget https://dev.mysql.com/get/mysql-apt-config\_0.8.30-1\_all.deb

$ sudo apt install ./mysql-apt-config_0.8.30-1_all.deb

image.png

image.png

image.png

now sudo apt update

sudo apt install mysql-server

csr@opensips:~$ sudo systemctl status mysql
● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; preset: enabled)
     Active: active (running) since Wed 2025-02-12 00:43:39 CST; 1min 49s ago
       Docs: man:mysqld(8)
             http://dev.mysql.com/doc/refman/en/using-systemd.html
   Main PID: 1941 (mysqld)
     Status: "Server is operational"
      Tasks: 34 (limit: 2305)
     Memory: 438.0M
        CPU: 1.350s
     CGroup: /system.slice/mysql.service
             └─1941 /usr/sbin/mysqld

Feb 12 00:43:38 opensips systemd[1]: Starting mysql.service - MySQL Community Server...
Feb 12 00:43:39 opensips systemd[1]: Started mysql.service - MySQL Community Server.

cd /var/www/html;

wget https://github.com/OpenSIPS/opensips-cp/archive/master.zip;

unzip master.zip;

mv opensips-cp-master opensips-cp

chown -R www-data:www-data /var/www/html/opensips-cp/;

Setup a Backup Point to restore if database fail

mysql -Dopensips -p < /var/www/html/opensips-cp/config/db_schema.mysql;

cp /var/www/html/opensips-cp/config/tools/system/smonitor/opensips_stats_cron /etc/cron.d/

Create database using opensips-cli

Creating the Database

In order to create the database_name database that you have provisioned above, run

opensips-cli -x database create

Later, if you decide to add a new module, for example presence, simply call:

opensips-cli -x database add presence

You can also specify a different name for the database, for example opensips_test, using:

opensips-cli -x database create opensips_test

mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.4.4 MySQL Community Server - GPL

Copyright (c) 2000, 2025, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> use opensips
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> desc ocp_admin_privileges;
+-----------------+--------------+------+-----+---------+----------------+
| Field           | Type         | Null | Key | Default | Extra          |
+-----------------+--------------+------+-----+---------+----------------+
| id              | int unsigned | NO   | PRI | NULL    | auto_increment |
| first_name      | varchar(64)  | NO   |     |         |                |
| last_name       | varchar(64)  | NO   |     |         |                |
| username        | varchar(64)  | NO   |     |         |                |
| password        | varchar(64)  | NO   |     |         |                |
| ha1             | varchar(256) | YES  |     |         |                |
| blocked         | varchar(60)  | YES  |     | NULL    |                |
| failed_attempts | int          | YES  |     | 0       |                |
| available_tools | varchar(512) | NO   |     |         |                |
| permissions     | varchar(512) | YES  |     | NULL    |                |
| secret          | varchar(20)  | YES  |     | NULL    |                |
+-----------------+--------------+------+-----+---------+----------------+
11 rows in set (0.01 sec)

mysql -p -e "CREATE USER 'opensips'@'localhost' IDENTIFIED BY 'opensips';" (if you modify the password here you need to  update the file /var/www/html/opensips-cp/config/db.inc.php and add the password for database connection here)

mysql -p -e "GRANT ALL PRIVILEGES ON opensips.* TO 'opensips'@'localhost';"
mysql -p -e "FLUSH PRIVILEGES;"  

 mysql -p -e "CREATE USER 'admin'@'localhost' IDENTIFIED BY 'Admin123';"
 mysql -p -e "GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost';"
 mysql -p -e "FLUSH PRIVILEGES;"

systemctl restart cron

modify /etc/apache2/sites-available/000-default.conf

root@opensips:/etc/apache2/sites-available 000-default.conf 
<VirtualHost *:80>
	#ServerName www.example.com

	ServerAdmin webmaster@localhost
	DocumentRoot /var/www/html
	ErrorLog ${APACHE_LOG_DIR}/error.log
	CustomLog ${APACHE_LOG_DIR}/access.log combined
	
	<Directory /var/www/html/opensips-cp/web>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride None
		Require all granted
	</Directory>

	<Directory> /var/www/html/opensips-cp>
		Options Indexes FollowSymLinks MultiViews
		AllowOverride None
		Require all denied
	</Directory>

	Alias /cp /var/www/html/opensips-cp/web

	<DirectoryMatch "/var/www/html/opensips-cp/web/tools/.*/.*/(template|custom_actions|lib)/">
		Require all denied
	</DirectoryMatch>


</VirtualHost>

Restart Apache2 and test by loging into http://x.x.x.x/cp

More on SQL

mysql> use opensips
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> CREATE USER 'cesar'@'%' IDENTIFIED BY 'Cesar123';
Query OK, 0 rows affected (0.02 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'cesar'@'%';
Query OK, 0 rows affected (0.01 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)

mysql> use opensips
Database changed
mysql> SELECT * FROM accounts WHERE username = 'admin';
ERROR 1146 (42S02): Table 'opensips.accounts' doesn't exist
mysql> SELECT * FROM accountsSELECT * FROM ocp_admin_privileges WHERE username = 'admin'; WHERE username = 'admin';
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '* FROM ocp_admin_privileges WHERE username = 'admin'' at line 1
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE username = 'admin'' at line 1
mysql> SELECT * FROM ocp_admin_privileges WHERE username = 'admin';
+----+------------+-----------+----------+----------+----------------------------------+---------+-----------------+-----------------+-------------+--------+
| id | first_name | last_name | username | password | ha1                              | blocked | failed_attempts | available_tools | permissions | secret |
+----+------------+-----------+----------+----------+----------------------------------+---------+-----------------+-----------------+-------------+--------+
|  1 | Super      | Admin     | admin    | opensips | 0273461fc6bf55340b21e41b9adc41bf | NULL    |               0 | all             | all         | NULL   |
+----+------------+-----------+----------+----------+----------------------------------+---------+-----------------+-----------------+-------------+--------+
1 row in set (0.00 sec)

mysql> SELECT * FROM ocp_admin_privileges WHERE username = 'Cesar';
Empty set (0.00 sec)

mysql> SELECT * FROM ocp_admin_privileges WHERE username = 'cesar';
Empty set (0.00 sec)

mysql> INSERT INTO ocp_admin_privileges (first_name, last_name, username, password, ha1, blocked, failed_attempts, available_tools, permissions, secret)
   -> VALUES ('Cesar', 'User', 'cesar', 'opensips', MD5('opensips'), NULL, 0, 'all', 'all', NULL);
Query OK, 1 row affected (0.01 sec)

mysql> SELECT * FROM ocp_admin_privileges WHERE username = 'cesar';
+----+------------+-----------+----------+----------+----------------------------------+---------+-----------------+-----------------+-------------+--------+
| id | first_name | last_name | username | password | ha1                              | blocked | failed_attempts | available_tools | permissions | secret |
+----+------------+-----------+----------+----------+----------------------------------+---------+-----------------+-----------------+-------------+--------+
|  2 | Cesar      | User      | cesar    | opensips | bd1146b4cfa503eb2c1056b693377f30 | NULL    |               0 | all             | all         | NULL   |
+----+------------+-----------+----------+----------+----------------------------------+---------+-----------------+-----------------+-------------+--------+
1 row in set (0.00 sec)

mysql> SELECT * FROM ocp_admin_privileges;
+----+------------+-----------+----------+----------+----------------------------------+---------+-----------------+-----------------+-------------+--------+
| id | first_name | last_name | username | password | ha1                              | blocked | failed_attempts | available_tools | permissions | secret |
+----+------------+-----------+----------+----------+----------------------------------+---------+-----------------+-----------------+-------------+--------+
|  1 | Super      | Admin     | admin    | opensips | 0273461fc6bf55340b21e41b9adc41bf | NULL    |               0 | all             | all         | NULL   |
|  2 | Cesar      | User      | cesar    | opensips | bd1146b4cfa503eb2c1056b693377f30 | NULL    |               0 | all             | all         | NULL   |
+----+------------+-----------+----------+----------+----------------------------------+---------+-----------------+-----------------+-------------+--------+
2 rows in set (0.00 sec)

mysql> SHOW TABLES;
+----------------------+
| Tables_in_opensips   |
+----------------------+
| config               |
| ocp_admin_privileges |
| ocp_boxes_config     |
| ocp_dashboard        |
| ocp_db_config        |
| ocp_extra_stats      |
| ocp_monitored_stats  |
| ocp_monitoring_stats |
| ocp_system_config    |
| ocp_tools_config     |
+----------------------+
10 rows in set (0.00 sec)

mysql> exit
Bye