天天看點

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看是否安裝上

注:每一個指令執行玩記得看是否報錯,報錯就去檢查問題      
LINUX 安裝PHP GD庫遇到的坑
LINUX 安裝PHP GD庫遇到的坑
LINUX 安裝PHP GD庫遇到的坑

搞定收工

轉載于:https://www.cnblogs.com/langgezuishuai/p/10687940.html