一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

linux中给php添加扩展方法

时间:2014-04-24 编辑:简简单单 来源:一聚教程网

例子

(1).重新编译一遍PHP(这种方法要编译的东西比较多,因此比较费时),

(2).单独编译FTP扩展然后配置php支持该扩展(这种方式比较省时,因此选用这种方式进行)

(1).解压PHP源码

tar xvf php-5.3.5.tar.bz2

cd php-5.3.5

(2).进入ftp扩展目录编译

cd ext/ftp

(3).运行phpize,为PHP扩展编译做准备

$PREFIX/php/bin/phpize

(4).配置ftp扩展(php-config是获取PHP环境的命令)

./configure --with-php-config=$PREFIX=/php/bin/php-config

(5).编译和安装

make && make install

说明:安装好后会显示扩展安装到的目录,如

$PREFIX/php/lib/php/extensions/no-debug-zts-20090626/

(6).配置php.ini加入:

extension_dir=$PREFIX/lib/php/extensions/no-debug-zts-20090626

extension=ftp.so

(7).重启Apache服务器即可生效

service httpd restart

例子 hpize 命令是用来准备 PHP 外挂模块的编译环境的。下面例子中,外挂模块的源程序位于 extname 目录中:

$ cd extname

$ phpize

$ ./configure (注一)

$ make

$ make install

成功的安装将建立 extname.so 并放置于 PHP 的外挂模块目录中 (预设存放于 /usr/lib/php/modules/ 内) 。

需要调整 php.ini,加入 extension=extname.so 这一行之后才能使用此外挂模块。


编译添加扩展

编译PHP所需要的支持
yum install gcc
yum install libxml2-devel curl-devel libjpeg libjpeg-devel libpng-devel freetype-devel.x86_64 mysql-devel
yum install freetype-devel.x86_64  freetype.x86_64
yum install libjpeg libjpeg-devel

下载PHP:wget http://us1.php.net/distributions/php-5.3.28.tar.bz2

tar -jxf php-5.3.28.tar.bz2
cd php-5.3.28

./configure  –prefix=/usr/local/php-5.3.28  –enable-fpm  –with-mysql  –with-zlib  –with-config-file-path=/usr/local/php5.3.28/etc  –with-pdo-mysql   –with-libdir=lib64 –with-gd –with-jpeg-dir=/usr/lib –with-png-dir=/usr/lib –enable-mbstring –enable-gd-native-ttf –enable-xml  –with-freetype-dir –with-curl  –enable-ftp  –enable-zip –with-mcrypt  –enable-mbstring  –enable-json

 

出现失败

checking for alloca… (cached) yes
checking for 8-bit clean memcmp… yes
checking for stdarg.h… (cached) yes
checking for mcrypt support… yes
configure: error: mcrypt.h not found. Please reinstall libmcrypt

rpm -qa | grep libmcrypt
libmcrypt-2.5.7-5.el5
libmcrypt-2.5.8-4.el5.centos

有但是失败,上面的是用yum安装,不对,难道需要去下载包编译??试试呗:

wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz 安装:
tar -zxvf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure
make
make install

热门栏目