Php+mssql Remote connection under CENTOS7

Source: Internet
Author: User
Tags install php log log mssql server php source code

MSSQL remote connection needs to do a lot of configuration on the SQL Server side, here first skip, here only the Linux server configuration.

CENTOS7 first needs to install FreeTDS, a class library that provides the ability to access SQL Server from Linux. Both the MSSQL and the pdo-mssql of PHP need to be connected to SQL Server via FreeTDS.

Installation is simple:

http://www.freetds.org/download, Download complete tar, then configure make && make install, this is the old routine, the only thing to note is the Configure parameter

./configure--prefix=/usr/local/freetds--enable-msdblib--with-tdsver=8.0

--with-tdsver This can not be lost, different FreeTDS versions connect SQL Server ports,--enable-msdblib is the required option to install Php-mssql.

After the installation is complete Cd/usr/local/freetds/etc,vim freetds.conf, add an MSSQL server settings, the above has an example, is also very simple,

Note that the following are:

dump file =/tmp/freetds.log "#前面的冒号去掉, open this log

TDS Version = 7.1 #我设置的是7.1, open log log to see, the connection is 1433 port, set 8.0, the connection is not 1433 port, you can try it yourself

Remember the name of the new setting, which will be used later. For example:

[Yunda]
Host = xxx.xxx.xxx.xxx
Port = 1433
TDS Version = 7.1

This Yunda is the name to be used in the back.

Down to install PHP's MSSQL extension, no source code to find a PHP version of the same source of code download down.

Enter the source code directory/ext/mssql directory.

/usr/bin/php/phpize

./configure--with-php-config=/opt/lampp/bin/php-config--with-mssql=/usr/local/freetds/

Make && make install

Note that this php-config is not the location of your PHP configuration file php.ini, this is the location of the Php-config file.

and add the mssql.so to the php.ini.

echo extension=mssql.so >>/opt/lampp/etc/php.ini

Restart the service is OK, at the time of the connection is filled

Mssql_connect ("Yunda", "sa", "xxxxxxx")

If you want to connect dblib, go to PHP source code directory Php-dblib

/opt/lampp/bin/phpize./configure--with-php-config=/opt/lampp/bin/php-config--with-pdo-dblib=/usr/local/freetds /make && make install Cp/opt/lampp/php-5.5.24/ext/pdo_dblib/modules/pdo_dblib.so/usr/lib64/php/modules/pdo _dblib.so echo extension=pdo_dblib.so >>/opt/lampp/etc/php.ini Restart Service

Php+mssql Remote connection under CENTOS7

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.