http://www.laruence.com/2009/04/28/719.html
注意在window下我们经常下载dll文件,然后放在扩展目录中,但是在linux下dll不能使用,对应的是so文件。
在LINUX下使用源码安装php
./configure --prefix=。。。。。--enable-php-fpm
这样会没有安装curl openssl mbstring mysqli gd库等
最好是在安装php的时候直接./configure --with-XXXX,要支持的扩展都安装上,因为本文安装时并没有不支持扩展,所以这里在安装后php,不支持扩展的情况下的解决办法。
很多文章都将在php.ini文件中直接将extension=前的;去掉,但是不能实现,我们要在找到php的安装源码中ext文件中生成扩展包.so,然后复制到extension的搜索目录中,并且在php.ini文件中添加extension=XX.so,最后再重启nginx php-fpm即可。
1 curl
(1)cd php-5.6.8/ext/curl
(2)# phpize
phpize是用来扩展php扩展模块的,通过phpize可以建立php的外挂模块,执行后会生成configure文件。
不能执行就find / -name "phpize" 找到phpize的路径。然后执行 # /XXX/phpize;
(3)然后执行
# ./configure--with-curl --with-php-config=/home/XX/php/bin/php-config
(4)# make ; make test; make
(5) # cp curl.so XX
XX 是php.ini 文件中extension-dir=“XX” 的路径‘’
(6)修改php.ini
extension=curl.so
2 openssl 同上
3 mbstring 不同在(3)步,其他一样
./configure--enable-mbstring--with-php-config=/home/XX/php/bin/php-config
4 mysql mysqli的支持其中第(3)步:./configure--with-php-config=/home/XX/php/bin/php-config--with- mysql=/home/XX/mysql/mysql/
with-mysql=mysql安装位置mysqli安装:
其中第(3)步: ./configure--with-mysqli--with-php-config=/home/XX/php/bin/php-config
会出错:关于mysqli_api.c内找不到mysqlnd的。。。。。
直接修改mysqli_api.c中include的路径,采用绝对路径
5 gd 需要支持jpeg freetype png 等在编译扩展中,我的出现不支持jpeg freetype
这是需要查看是否安装jpeg freetype 其中jpeg安装参照6
# ./configure --with-gd --with-jpeg-dir=/home/XX/jpeg --with-freetype-dir=/usr/include/freetype2 --with-php-config=/home/XX/php/bin/php-config
需要指定安装位置
6 安装jpeg
这里安装的6
解压后:
# cd jpeg6b
# ./configure --prefix=安装路径--enable-shared --enable-
static
#make && make install
出现错误:
/usr/bin/install: 无法创建普通文件"/usr/local/man/man1/cjpeg.1": 没有那个文件或目录
make: *** [install] 错误 1
解决:
# mkdir -p /usr/local/man/man1 然后在make install即可。