microsoft / msphpsql

Microsoft Drivers for PHP for SQL Server
MIT License
1.8k stars 373 forks source link

install error on CENTOS #734

Closed leandroruel closed 6 years ago

leandroruel commented 6 years ago

+## Driver version or file name +Please tell us what the PHP driver version or file name is.

david-puglielli commented 6 years ago

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 match error. 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

sudo yum-config-manager --enable rhel-server-rhscl-7-rpms

should be replaced with

sudo yum install centos-release-scl

Please try these instructions and let us know if the problem is fixed.

leandroruel commented 6 years ago

stoped here:

[root@unisrvwaapi01vm ~]# subscription-manager repos --enable=rhel-7-server-optional-rpms
bash: subscription-manager: command not found
david-puglielli commented 6 years ago

My apologies, that command is not needed for CentOS. You can leave it out entirely.

leandroruel commented 6 years ago

skipped this command but still have issues

[root@unisrvwaapi01vm ~]# php -v
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 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
david-puglielli commented 6 years ago

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.

leandroruel commented 6 years ago

Ok, I'll try that now.

Update: after remove the lines mentioned, now when i type php -v he just show me the php version and no errors show up. However, i tried the sqlcmd command and i can't connect with my database. do you have any database to tests?

my application still gets:

could not find driver (SQL: select * from [permissions])
david-puglielli commented 6 years ago

sqlcmd is separate from the sqlsrv/pdo_sqlsrv drivers. What is the output of php --ri sqlsrv and php --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.

leandroruel commented 6 years ago

this is the output:

[root@unisrvwaapi01vm ~]# php --ri sqlsrv
Extension 'sqlsrv' not present.
[root@unisrvwaapi01vm ~]# php --ri pdo_sqlsrv
Extension 'pdo_sqlsrv' not present.

i'm not understanding why, i followed all the instructions.

david-puglielli commented 6 years ago

What is the output of php --ini?

leandroruel commented 6 years ago
[root@unisrvwaapi01vm ~]# php --ini
Configuration File (php.ini) Path: /etc
Loaded Configuration File:         /etc/php.ini
Scan for additional .ini files in: /etc/php.d
Additional .ini files parsed:      /etc/php.d/10-opcache.ini,
/etc/php.d/20-bz2.ini,
/etc/php.d/20-calendar.ini,
/etc/php.d/20-ctype.ini,
/etc/php.d/20-curl.ini,
/etc/php.d/20-dom.ini,
/etc/php.d/20-exif.ini,
/etc/php.d/20-fileinfo.ini,
/etc/php.d/20-ftp.ini,
/etc/php.d/20-gettext.ini,
/etc/php.d/20-iconv.ini,
/etc/php.d/20-json.ini,
/etc/php.d/20-mbstring.ini,
/etc/php.d/20-pdo.ini,
/etc/php.d/20-phar.ini,
/etc/php.d/20-posix.ini,
/etc/php.d/20-shmop.ini,
/etc/php.d/20-simplexml.ini,
/etc/php.d/20-sockets.ini,
/etc/php.d/20-sqlite3.ini,
/etc/php.d/20-sysvmsg.ini,
/etc/php.d/20-sysvsem.ini,
/etc/php.d/20-sysvshm.ini,
/etc/php.d/20-tokenizer.ini,
/etc/php.d/20-xml.ini,
/etc/php.d/20-xmlwriter.ini,
/etc/php.d/20-xsl.ini,
/etc/php.d/30-mcrypt.ini,
/etc/php.d/30-pdo_sqlite.ini,
/etc/php.d/30-wddx.ini,
/etc/php.d/30-xmlreader.ini
david-puglielli commented 6 years ago

There are no files to load sqlsrv or pdo_sqlsrv. Please run the following:

sudo su
echo extension=pdo_sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/30-pdo_sqlsrv.ini
echo extension=sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/20-sqlsrv.ini
exit

This will add the required .ini files.

leandroruel commented 6 years ago

OK, i'm already as root user, so, i'm running the commands without sudo

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
david-puglielli commented 6 years ago

Somewhere on your system you have the modules built for PHP 7.1. Have you built the modules with PECL, as follows?

sudo pecl install sqlsrv
sudo pecl install pdo_sqlsrv

Please try this and let us know if it works.

leandroruel commented 6 years ago
[root@unisrvwaapi01vm ~]# pecl install sqlsrv
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
pecl/sqlsrv is already installed and is the same as the released version 5.2.0
install failed

Thanks for the patience

david-puglielli commented 6 years ago

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. Try

sudo pecl uninstall sqlsrv
sudo pecl uninstall pdo_sqlsrv
sudo pecl install sqlsrv
sudo pecl install pdo_sqlsrv
leandroruel commented 6 years ago

OK, this is the output when i typed the first 3 commands:

[root@unisrvwaapi01vm ~]# pecl uninstall sqlsrv
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
Unable to remove "extension=sqlsrv.so" from php.ini
uninstall ok: channel://pecl.php.net/sqlsrv-5.2.0
[root@unisrvwaapi01vm ~]# pecl uninstall pdo_sqlsrv
PHP Warning:  PHP Startup: Unable to load dynamic library 'sqlsrv.so' (tried: /usr/lib64/php/modules/sqlsrv.so (/usr/lib64/php/modules/sqlsrv.so: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/sqlsrv.so.so (/usr/lib64/php/modules/sqlsrv.so.so: cannot open shared object file: No such file or directory)) 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
Unable to remove "extension=pdo_sqlsrv.so" from php.ini
uninstall ok: channel://pecl.php.net/pdo_sqlsrv-4.0.5
[root@unisrvwaapi01vm ~]# pecl install sqlsrv
PHP Warning:  PHP Startup: Unable to load dynamic library 'sqlsrv.so' (tried: /usr/lib64/php/modules/sqlsrv.so (/usr/lib64/php/modules/sqlsrv.so: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/sqlsrv.so.so (/usr/lib64/php/modules/sqlsrv.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
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: cannot open shared object file: No such file or directory), /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
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading sqlsrv-5.2.0.tgz ...
Starting to download sqlsrv-5.2.0.tgz (171,728 bytes)
.....................................done: 171,728 bytes
33 source files, building
running: phpize
Configuring for:
PHP Api Version:         20170718
Zend Module Api No:      20170718
Zend Extension Api No:   320170718
building in /var/tmp/pear-build-roots7f7aH/sqlsrv-5.2.0
running: /var/tmp/sqlsrv/configure --with-php-config=/usr/bin/php-config
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib
checking for PHP extension directory... /usr/lib64/php/modules
checking for PHP installed headers prefix... /usr/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... re2c
checking for re2c version... 0.14.3 (ok)
checking for gawk... gawk
checking whether to enable sqlsrv functions... yes, shared
checking for SQLSRV headers... /var/tmp/sqlsrv/shared/
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking how to run the C++ preprocessor... g++ -E
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking for gawk... (cached) gawk
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for sysroot... no
checking for mt... no
checking if : is a manifest tool... no
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC -DPIC
checking if cc PIC flag -fPIC -DPIC works... yes
checking if cc static flag -static works... no
checking if cc supports -c -o file.o... yes
checking if cc supports -c -o file.o... (cached) yes
checking whether the cc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
checking how to run the C++ preprocessor... g++ -E
checking for ld used by g++... /usr/bin/ld -m elf_x86_64
checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC -DPIC
checking if g++ PIC flag -fPIC -DPIC works... yes
checking if g++ static flag -static works... no
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... (cached) GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
configure: creating ./config.status
config.status: creating config.h
config.status: executing libtool commands
running: make
/bin/sh /var/tmp/pear-build-roots7f7aH/sqlsrv-5.2.0/libtool --mode=compile g++ -std=c++11 -I. -I/var/tmp/sqlsrv -DPHP_ATOM_INC -I/var/tmp/pear-build-roots7f7aH/sqlsrv-5.2.0/include -I/var/tmp/pear-build-roots7f7aH/sqlsrv-5.2.0/main -I/var/tmp/sqlsrv -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/var/tmp/sqlsrv/shared/  -DHAVE_CONFIG_H  -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector   -c /var/tmp/sqlsrv/conn.cpp -o conn.lo
libtool: compile:  g++ -std=c++11 -I. -I/var/tmp/sqlsrv -DPHP_ATOM_INC -I/var/tmp/pear-build-roots7f7aH/sqlsrv-5.2.0/include -I/var/tmp/pear-build-roots7f7aH/sqlsrv-5.2.0/main -I/var/tmp/sqlsrv -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/var/tmp/sqlsrv/shared/ -DHAVE_CONFIG_H -std=c++11 -D_FORTIFY_SOURCE=2 -O2 -fstack-protector -c /var/tmp/sqlsrv/conn.cpp  -fPIC -DPIC -o .libs/conn.o
In file included from /usr/include/php/Zend/zend_types.h:27:0,
                 from /usr/include/php/Zend/zend.h:29,
                 from /usr/include/php/main/php.h:35,
                 from /var/tmp/sqlsrv/shared/core_sqlsrv.h:34,
                 from /var/tmp/sqlsrv/php_sqlsrv.h:25,
                 from /var/tmp/sqlsrv/conn.cpp:20:
/usr/include/php/Zend/zend_operators.h: In function 'void fast_long_increment_function(zval*)':
/usr/include/php/Zend/zend_operators.h:446:68: error: '__builtin_saddl_overflow' was not declared in this scope
  if (UNEXPECTED(__builtin_saddl_overflow(Z_LVAL_P(op1), 1, &lresult))) {
                                                                    ^
/usr/include/php/Zend/zend_portability.h:312:52: note: in definition of macro 'UNEXPECTED'
 # define UNEXPECTED(condition) __builtin_expect(!!(condition), 0)
                                                    ^
/usr/include/php/Zend/zend_operators.h: In function 'void fast_long_decrement_function(zval*)':
/usr/include/php/Zend/zend_operators.h:500:68: error: '__builtin_ssubl_overflow' was not declared in this scope
  if (UNEXPECTED(__builtin_ssubl_overflow(Z_LVAL_P(op1), 1, &lresult))) {
                                                                    ^
/usr/include/php/Zend/zend_portability.h:312:52: note: in definition of macro 'UNEXPECTED'
 # define UNEXPECTED(condition) __builtin_expect(!!(condition), 0)
                                                    ^
/usr/include/php/Zend/zend_operators.h: In function 'void fast_long_add_function(zval*, zval*, zval*)':
/usr/include/php/Zend/zend_operators.h:554:80: error: '__builtin_saddl_overflow' was not declared in this scope
  if (UNEXPECTED(__builtin_saddl_overflow(Z_LVAL_P(op1), Z_LVAL_P(op2), &lresult))) {
                                                                                ^
/usr/include/php/Zend/zend_portability.h:312:52: note: in definition of macro 'UNEXPECTED'
 # define UNEXPECTED(condition) __builtin_expect(!!(condition), 0)
                                                    ^
/usr/include/php/Zend/zend_operators.h: In function 'void fast_long_sub_function(zval*, zval*, zval*)':
/usr/include/php/Zend/zend_operators.h:657:80: error: '__builtin_ssubl_overflow' was not declared in this scope
  if (UNEXPECTED(__builtin_ssubl_overflow(Z_LVAL_P(op1), Z_LVAL_P(op2), &lresult))) {
                                                                                ^
/usr/include/php/Zend/zend_portability.h:312:52: note: in definition of macro 'UNEXPECTED'
 # define UNEXPECTED(condition) __builtin_expect(!!(condition), 0)
                                                    ^
make: ** [conn.lo] Erro 1
ERROR: `make' failed
david-puglielli commented 6 years ago

Okay, this is progress as it starts building the drivers. The errors you are seeing are due to a known issue in PECL on CentOS. To install, you need to switch to the devtoolset-7 shell and install the drivers manually:

scl enable devtoolset-7 bash
pecl download sqlsrv
tar xvzf sqlsrv-5.2.0.tgz
cd sqlsrv-5.2.0/
phpize
./configure --with-php-config=/usr/bin/php-config
make
sudo make install

and similarly for pdo_sqlsrv. This should finally install the drivers properly, and you can check with php --ri sqlsrv and php --ri pdo_sqlsrv.

leandroruel commented 6 years ago

OK, this is the output after type the commands above:

[root@unisrvwaapi01vm ~]# scl enable devtoolset-7 bash
[root@unisrvwaapi01vm ~]# pecl download sqlsrv
PHP Warning:  PHP Startup: Unable to load dynamic library 'sqlsrv.so' (tried: /usr/lib64/php/modules/sqlsrv.so (/usr/lib64/php/modules/sqlsrv.so: cannot open shared object file: No such file or directory), /usr/lib64/php/modules/sqlsrv.so.so (/usr/lib64/php/modules/sqlsrv.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
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: cannot open shared object file: No such file or directory), /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
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading sqlsrv-5.2.0.tgz ...
Starting to download sqlsrv-5.2.0.tgz (171,728 bytes)
.....................................done: 171,728 bytes
File /root/sqlsrv-5.2.0.tgz downloaded
[root@unisrvwaapi01vm ~]# tar xvzf sqlsrv-5.2.0.tgz
package.xml
sqlsrv-5.2.0/
sqlsrv-5.2.0/util.cpp
sqlsrv-5.2.0/LICENSE
sqlsrv-5.2.0/init.cpp
sqlsrv-5.2.0/config.w32
sqlsrv-5.2.0/shared/
sqlsrv-5.2.0/shared/StringFunctions.h
sqlsrv-5.2.0/shared/interlockedatomic.h
sqlsrv-5.2.0/shared/xplat_intsafe.h
sqlsrv-5.2.0/shared/core_sqlsrv.h
sqlsrv-5.2.0/shared/msodbcsql.h
sqlsrv-5.2.0/shared/version.h
sqlsrv-5.2.0/shared/localization.hpp
sqlsrv-5.2.0/shared/globalization.h
sqlsrv-5.2.0/shared/interlockedatomic_gcc.h
sqlsrv-5.2.0/shared/core_util.cpp
sqlsrv-5.2.0/shared/localizationimpl.cpp
sqlsrv-5.2.0/shared/core_conn.cpp
sqlsrv-5.2.0/shared/FormattedPrint.cpp
sqlsrv-5.2.0/shared/core_results.cpp
sqlsrv-5.2.0/shared/core_stream.cpp
sqlsrv-5.2.0/shared/sal_def.h
sqlsrv-5.2.0/shared/xplat_winerror.h
sqlsrv-5.2.0/shared/xplat_winnls.h
sqlsrv-5.2.0/shared/StringFunctions.cpp
sqlsrv-5.2.0/shared/typedefs_for_linux.h
sqlsrv-5.2.0/shared/core_init.cpp
sqlsrv-5.2.0/shared/xplat.h
sqlsrv-5.2.0/shared/core_stmt.cpp
sqlsrv-5.2.0/shared/interlockedslist.h
sqlsrv-5.2.0/shared/FormattedPrint.h
sqlsrv-5.2.0/template.rc
sqlsrv-5.2.0/CREDITS
sqlsrv-5.2.0/config.m4
sqlsrv-5.2.0/stmt.cpp
sqlsrv-5.2.0/php_sqlsrv.h
sqlsrv-5.2.0/conn.cpp
[root@unisrvwaapi01vm ~]# cd sqlsrv-5.2.0/
[root@unisrvwaapi01vm sqlsrv-5.2.0]# phpize
Configuring for:
PHP Api Version:         20170718
Zend Module Api No:      20170718
Zend Extension Api No:   320170718
[root@unisrvwaapi01vm sqlsrv-5.2.0]# ./configure --with-php-config=/usr/bin/php-config
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib
checking for PHP extension directory... /usr/lib64/php/modules
checking for PHP installed headers prefix... /usr/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... re2c
checking for re2c version... 0.14.3 (ok)
checking for gawk... gawk
checking whether to enable sqlsrv functions... yes, shared
checking for SQLSRV headers... ./shared/
checking for g++... g++
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking how to run the C++ preprocessor... g++ -E
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by cc... /opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld
checking if the linker (/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /opt/rh/devtoolset-7/root/usr/bin/nm -B
checking the name lister (/opt/rh/devtoolset-7/root/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking for gawk... (cached) gawk
checking command to parse /opt/rh/devtoolset-7/root/usr/bin/nm -B output from cc object... ok
checking for sysroot... no
checking for mt... no
checking if : is a manifest tool... no
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC -DPIC
checking if cc PIC flag -fPIC -DPIC works... yes
checking if cc static flag -static works... no
checking if cc supports -c -o file.o... yes
checking if cc supports -c -o file.o... (cached) yes
checking whether the cc linker (/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
checking how to run the C++ preprocessor... g++ -E
checking for ld used by g++... /opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld -m elf_x86_64
checking if the linker (/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld -m elf_x86_64) is GNU ld... yes
checking whether the g++ linker (/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld -m elf_x86_64) supports shared libraries... yes
checking for g++ option to produce PIC... -fPIC -DPIC
checking if g++ PIC flag -fPIC -DPIC works... yes
checking if g++ static flag -static works... no
checking if g++ supports -c -o file.o... yes
checking if g++ supports -c -o file.o... (cached) yes
checking whether the g++ linker (/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... (cached) GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
configure: creating ./config.status
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing libtool commands
[root@unisrvwaapi01vm sqlsrv-5.2.0]# make
/bin/sh /root/sqlsrv-5.2.0/libtool --mode=install cp ./sqlsrv.la /root/sqlsrv-5.2.0/modules
libtool: install: cp ./.libs/sqlsrv.so /root/sqlsrv-5.2.0/modules/sqlsrv.so
libtool: install: cp ./.libs/sqlsrv.lai /root/sqlsrv-5.2.0/modules/sqlsrv.la
libtool: finish: PATH="/opt/rh/devtoolset-7/root/usr/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/mssql-tools/bin:/opt/mssql-tools/bin:/opt/mssql-tools/bin:/sbin" ldconfig -n /root/sqlsrv-5.2.0/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /root/sqlsrv-5.2.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'.

[root@unisrvwaapi01vm sqlsrv-5.2.0]# make install
Installing shared extensions:     /usr/lib64/php/modules/
leandroruel commented 6 years ago

and this is the output when i typed the command below:

[root@unisrvwaapi01vm sqlsrv-5.2.0]# php --ri sqlsrv
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: cannot open shared object file: No such file or directory), /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

sqlsrv

sqlsrv support => enabled
ExtensionVer => 5.2.0

Directive => Local Value => Master Value
sqlsrv.WarningsReturnAsErrors => On => On
sqlsrv.LogSeverity => 0 => 0
sqlsrv.LogSubsystems => 0 => 0
sqlsrv.ClientBufferMaxKBSize => 10240 => 10240
david-puglielli commented 6 years ago

That looks correct. Simply do the same for pdo_sqlsrv and you should have both drivers installed and functioning.

leandroruel commented 6 years ago

i think they are now installed, have any way of testing it to really know if is working?

david-puglielli commented 6 years ago

Run php --ri sqlsrv and php --ri pdo_sqlsrv. You should see the same output as above, and ExtensionVer should be 5.2.0 for both drivers.

leandroruel commented 6 years ago

i tried a test using sqlcmd and this give me the output:

Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : SQL Server Network Interfaces: Error Locating Server/Instance Specified [xFFFFFFFF]. .
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : Login timeout expired.
Sqlcmd: Error: Microsoft SQL Server Native Client 11.0 : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..

you think this is a issue inside my network? i'm using a virtual machine with centos, this machine is not local, but is in a server in my company.

david-puglielli commented 6 years ago

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.

leandroruel commented 6 years ago

i fixed it, for any reason, in my vm he is not resolving the server name but with ip address works, example: myserver\sql2012 = fails. BUT 192.168.0.21\sql2012 works.

also, i'm going to update it (i expect it not mess up again)

thank you for your help! 🥇

can i close this issue now?

david-puglielli commented 6 years ago

You're welcome. You can leave the issue open in case you have any more questions, but we will probably close it in a few days' time if there is no more activity.

framm commented 6 years ago

@david-puglielli: I'm experiencing the exact same issues as @leandroruel, but I'm on Ubuntu 16.04.

I'm following this guide: https://sqlchoice.azurewebsites.net/en-us/sql-server/developer-get-started/php/ubuntu/ step-by-step.

Can you help? I'm getting the following error: _PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20151012/pdo_sqlsrv.so' - /usr/lib/php/20151012/pdo_sqlsrv.so: undefined symbol: php_pdo_registerdriver in Unknown on line 0

leandroruel commented 6 years ago

@framm never follow those guide,s just official Microsoft guides

david-puglielli commented 6 years ago

@framm You need to load the PDO extension before PDO_SQLSRV. Try the following command:

echo extension=pdo_sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/30-pdo_sqlsrv.ini

and remove the line extension=pdo_sqlsrv.so from php.ini.

david-puglielli commented 6 years ago

Closing this issue as there has been no more activity. Please reopen if needed.

jlsjonas commented 6 years ago

For anyone stumbling upon this; for CentOs 7 I had to execute the following (as root) to get php 7.2 instead of 5 by default:

yum install epel-release
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
#just in case
yum install yum-utils
#enable 7.2
yum-config-manager --enable remi-php72
yum update

at this point you should be able to (mostly) follow the RHEL guide, installing php & related dependencies using

yum install php php-pdo php-xml php-pear php-devel re2c gcc-c++ gcc

note that php-related packages should have version 7.2+ when you confirm

(source)

zan182 commented 6 years ago

Hi Guys

@david-puglielli I need your help, I need to connect to a remote server via sqlcmd, locally if I can connect to my database, but I get the following message connecting to the external server

[root@localhost ~]# sqlcmd -S 10.1.2.1,1434 -U userx Password: Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login timeout expired. Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x102. Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..

I get the same message if I make a .php file and execute it in the browser.

Help me please

as additional information I have CENTOS7 installed and I followed this guide for the installation of php, apache, ODBDC, SQL SERVER and the php driver

leandroruel commented 6 years ago

@zan182 create a new issue