Heim  >  Artikel  >  php教程  >  linux下用phpize给PHP动态添加扩展

linux下用phpize给PHP动态添加扩展

WBOY
WBOYOriginal
2016-06-13 10:33:47951Durchsuche

  使用php的常见问题是:编译php时忘记添加某扩展,后来想添加扩展,但是因为安装php后又装了一些东西如PEAR等,不想删除目录重装,别说,php还真有这样的功能。

  我没有在手册中看到。

  如我想增加bcmath支持,这是一个支持大整数计算的扩展。windows自带而且内置,linux“本类函数仅在 PHP 编译时配置了 --enable-bcmath 时可用”(引号内是手册中的话)

  幸好有phpize,

  方法是,要有与现有php完全相同的php压缩包。我用的是php-5.2.6.tar.gz。

  展开后进入里面的ext/bcmath目录

  然后执行/usr/local/php/bin/phpize,这是一个可执行的文本文件,要确保它在系统中

  会发现当前目录下多了一些configure文件,

  如果没报错,则

  Php代码

  ./configure --with-php-config=/usr/local/php/bin/php-config

  注意要先确保/usr/local/php/bin/php-config存在。

  如果你的php安装路径不是默认的,要改。

  如果没有报错,则make,再make install ,然后它告诉你一个目录

  你把该目录下的bcmath.so拷贝到你php.ini中的extension_dir指向的目录中,

  修改php.ini,在最后添加一句extension=bcmath.so

  重启apache.

 

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:理解PHP字符串原理Nächster Artikel:PHP获文件扩展名的三种方法