PHPMSSQL extension tutorial and linuxmssql_PHP tutorial are installed in Linux.

Source: Internet
Author: User
Install PHPMSSQL extension tutorial in Linux, linuxmssql. In the PHPMSSQL extension tutorial installed in Linux, linuxmssqlPHP naturally has good support for MySQL, but it takes some time to use PHP to operate SQLServer. Today, the team just installed the php mssql extension tutorial in Linux, linuxmssql

PHP naturally has good support for MySQL, but it takes some time to operate SQL Server with PHP. Today, a project in the team needs to use PHP to operate SQL Server, so we can help you configure the environment.

The system version of the Server is SUSE Linux Enterprise Server 10 SP3.

1. install FreeTDS

Address: FreeTDS

The code is as follows:


Wget http://ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz
Tar zxvf freetds-stable.tgz
Cd freetds-0.82
./Configure -- prefix =/usr/local/freetds -- with-tdsver = 8.0 -- enable-msdblib -- enable-dbmfix
Make & make install


After successful installation, it is best to update the dynamic connection library cache:

The code is as follows:


Echo "/usr/local/freetds/lib">/etc/ld. so. conf
Ldconfig

2. configure FreeTDS and test the connection

The configuration file of FreeTDS is placed in The etc directory of the installation directory. according To The configure parameter in step 1, we install FreeTDS in/usr/local/freetds:

The code is as follows:


Vim/usr/local/freetds/etc/freetds. conf

It is not clear which configuration items of FreeTDS can be used here, but an important configuration is provided to solve Chinese garbled characters. Add the following statement to the configuration file:

The code is as follows:


Client charset = utf8

Then, we use the tsql command to test whether the database can be connected to the SQL Server database normally:

The code is as follows:


Cd/usr/local/freetds/bin
./Tsql-H 192.168.0.254-p 1433-U sa-P 123456

If the connection is normal, the following statement should be displayed:

The code is as follows:


Locale is "zh_CN.UTF-8"
Locale charset is "UTF-8"
1>

3. install mssql extension for php

The php version on the server is 5.3.13. php has been installed in/usr/local/services/php, and the extended directory is/usr/local/services/php/extensions. The following describes how to install the mssql extension:

The code is as follows:


Cd php-5.3.13/ext/mssql/
/Usr/local/services/php/bin/phpize
./Configure -- with-php-config =/usr/local/services/php/bin/php-config -- with-mssql =/usr/local/freetds

Make # generate the extension file and place it in the module folder of the current directory.
Cp modules/mssql. so/usr/local/services/php/extensions/# Copy the extension file to the extension directory of PHP

4. configure php. ini and verify the installation result.

Open php. ini and add the following extension statement:

The code is as follows:


Extension = mssql. so

After the PHP service is restarted (php-fpm is used on the Server), print phpinfo. the following configuration indicates that php can operate SQL Server normally.


In linux, I installed apache and php, but php forgot to install the mssql extension. how can I complete the mssql extension?

1. you can solve this problem by installing unixODBC on your own.
2. linux security restrictions may be imposed.
SELINUX = enforce
Change to: SELINUX = disabled
3. mssql restrictions may not allow remote logon

How to install other extension models after installing php in linux

Some modules also need to re-compile php. It's not as simple as modifying php. ini.
 

In the extended tutorial of MSSQL, linuxmssql PHP naturally has good support for MySQL. However, it takes some time to use PHP to operate SQL Server. Today is just in the team...

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.