您现在的位置是:PHP7增加mssql支持(sqlsrv、pdo_sqlsrv)

PHP7增加mssql支持(sqlsrv、pdo_sqlsrv)

分类: PHP 日期:2020-06-09点击:2423

cd ~ 

php -m | grep mssql #查看是否有mssql支持
wget http://pecl.php.net/get/pdo_sqlsrv-5.3.0.tgz
tar -zxvf pdo_sqlsrv-5.3.0.tgz
/usr/local/php/bin/phpize
cd pdo_sqlsrv-5.3.0
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install

php.ini中添加extension="pdo_sqlsrv.so",重启服务。


同理,安装sqlsrv。http://pecl.php.net/get/sqlsrv-5.3.0.tgz


----------------------------------------------------------------------
Libraries have been installed in:
   /root/pdo_sqlsrv-5.3.0/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/

#php.ini 增加以下内容
extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/pdo_sqlsrv.so



测试mssql支持


[root@localhost ~]# php -m | grep sql
mysqli
mysqlnd
pdo_mysql
pdo_sqlite
pdo_sqlsrv
sqlite3



安装过程中报错  unrecognized command line option "-std=c++11"

原因是gcc++版本不够


g++ --version
g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

gcc++升级,详见另一篇文章


标签: PHP MSSQL

站长简介

    姓名:喻理
    微信:yuli0927
    邮箱:yuli0927@126.com
    不懂业务的运维工程师不是一个好程序员。

分类

最新文章

热门文章

全站标签