服务器运行一段时间后,可能突然会需求添加某个扩展,如curl、pdo、xmlrpc等,这就需要在不重新编译PHP的情况下独立添加扩展。
下面以安装curl为例,介绍具体安装步骤。
观察一下ubuntu下php的配置文件
生成配置文件,并编译生成模块:
/usr/local/php5/bin/phpize
./configure --with-curl=/usr/local/curl
--with-php-config=/usr/local/php5/bin/php-config
make
make install
这样,curl.so就被复制到PHP对应目录(如:/usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626/)
1.安装crul
wget http://curl.haxx.se/download/curl-7.19.6.tar.gz
tar -zxvf curl-7.19.6.tar.gz
cd curl-7.19.6
./configure --prefix=/usr/local/curl
make
make install
在ubuntu下以apt-get方式安装的nginx和php,php以php-cgi方式启动,php配置文件在/etc/php5/cgi 目录下,php.ini文件与Apache环境下不太一样,要开启curl不是在php.ini加上extension=curl.so就可以的。
2.编译生成扩展
进入php源程序目录中的ext目录中,这里存放着各个扩展模块的源代码,选择你需要的模块,比如curl模块:
cd curl
执行phpize生成编译文件,phpize在PHP安装目录的bin目录下
/usr/local/php5/bin/phpize
运行时,可能会报错:Cannot find autoconf. Please check your autoconf
installation and the $PHP_AUTOCONF
environment variable is set correctly and then rerun this
script.“,需要安装autoconf:
yum install autoconf(RedHat或者CentOS)、apt-get install
autoconf(Ubuntu Linux)
本文由美洲杯赔率发布于计算机教程,转载请注明出处:美洲杯赔率Linux 主机独立添加PHP扩展模块