前些天一朋友在群里问:
编译php时没有加载ftp扩展 ,有什么方法么
已经在使用了
现在已经在跑网站了
编译php时没有加载ftp扩展 ,有什么方法么
能不在重新编译的情况下解决么
现在对方向要ftp 支持图片上传
其实这些可以先baidu或者google的,找不到答案,大部分是不会使用关键词来搜索。
# cd /usr/local/src/php-5.2.13/ext/ftp 进入源码目录的相应扩展模块文件夹
# /usr/local/php-5.2.13/bin/phpize 进入编译好的php相关目录,调用phpize程序生成编译配置文件
# ./configure --with-php-config=/usr/local/php-5.2.13/bin/php-config 注意php-config文件要存在
# make && make install
把生成的复制到php.ini中extension_dir指定的目录
然后php.ini加上extension=ftp.so
# service httpd restart
PHP官方介绍http://php.net/manual/en/install.pecl.phpize.php
附2012/4/10我又通过此方法安装了mcrypt.so
extension_dir=/usr/local/php5.2.13/lib/php/extensions/no-debug-zts-20060613/ (这是自动生成mcrypt.so的目录)
extension=mcrypt.so
Compiling shared PECL extensions with phpize
Sometimes, using the pecl installer is not an option. This could be because you're behind a firewall, or it could be because the extension you want to install is not available as a PECL compatible package, such as unreleased extensions from SVN. If you need to build such an extension, you can use the lower-level build tools to perform the build manually.
The phpize command is used to prepare the build environment for a PHP extension. In the following sample, the sources for an extension are in a directory named extname:
$ cd extname$ phpize$ ./configure$ make# make install
A successful install will have created extname.so and put it into the PHP extensions directory. You'll need to and adjust php.ini and add an extension=extname.so line before you can use the extension.
If the system is missing the phpize command, and precompiled packages (like RPM's) are used, be sure to also install the appropriate devel version of the PHP package as they often include the phpize command along with the appropriate header files to build PHP and its extensions.
Execute phpize --help to display additional usage information.