msphpsql: install error on CENTOS
+## Driver version or file name +Please tell us what the PHP driver version or file name is.
- 7.2
+## SQL Server version +Please tell us what the SQL Server version is.
- 17
+## Client operating system +Please tell us what oprating system the client program is running on. 3.10.0-693.el7.x86_64 GNU/Linux
+## PHP version +Please tell us which version of PHP you are running.
- 7.2
+## Microsoft ODBC Driver version +Please tell us which version of the Microsoft ODBC Driver you are using.
- 17
+## Table schema +Please tell us the table schema
- dbo
+## Problem description i got the following error:
PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_sqlsrv.so' (tried: /usr/lib64/php/modules/pdo_sqlsrv.so (/usr/lib64/php/modules/pdo_sqlsrv.so: undefined symbol: php_pdo_register_driver), /usr/lib64/php/modules/pdo_sqlsrv.so.so (/usr/lib64/php/modules/pdo_sqlsrv.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning: PHP Startup: sqlsrv: Unable to initialize module
Module compiled with module API=20160303
PHP compiled with module API=20170718
These options need to match
in Unknown on line 0
PHP Warning: PHP Startup: pdo_sqlsrv: Unable to initialize module
Module compiled with module API=20160303
PHP compiled with module API=20170718
These options need to match
in Unknown on line 0
PHP Warning: PHP Startup: sqlsrv: Unable to initialize module
Module compiled with module API=20160303
PHP compiled with module API=20170718
These options need to match
in Unknown on line 0
PHP 7.2.4 (cli) (built: Mar 27 2018 17:23:35) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.4, Copyright (c) 1999-2018, by Zend Technologies
this happens even if i type the command php -v on command line
+Please share more details with us.
+## Expected behavior and actual behavior
+Please tell us what should happen and what happened instead
sqlcmd should work as expected when i try a connection with my database, and my application (with php) still got errors unable of find the sql driver:
could not find driver
+## Repro code +Please share repro code with us, or tell us how to reproduce the issue.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 33 (15 by maintainers)
That looks correct. Simply do the same for pdo_sqlsrv and you should have both drivers installed and functioning.
My apologies, that command is not needed for CentOS. You can leave it out entirely.
Hi @leandroruel it looks like you are downloading or compiling the extensions for PHP 7.1 but using PHP 7.2. That’s the probable cause of the
These options need to matcherror. How did you install PHP? And how did you install the sqlsrv/pdo_sqlsrv extensions?Please see the full install instructions here. The instructions for CentOS are almost identical to the ones for Red Hat, except that the command
should be replaced with
Please try these instructions and let us know if the problem is fixed.
@zan182 create a new issue
It may be inside your network, but if you are trying to connect to a named instance, you need to specify the port number (the default is 1433):
server\instancename,1433.Also, is there any particular reason you are using version 11 of the driver? The latest is version 17 and fixes many bugs, including network connection bugs. Instructions for installing the latest are here.
Okay, I think what has happened is, you compiled the latest version of the drivers under PHP 7.1, and PECL won’t let you rebuild them for 7.2 because they are the latest version. You need to remove the existing modules sqlsrv.so and pdo_sqlsrv.so (which are probably in
/usr/lib64/php/modules/) and then try installing with PECL again. TrySomewhere on your system you have the modules built for PHP 7.1. Have you built the modules with PECL, as follows?
Please try this and let us know if it works.
sqlcmd is separate from the sqlsrv/pdo_sqlsrv drivers. What is the output of
php --ri sqlsrvandphp --ri pdo_sqlsrv? These commands should provide information about the installed versions of the extensions. If they are installed correctly, try connecting through a PHP script with sqlsrv_connect(). If it does not work, use sqlsrv_errors() to see any error messages and reproduce the errors here.That error message usually occurs because pdo_sqlsrv is being loaded before pdo itself. This may happen if your php.ini loads pdo_sqlsrv.so but pdo is loaded with its own pdo.ini file (it is probably named something like 10-pdo.ini). These extension-specific .ini files are loaded after php.ini. If you followed the instructions I linked, then you should already have a file to load pdo_sqlsrv after pdo, but your php.ini probably includes a line like
extension=pdo_sqlsrv.so. If you remove that line, it should work.