【问题标题】:Recompiling PHP with xmlreader, xmlwriter enabled使用 xmlreader 重新编译 PHP,启用 xmlwriter
【发布时间】:2011-07-11 04:30:29
【问题描述】:

我注意到我在开发盒上使用的 PHP 版本没有启用 xmlreader 和 xmlwriter 扩展。我知道我需要重新编译 PHP 以启用这些扩展(或者可能更准确地删除禁用,因为它们是默认启用的?),但是我在我需要运行的地方建立连接时遇到了问题./configure 和 make 命令。

这是来自 phpinfo() 输出的配置命令:

'./configure' '--build=i686-redhat-linux-gnu' '--host=i686-redhat-linux-gnu' \
 '--target=i386-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' \
 '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' \
 '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' \
 '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var' \
 '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info' \
 '--cache-file=../config.cache' '--with-libdir=lib' '--with-config-file-path=/etc' \
 '--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' \
 '--disable-rpath' '--without-pear' '--with-bz2' '--with-exec-dir=/usr/bin' \
 '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--with-xpm-dir=/usr' \
 '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp' \
 '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-pcre-regex=/usr' \
 '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' \
 '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' \
 '--enable-sysvmsg' '--with-kerberos' '--enable-ucd-snmp-hack' '--enable-shmop' \
 '--enable-calendar' '--without-mime-magic' '--without-sqlite' \
 '--with-libxml-dir=/usr' '--enable-xml' '--with-system-tzdata' \
 '--with-apxs2=/usr/sbin/apxs' '--without-mysql' '--without-gd' '--disable-dom' \
 '--disable-dba' '--without-unixODBC' '--disable-pdo' '--disable-xmlreader' \
 '--disable-xmlwriter' '--without-sqlite3' '--disable-phar' '--disable-fileinfo' \
 '--disable-json' '--without-pspell' '--disable-wddx' '--without-curl' \
 '--disable-posix' '--disable-sysvmsg' '--disable-sysvshm' '--disable-sysvsem' 

请注意,它是使用 --disable-xmlreader 和 --disable-xmlwriter 编译的。根据http://www.php.net/manual/en/xmlwriter.installation.php 的文档,我看到默认情况下启用了此扩展。我将如何“撤消”此扩展禁用?

我的目标是能够使用 PHPExcel 类集 (http://phpexcel.codeplex.com/),但由于其中一个类试图扩展 XMLWriter 类而遇到致命错误。

【问题讨论】:

  • 我只是使用 ./configure 行,然后是 make clean、make、make test 和 make install 在 RH ES4 上重建 PHP;但我确实确保使用 rpm -e 在新的服务器构建上删除所有 Redhat rpm

标签: php xmlwriter


【解决方案1】:

如果您使用的是具有二进制包的发行版之一(如 openSUSE) - 您可能只想安装 php-xmlwriter 包作为扩展。

另一种选择 - 只需获取版本的源代码,然后使用 phpize 将 xmlwriter 编译为模块(如果需要更多帮助,请告诉我)。

如果这不起作用 - 您将需要获取源代码,然后从头开始编译所有内容。在这种情况下,configure 将从您提取源代码的文件夹运行。

要记住的其他事项 - 您现在安装的任何扩展 - 您需要编译它们,或者使用您获得的源重新构建(除非 php 版本匹配 - 然后您可以使用已安装的) .

最后,发行版通常带有一些 php 二进制文件(如 CGI、apache 模块、cli)。您还需要确保在您的配置命令中启用了此功能(或您需要的任何部分)。

【讨论】:

  • 如果我使用您的第一个建议(安装为扩展程序),我会为 xmlwriter 获取 .so 吗?
  • 第一个 - 您需要安装发行版附带的 RPM 或 DEB 包。 “yum install php-xmlwriter”或“apt-get install php-xmlwriter”。或者下载合适的包并安装。
  • 我能够从 yum.chrislea.com/centos/5/i386 获取 rpm 并且成功了。感谢您的帮助!
【解决方案2】:

只需在您提取源代码的目录(例如,/home/user/php-5.3.5)中运行配置命令,不要包含这两个选项。即:

./configure -prefix=/usr ... <everything but --disable-xmlreader and --disable-xmlwriter>

【讨论】:

  • 也许我的做法是错误的,但我尝试了locate php-5.3.2 并没有看到源文件。但是,我确实找到了 /var/cache/yum/remi/packages/php-5.3.2-2.el5.remi.i386.rpm 。我应该只下载/提取最新版本并在其上运行配置命令吗?
  • @jonwayne - 默认情况下你不会有源文件。您需要单独获取它们。
  • 这就是我推荐的,是的。
猜你喜欢
  • 1970-01-01
  • 2014-01-30
  • 2016-06-22
  • 1970-01-01
  • 1970-01-01
  • 2015-07-21
  • 1970-01-01
  • 2012-02-21
  • 2015-07-26
相关资源
最近更新 更多