linux server 安装php,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}   /* Must be the last line in my_module_functions[] */

};

在文件最后添加

PHP_FUNCTION(say_hello)

{

zend_printf("hello sdomain!");

}

2.3 修改php_sdomain.h

PHP_FUNCTION(confirm_my_module_compiled ); /* For testing, remove later. */

/*这行的下面添加一行*/

PHP_FUNCTION(say_hello); /* For testing, remove later. */

2.4运行phpize

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

Configuring for:

PHP Api Version:     20020918

Zend Module Api No:   20020429

Zend Extension Api No:  20050606

出现以上信息,则配置成功啦!

3、重新编译PHP,使用phpize会保留以前的配置

先确保php.ini里的extension_dir="/usr/local/php/ext",如果不先设置它的扩展路径的话,重新编译不会把mssql.so放到/usr/local/php/ext下的。当然,你不设置也可以。make install时,它会提示扩展放到那里去了。

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

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/webserver/php/bin/php-config --with-mssql=/usr/local/webserver/freetds/

make

make install

在php.ini增加一行extension = "mssql.so"

4、重启PHP FastCGI, 用phpinfo();查看一下如果看见mssql模块就成功了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值