osx为php配置pdo-odbc

来源:互联网 发布:it occured that 编辑:程序博客网 时间:2024/06/05 09:45

参考:http://stackoverflow.com/questions/9958920/enabling-php-pdo-odbc-extension-on-a-mac-osx


AndyMacBookPro:pdo_odbc andy$ ./configure --with-pdo-odbc=/usr/local/unixODBC
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... i386-apple-darwin13.3.0
checking host system type... i386-apple-darwin13.3.0
checking target system type... i386-apple-darwin13.3.0
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/lib/php/extensions/no-debug-non-zts-20100525
checking for PHP installed headers prefix... /usr/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking for ODBC v3 support for PDO... yes, shared
checking for PDO includes... checking for PDO includes... /usr/include/php/ext
checking for selected PDO ODBC flavour... configure: error: Unknown ODBC flavour /usr/local/unixODBC
                            include and lib dirs are looked for under 'dir'.


                            'flavour' can be one of:  ibm-db2, iODBC, unixODBC, generic
                            If ',dir' part is omitted, default for the flavour
                            you have selected will used. e.g.:


                              --with-pdo-odbc=unixODBC


                            will check for unixODBC under /usr/local. You may attempt
                            to use an otherwise unsupported driver using the "generic"
                            flavour.  The syntax for generic ODBC support is:


                              --with-pdo-odbc=generic,dir,libname,ldflags,cflags


                            When build as shared the extension filename is always pdo_odbc.so
AndyMacBookPro:pdo_odbc andy$ 



报错,所以改为:


AndyMacBookPro:pdo_odbc andy$ ./configure --with-pdo-odbc=unixodbc
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... i386-apple-darwin13.3.0
checking host system type... i386-apple-darwin13.3.0
checking target system type... i386-apple-darwin13.3.0
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/lib/php/extensions/no-debug-non-zts-20100525
checking for PHP installed headers prefix... /usr/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking for ODBC v3 support for PDO... yes, shared
checking for PDO includes... checking for PDO includes... /usr/include/php/ext
checking for selected PDO ODBC flavour... unixodbc
          libs       /usr/local/lib,
          headers    /usr/local/include
checking for odbc.h in /usr/local/include... no
checking for odbcsdk.h in /usr/local/include... no
checking for iodbc.h in /usr/local/include... no
checking for sqlunix.h in /usr/local/include... no
checking for sqltypes.h in /usr/local/include... yes
checking for sqlucode.h in /usr/local/include... yes
checking for sql.h in /usr/local/include... yes
checking for isql.h in /usr/local/include... no
checking for sqlext.h in /usr/local/include... yes
checking for isqlext.h in /usr/local/include... no
checking for udbcext.h in /usr/local/include... no
checking for sqlcli1.h in /usr/local/include... no
checking for LibraryManager.h in /usr/local/include... no
checking for cli0core.h in /usr/local/include... no
checking for cli0ext.h in /usr/local/include... no
checking for cli0cli.h in /usr/local/include... no
checking for cli0defs.h in /usr/local/include... no
checking for cli0env.h in /usr/local/include... no
checking for SQLBindCol in -lodbc... yes
checking for SQLAllocHandle in -lodbc... yes
checking for ld used by cc... /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld
checking if the linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) is GNU ld... no
checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
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 dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 196608
checking command to parse /usr/bin/nm output from cc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking for dsymutil... dsymutil
checking for nmedit... nmedit
checking for -single_module linker flag... yes
checking for -exported_symbols_list linker flag... yes
checking if cc supports -fno-rtti -fno-exceptions... yes
checking for cc option to produce PIC... -fno-common
checking if cc PIC flag -fno-common works... yes
checking if cc static flag -static works... no
checking if cc supports -c -o file.o... yes
checking whether the cc linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... darwin13.3.0 dyld
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


creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
AndyMacBookPro:pdo_odbc andy$ 



之后make就可以了~~~




Yes!!!




然后再将pdo_odbc.so拷贝到php保存扩展的目录:/usr/lib/php/extensions/no-debug-non-zts-20100525/ 就可以了~~~



AndyMacBookPro:pdo_odbc andy$ sudo find / -name redis.so
Password:
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
/Users/andy/Documents/phpredis/.libs/redis.so
/Users/andy/Documents/phpredis/.libs/redis.so.dSYM/Contents/Resources/DWARF/redis.so
/Users/andy/Documents/phpredis/modules/redis.so
/usr/lib/php/extensions/no-debug-non-zts-20100525/redis.so
AndyMacBookPro:pdo_odbc andy$ 



然后就cp:


AndyMacBookPro:pdo_odbc andy$ sudo cp /Users/andy/Downloads/php-5.4.30/ext/pdo_odbc/modules/pdo_odbc.so /usr/lib/php/extensions/no-debug-non-zts-20100525/
AndyMacBookPro:pdo_odbc andy$ 




之后去php.ini中配置开启pdo_odbc.so扩展,我的位于:/private/etc/php.ini


AndyMacBookPro:modules andy$ sudo find / -name php.ini
find: /dev/fd/3: Not a directory
find: /dev/fd/4: Not a directory
/private/etc/php.ini
/usr/local/etc/php/5.4/php.ini
AndyMacBookPro:modules andy$ 



添加extension=pdo_odbc.so 就可以了~~


然后保存重启apache服务器~~~


sudo apachectl restart



PDO_ODBC

pdopdoDO_ODBCpdo

PDO Driver for ODBC (unixodbc)enabledODBC Connection PoolingEnabled, strict matching



之后我们再访问sql server数据库,提示错误终于从:


系统发生错误

您可以选择 [ 重试 ] [ 返回 ] 或者 [ 回到首页 ]

[ 错误信息 ]

could not find driver



变为:


系统发生错误

您可以选择 [ 重试 ] [ 返回 ] 或者 [ 回到首页 ]

[ 错误信息 ]

SQLSTATE[IM002] SQLConnect: 0 [unixODBC][Driver Manager]Data source name not found, and no default driver specified




php通过pdo连接sqlserver有希望啦~~~~


如果有心的同学能发现这也是isql 连接时的报错,说明终于使用unixodbc来建立连接了~~~,后面我们要解决的就是上面提示的这个问题了~~~

0 0
原创粉丝点击