How to Implement opensips user authentication using mysql in ubuntu

Source: Internet
Author: User

1. MySQL support

1.1 MySQL module support

By default, the MySQL module is not included.

The opensipsctlrc file contains the database configuration information. To enable opensips to support mysql databases

It is necessary to support the mysql module. The method is as follows:

(1) Modify Makefile. conf in opensips and remove db_mysql from exclude_modules. In include_modules

Add db_mysql and re-compile and install it. You can add supported modules in this way.

(2) make sure de_modules = "db_mysql" modules prefix = /.

Before compilation and installation, install the mysql development kit. The method is as follows:

$ Sudo apt-get install libmysqlclient-dev.

2.2 install MySQL

Before using sudo opensipsdbctl create to create a database, make sure that mysql is installed. The installation method is as follows:

$ Sudo apt-get install mysql-server mysql-client

During installation, the system prompts you to enter the mysql root User Password. Run the following command to test whether mysql is successfully installed:

$ Sudo mysql-p enter the root password just set

The MySQL URL format is as follows:

Mysql: // username: password @ domain/dbname

2.3 create an opensips Database

Use the sudo opensipsdbctl create command to create a database. In this process, enter the password of the root user of the MySQL database,

The password entered in the previous step. Then there are some additional tables for you to choose whether to create them. After selection, the opensips database is successfully created.

/Sbin/opensipsdbctl is a shell script. You can read its code to see how the database is created. First,

It will include the/etc/opensips/opensipsctlrc configuration file, and then create a database based on the configuration file.

The opensipsdbctl. base File and opensipsdbctl. mysql file in/lib/opensips/opensipsctl.

You can go to the opensips database to check which tables are available and use the subscriber table for user authentication.

2. User Authentication Configuration

The previous section describes how to enable opensips to support MySQL databases. User authentication is completed on the basis of the previous section.

The main work of this part is to modify the opensips configuration file, including the opensips. cfg and opensipsctlrc files. In the configuration file opensips. cfg

Modify the global variables, load the dynamic database db_mysql.so, auth. so, and auth_db.so, configure the relevant parameters, modify the routing policy, and configure the file

Some parameters need to be modified in opensipsctlrc.

The configuration file opensips. cfg is as follows:

Http://www.jb51.net/article/35752.htm

A lot of information is found on the Internet during the configuration process. Usually, the configuration file can be checked but opensips cannot be run.

Have they actually practiced it!

Finally, I decided to read the official instructions, such as the English PDF of opensips mysql installation and the INSTALL file in the opensips source package.

The INSTALL file only describes the configuration code to be added to the opensips. cfg file, but does not provide detailed instructions on where to add these statements, and

It seems that there are still errors. You cannot use break, but exit. The location of opensips mysql installation is described in PDF,

Configure according to your actual situation.

After the configuration is complete, check whether the syntax of the configuration file is correct. The command is as follows:

$ Sudo opensips-c

Run the following command to start opensips after the check is passed:

$ Sudo opensipsctl start

If an error occurs during startup, view the system log to learn the specific cause and solve the problem accordingly.

$ Vim/var/log/syslog

3 Test

Add a SIP User:

Syntax: opensipsctl add <username> <password>

Opensipsctl add alice@192.168.139.121 123456

Opensipsctl add bob@192.168.139.121 123456

Then download the SIP client for testing!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.