系统:Ubuntu 12.04
核心:Linux 3.2.0-45-generic
PHP版本:5.4.9
要求:
1.已安装好php;
2.php源码;
以添加mbstring(iconv,sqlite,ftp,mysqli,odbc,pdo,openssl等都类似)扩展为例,假设php的安装目录为:/usr/local/php,php源码的目录为:/usr/local/src/php-5.4.9/,添加扩展的步骤为:
1.进入php源码mbstring扩展的目录;
$cd /usr/local/src/php-5.4.9/ext/mbstring
2.执行phpize命令生成configure配置文件
$phpize
3.执行configure
$./configure --with-php-config=/usr/local/php/bin/php-config
4.make
$make
5.make install
$make install
6.把编译生成的扩展链接文件(一般放在/usr/local/php/lib/php/extensions/目录下)拷贝到你php.ini配置文件extension_dir配置
指令配置的目录里,如果没有配置extension_dir,需要添加上这个配置指令。最好是放在如:/usr/local/php/ext这样的目录下;
7.修改php.ini配置添加如下配置:
extension=mbstring.so
8.重启你的php,检测一下扩展是否已经添加上了,
如果添加上了,那恭喜你又进步了。