当前位置:网站首页>Installing sqlserver extension PDO of PHP under Linux_ sqlsrv

Installing sqlserver extension PDO of PHP under Linux_ sqlsrv

2022-06-24 12:28:00 Mongolia Shangdan 2

1. Set up yum Install source

curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssqlrelease.repo

2. Install dependent components

yum -y install msodbcsql mssql-tools unixODBC-devel

There is a risk of mistakes , Follow the instructions , It can be solved by adding parameters :

yum -y --disablerepo=packages-microsoft-com-prodyum install yum --disablerepo=packages-microsoft-com-prod msodbcsql mssql-tools unixODBC-devel

3. Download installation package

The choice here is 5.6.1 edition

wget http://pecl.php.net/get/pdo_sqlsrv-5.6.1.tgz

4. install

First decompress

tar -xvf pdo_sqlsrv-5.6.1.tgz
cd pdo_sqlsrv-5.6.1

The following execution path is based on your own php Path modification :

/usr/local/services/php-7.2/bin/phpize
./configure --with-php-config=/usr/local/services/php-7.2/bin/php-config
make && make install

After installation , The system will prompt you for the installation path , For example, my execution result is :

Installing shared extensions:     /usr/local/services/php-7.2/lib/php/extensions/no-debug-non-zts-20170718/

5. modify php.ini

Find you. php.ini route , Usually in php In the directory of etc/php.ini. My is

/usr/local/services/php-7.2/etc/php.ini

Add a line at the end of the file :

extension=pdo_sqlsrv.so

6. verification

There are two ways to verify , One is to write a php file , Then check it out php Information :

<?php
phpinfo();

If the displayed results show pdo_sqlsrv It means that it can operate normally

Another way is to execute the command :

/usr/local/services/php-7.2/bin/php --ri pdo_sqlsrv

The following results will be printed :

pdo_sqlsrv

pdo_sqlsrv support => enabled
ExtensionVer => 5.6.1

Directive => Local Value => Master Value
pdo_sqlsrv.log_severity => 0 => 0
pdo_sqlsrv.client_buffer_max_kb_size => 10240 => 10240

This means that the extension can run normally .

原网站

版权声明
本文为[Mongolia Shangdan 2]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/06/20210601180749362P.html

随机推荐