日期:2014-05-16  浏览次数:20673 次

linux php 安装sql server扩展

?

参照: ?基于Linux下PHP连接SQL Server的FreeTDS配置

? ? ? ? ? ? ??使用phpize建立php扩展 Cannot find config.m4.

注:php安装地方 /usr/local/php

? ? ? ?php源码包 /usr/local/src/php-4.3.5

? ? ? ?FreeTDs下载http://ftp.ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz

?

1、编译安装FreeTDS

?

tar zxvf freetds-stable.tgz
cd freetds-0.91
./configure --prefix=/usr/local/freetds --with-tdsver=8.0 --enable-msdblib 
make
make install

echo "/usr/local/freetds/lib/" > /etc/ld.so.conf.d/freetds.conf  

ln -s /usr/local/freetds/lib/libsybdb.so.5.0.0 /usr/local/freetds/lib/libsybdb.so.4 

/sbin/ldconfig 

cd /usr/local/freetds/etc
cp freetds.conf  freetds.conf.bak
vi freetds.conf

?

?

? ?修改freetds.conf

?

[global]  
        # TDS protocol version  
;       tds version = 4.2  
 
        # Whether to write a TDSDUMP file for diagnostic purposes  
        # (setting this to /tmp is insecure on a multi-user system)  
;       dump file = /tmp/freetds.log  
;       debug flags = 0xffff 
 
        # Command and connection timeouts  
;       timeout = 10 
;       connect timeout = 10 
 
        # If you get out-of-memory errors, it may mean that your client  
        # is trying to allocate a huge buffer for a TEXT field.  
        # Try setting 'text size' to a more reasonable limit  
        text size = 64512 
 
        host = mssql.yourdomain.com  
        port = 1433 
        tds version = 8.0  
        client charset = UTF-8

?

?

2、配置phpize

? ? ?由于运行/usr/local/php/bin/phpize时报以下的错,所以要配置一下phpize。如果运行phpize不报错,则直接跳至3

[root@ns root]# /usr/local/php/bin/phpize

  Cannot find config.m4.

  Make sure that you run /usr/local/bin/phpize in the top level source directory of the module

解决方法

?

cd /usr/local/src/php-4.3.5/ext/

./ext_skel --extname=sdomain

cd sdomain/

vi config.m4

?

2.1、修改config.m4

?

dnl PHP_ARG_ENABLE(my_module, whether to enable my_module support,
dnl Make sure that the comment is aligned:
dnl [ --enable-my_module      Enable my_module support])
?
修改成,dnl其实是注释,把dnl删除
PHP_ARG_ENABLE(my_module, whether to enable my_module support,
[ --enable-my_module      Enable my_module support])

?

?2.2、修改sdomain.c

?

将其中的代码修改成

function_entry my_module_functions[] = {
    PHP_FE(say_hello,    NULL) /* 添加这一行代码 */
    PHP_FE(confirm_my_module_compiled,   NULL) /* For testing, remove later. */
    {NULL, NULL, NULL}   /*