php依赖安装及常见问题汇总
一、GD安装
安裝 GD 前需要安裝 jpeg-6b, libpng, zlib, freetype。以下是下载网址:
http://www.libgd.org/Downloads GD下载
ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz JPEG下载
http://www.libpng.org/pub/png/libpng.html png下载
http://www.zlib.net/zlib-1.2.3.tar.gz zlib下载
http://www.freetype.org/ freetype下载
- 安装zlib
tar zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure
make
make install
2.安装 libpng
tar zxvf libpng-1.2.29.tar.gz
cd libpng-1.2.29
cd scripts/
mv makefile.linux ../makefile
cd ..
make
make install
注意,这里的makefile不是用./configure生成,而是直接从scripts/里拷一个
3.安装freetype
tar zxvf freetype-2.1.10.tar.gz
cd freetype-2.1.10
./configure --prefix=/usr/local
make
make install
4.安装Jpeg
tar -zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b/
mkdir -p /usr/local/jpeg6
mkdir -p /usr/local/jpeg6/include
mkdir -p /usr/local/jpeg6/lib
mkdir -p /usr/local/jpeg6/bin
mkdir -p /usr/local/jpeg6/man
mkdir -p /usr/local/jpeg6/man/man1
./configure –prefix=/usr/local/jpeg6 --enable-shared
make
make
install-lib
make install
make
clean
注意,这里configure一定要带--enable-shared参数,不然,不会生成共享库
5.安装GD
tar zxvf gd-2.0.33.tar.gz
cd gd-2.0.33
./configure --with-png --with-freetype --with-jpeg
make install
如果GD报错:configure.ac:64:
warning: macro `AM_ICONV' not found in library
你就make
clean一下,然后再make
如果你安装别的出现libtool没有找到,你就从/usr/bin/libtool cp 一个过来用就好了!
在64位下编译GD 如果/usr/bin/ld:
/usr/local/lib/libz.a(compress.o): relocation R_X86_64_32 against `a local
symbol' can not be used when making a shared object; recompile with -fPIC
这说明zlib没用用-fPIC进行编译修改zlib的Makefile
CFLAGS=-O3 -DUSE_MMAP -fPIC
make;make install然后再编译gd
就过去了!
二、Linux下安装过程中编译PHP时报错:configure: error: libjpeg.(a|so) not found
在Linux下安装PHP过程中,编译时出现configure: error: libjpeg.(a|so) not found 错误的解决办法
检查之后发现已经安装了libjpeg
[root@localhost php-5.2.14]# yum list
installed|grep libpng
libpng.x86_64
2:1.2.49-1.el6_2
或者:
[root@localhost php-5.2.14]# rpm -qa|grep
libjpeg
libjpeg-turbo-1.2.1-3.el6_5.x86_64
安装libjpeg-devel
yum -y install libjpeg-devel
[root@localhost php-5.2.14]# yum list
installed|grep libjpeg
libjpeg-turbo.x86_64 1.2.1-3.el6_5
@base
libjpeg-turbo-devel.x86_64
[root@localhost php-5.2.14]# rpm -ql libjpeg-turbo-devel.x86_64
/usr/include/jconfig.h
/usr/include/jerror.h
/usr/include/jmorecfg.h
/usr/include/jpeglib.h
/usr/lib64/libjpeg.so
/usr/share/doc/libjpeg-turbo-devel-1.2.1
/usr/share/doc/libjpeg-turbo-devel-1.2.1/coderules.txt
/usr/share/doc/libjpeg-turbo-devel-1.2.1/example.c
/usr/share/doc/libjpeg-turbo-devel-1.2.1/jconfig.txt
/usr/share/doc/libjpeg-turbo-devel-1.2.1/libjpeg.txt
/usr/share/doc/libjpeg-turbo-devel-1.2.1/structure.txt
但是在/usr/lib目录下没有libjpeg.so这个文件,在/usr/lib64下是有的,虽然使用–with-jpeg-dir=/usr/lib64
依然无效,最后用
[root@ www.linuxidc.com ~]#ln -s
/usr/lib64/libjpeg.so.62 /usr/lib/libjpeg.so
问题解决, libpng 报的错误解决方法一样
configure: error: png.h not found.错误的解决方法
转自:http://51yanyu.net/wangluo/20140704_9729.html
今天安装PHP的时候提示这个错误 configure: error: png.h not found.,这个是选择安装GD模块才会出现的错误,详细错误信息如下
If configure fails try --with-vpx-dir=<DIR>
If configure fails try --with-jpeg-dir=<DIR>
configure: error: png.h not found.
我找了下资料说是libpng没有安装,于是我执行命令
$>yum install libpng
但是并没有解决,想了下是不是还有什么devel包没安装吧,试了下面这个命令
$> yum install libpng-devel
终于解决了,呵呵。记录下来,方便大家和自己下次查看。
configure:
error: Cannot find ldap.h
[root@localhost php-5.2.14]# yum list installed|grep ldap
apr-util-ldap.x86_64 1.3.9-3.el6_0.1
@anaconda-CentOS-201303020151.x86_64/6.4
openldap.x86_64
2.4.39-8.el6 @base
list
yum list openldap
yum list openldap-devel
安装 :
yum install openldap-devel
三、常见的 libphp5.so文件无法生成的问题
由于好久没有搭环境,在linux上搭apache、php的环境时,遇到libphp5.so 无法生成这个问题,我也困扰了我半天,很是郁闷。从网上找了各种资料,都是瞎转载,太无聊的一堆人了,自己成功没有成功的先转载,鄙视。 害的我尝试了半天也没有解决。下面列出我的正确解决办法:
常见问题一:配置apache打开libphp5.so文件后提示错误
/usr/local/apache2/modules/libphp5.so: No such file or directory
解答: 发现modules下面没有libphp5.so文件,说明安装apache2的时候配置有问题,需要重新编译安装,必须采用 ./configure --enable-so 这种方式。然后重新安装 make clean -> make -> make install。 然后重新安装php,安装时要求采用./configure --with-apxs2=/usr/local/apache2/bin/apxs 这种方式 然后 make & make install。如果还出现这个问题,可以重新安装一下apache 和 php
libphp5.so是php5提供的,你还需要编译php5才能生成这个文件
你在PHP的configure的时候,加上:
--with-apxs2=/usr/local/apache/bin/apxs
这样就会自动编译一个libphp5.so出来了。
常见问题二:在centOS中 配置apache的php时提示错误
cannot restore segment prot after reloc: Permission denied
解答:可以百度查看资料,关于centOS中的selinux。SELINUX的问题,对LIB库的保护。
关闭 SELINUX
vi /etc/selinux/config
#SELINUX=enforcing #注释掉
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加
:wq!#保存退出
shutdown -r now#重启系统
四、centos7-php安装gd库扩展以及freetype
先安装freetype
1:下载: wget "http://download.savannah.gnu.org/releases/freetype/freetype-2.4.0.tar.bz2"
2: 解压: tar jxvf freetype-2.4.0.tar.bz2
3:进入 freetype-2.4.0
4:./configure --prefix=/usr/local/freetype && make && make install
1,进入之前解压的php文件夹里面/usr/local/php-5.6.5/ext/gd里面
2,运行 phpize 然后:make clean再 运行./configure --with-freetype-dir=/usr/local/freetype
3,如果出现错误:configure: error: png.h not found.
4:执行下面两条命令即可解决
经查资料说是libpng,devel包没安装
yum install libpng
yum install libpng-devel
然后重新编译安装就行了,运行./configure --with-freetype-dir=/usr/local/freetype
之后make 即可 不用make install
5:在/usr/local/php-5.6.5/ext/gd/modules/找到 gd.so 拷贝到/usr/local/php/etc/
6:修改php.ini
之后重启php-fpm
7:phpinfo查看
五、make: ./libtool:command not found
./libtool --mode=compile gcc -O2 -I. -c ./jcapimin.c
make: ./libtool:命令未找到
make: *** [jcapimin.lo] 错误 127
./libtool --mode=compile gcc -O2 -I. -c ./cjpeg.c
make: ./libtool:命令未找到
make: *** [cjpeg.lo] 错误 127
问题原因:没有安装 libtool
解决办法:首先看有没有安装libtool 及 libtool-ltdl-devel
rpm -qa | grep libtool
下面安装libtool:
libtool见附件或者我的资源
./configure
make
make install
#cd jpeg-6b
#cp /usr/share/libtool/config/config.sub .
#cp /usr/share/libtool/config/config.guess .
把 libtool里面的两个配置文件拿来覆盖掉jpeg-6b目录下的对应文件
make clean 再重新configure(切记必须重新configure,否则仍提示这个错误)
没有权限的时候先建立对应的文件夹,再次make install就行了
然后进入jpeg-6b的源码目录,然后执行以下步骤,切记!COPY到当前目录注意后面的点(.)
网上好多都把config.sub和config.guess的路径弄错了,应该是在/usr/share/libtool/config/下,而不是在
/usr/share/libtool/下

浙公网安备 33010602011771号