LINUX 安装PHP GD库遇到的坑

 本文借鉴:https://www.cnblogs.com/gaohj/p/3152646.html

linux下为php添加GD库的步骤如下: 

一、下载 

gd-2.0.33.tar.gz http://www.boutell.com/gd/ 
jpegsrc.v6b.tar.gz http://www.ijg.org/ 
libpng-1.6.21.tar.tar http://sourceforge.net/projects/libpng/ 
zlib-1.2.8.tar.gz http://sourceforge.net/projects/zlib/ 
freetype-2.1.9.tar.gz http://sourceforge.net/projects/freetype/ 

(zlib-1.2.8与libpng-1.6.21  版本匹配 自己找版本)

二、安装 (复制版本可能对不上别直接复制用)

1.安装zlib 

tar zxvf zlib-1.2.2.tar.gz 
cd zlib-1.2.2 
./configure 
make 
make install 

2.安装libpng 

tar zxvf libpng-1.2.7.tar.tar 
cd libpng-1.2.7 
cd scripts/ 
mv makefile.linux ../makefile 
cd .. 
make 
make install 
注意,这里的makefile不是用./configure生成,而是直接从scripts/里拷一个 

【出错的话:collect2: ld returned 1 exit status

make: *** [pngtest] Error 1

可以直接编译./configure –prefix=/usr/local/libpng】


3.安装freetype 

tar zxvf freetype-2.1.9.tar.gz 
cd freetype-2.1.9 
./configure 
make 
make install 

4.安装Jpeg 

tar zxvf jpegsrc.v6b.tar.gz 
cd jpeg-6b/ 
./configure --enable-shared 
make 
make test 
make install 
注意,这里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 

 

三:进入到 我的服务器地址是(/usr/local/src)里面的PHP源文件里面的GD(/usr/local/src/php-7.1.24/ext/gd) 上面都安装好了后shell运行 

./configure --with-php-config=/usr/local/php/bin/php-config --with-jpeg-dir=/usr/local/jpeg --with-png-dir=/usr/local/libpng --with-freetype-dir=/usr/local/freetype

然后 :make 再然后 make install  再然后 重启PHP-FPM 通过 php -m查看是否有GD 或者通过PHP info看是否安装上

注:每一个命令执行玩记得看是否报错,报错就去检查问题

 

搞定收工

猜你喜欢

转载自www.cnblogs.com/langgezuishuai/p/10687940.html