在OS X中安装捆绑的PHP扩展 [英] Installing extensions to the bundled PHP in OS X

查看:60
本文介绍了在OS X中安装捆绑的PHP扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从OS X 10.9上的PHP连接到SQL Server,所以我做到了:

I needed to connect to an SQL Server from PHP on OS X 10.9, so I did:

brew install php55
brew install php55-pdo-dblib

这很好用,但是我想知道:是否可以在OS X中将dblib扩展(或任何其他PHP扩展)安装到PHP的捆绑版本中,而无需编译全新的版本的PHP?

This worked nicely, but I'm wondering: Is it possible to install the dblib extension (or any other PHP extension) into the bundled version of PHP in OS X, without compiling a totally new version of PHP?

您在哪里可以找到必要的下载文件,以及通常如何向PHP添加扩展?在研究了该主题之后,这还出乎意料地不清楚.

Where do you find necessary downloads, and what do you do in general to add extensions to PHP? This is surprisingly unclear after researching the topic.

推荐答案

诀窍是使用phpize-OSX附带的phpize,构建您希望添加为共享的扩展,并在php.ini文件中启用它

The trick is to use phpize - which OSX ships, build the extension you wish to add as shared, and enable it in your php.ini file

php手册在此提供了有关此信息- http://php.net /manual/zh-CN/install.pecl.phpize.php

The php manual has information about this here - http://php.net/manual/en/install.pecl.phpize.php

因此,您需要下载要构建的扩展程序的源代码并将其安装到其中

So you'll need to download the source for the extension you want to build and cd into it

运行phpize(确保使用正确的phpize,如果您已安装其他版本的自制软件,则将有两个浮动版本,因此请确保安全并使用完整路径-系统phpize通常位于/usr/bin/phpize中)您还需要匹配的php-config文件(通常在/bin中找到您的php二进制文件)

run phpize (make sure you use the correct phpize, if you have homebrew with another PHP version installed you'll have two floating around so be safe and use complete paths - system phpize is generally in /usr/bin/phpize) You'll also need the matching php-config file (generally found in /bin wherever your php binaries are)

/path/to/phpize
./configure --with-php-config=/path/to/php-config
make
make install

然后,您需要查找已编译模块的名称,并将其放入您的php.ini文件中

then you need to look up the name of the module that was compiled and put that into your php.ini file

extension=pdo_dblib.so

并重新启动服务器

注意:您可能需要安装autoconf,用于编译器的xcode或其他工具.但是,如果您已经安装了自制软件,我想您已经有了所需的工具.

NOTE: you may need to install autoconf, xcode for a compiler, or other tools. But if you already have homebrew installed I'm guessing you already have the tools you need.

如果这似乎太难了-使用--without-homebrew-php应该安装系统php扩展版本,但我始终无法使它可靠地工作-有关此的更多信息,请参见链接

If this seems too hard - using the --without-homebrew-php should install system php extension versions, but I've never been able to get that to work reliably - see link for more information on this

http://www.farces.com/wikis /naked-server/homebrew/homebrew-php-ext/

这篇关于在OS X中安装捆绑的PHP扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆