首頁 >後端開發 >php教程 >linux下安裝 php GD支援庫的方法

linux下安裝 php GD支援庫的方法

WBOY
WBOY原創
2016-07-25 08:56:35984瀏覽
  1. gd-2.0.33.tar.gz http://www.boutell.com/gd/
  2. jpegsrc.v6b.tar.gz http:// www.ijg.org/
  3. libpng-1.2.7.ta​​r.tar http://sourceforge.net/projects/libpng/
  4. zlib-1.2.2.tar.gz http://sourceforge.net/ projects/zlib/
  5. freetype-2.1.9.tar.gzhttp://sourceforge.net/projects/freetype/
  6. php-4.3.9.tar.gz http://www.php.net
複製程式碼

二、安裝

1.安裝zlib

  1. tar zxvf zlib-1.2.2.tar.gz
  2. cd zlib-1.2.2
  3. ./configure
  4. >make install
複製程式碼
2.安裝libpng

  1. tar zxvf libpng-1.2.7.ta​​r.tar
  2. cd libpng-1.2.7
  3. cd scripts/
  4. cd libpng-1.2.7
  5. cd scripts/
  6. cd libpng-1.2.7
  7. cd scripts/
  8. mv. linux ../makefile
  9. cd ..
make
make install

複製程式碼

注意,這裡的makefile不是用./configure生成,而是直接從scripts/裡拷出一個
3.安裝freetype
  1. tar zxvf freetype-2.1.9.tar.gz
  2. cd freetype-2.1.9
./configure
cd freetype-2.1.9./configuremake
make install

複製程式碼
  1. 4.安裝Jpeg
  2. tar zxvf jpegsrc.v6b.tar.gz
  3. cd jpeg-6b/
./configure --enable-sharedmake testmake 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-jpegmake install

複製程式碼
    上面的安裝步驟是沒有設定安裝目錄的,測試重新編譯PHP時用上面方法均可。 若要指定安裝位址,請採用以下方式,建議定義安裝目錄。 1.安裝 zlib
  1. wget ftp://ftp.sunfreeware.com/pub/freeware/SOURCES/zlib-1.2.3.tar.gz
  2. tar -zxf zlib-1.2.3.tar.gz
  3. cd zlib-1.2.3
./configure –prefix=/usr/local/zlib
make make install

make install
  1. 複製程式碼
  2. 2、安裝jpeg
  3. wget ftp://ftp.sunfreeware.com/pub/freeware/SOURCES/jpeg-6b.tar.gz
  4. mkdir -p /usr /local/jpeg6
  5. mkdir -p /usr/local/jpeg6/bin
  6. mkdir -p /usr/local/jpeg6/lib
  7. mkdir -p /usr/local/jpeg6/include -p /usr/local/jpeg6/man
mkdir -p /usr/local/jpeg6/man1
mkdir -p /usr/local/jpeg6/man/man1 tar -zxf jpeg-6b. tar.gz cd jpeg-6b
./configure –prefix=/usr/local/jpeg6 –enable-shared –enable-static

make

make install
make
    make install
  1. 複製程式碼
  2. 安裝完成提示: Libraries have been installed in: /usr/local/jpeg6/lib 3.安裝 libpng

wget ftp://ftp.sunfreeware.com/pub/freeware/SOURCES/libpng-1.2.16.tar.gz

tar -zxf libpng-1.2.16.tar.gz
cd libpng-1.2.16
./configure –prefix=/usr/local/libpng
    make
  1. make install
  2. make
  3. make install
  4. 複製代碼
  5. 4、安裝freetype

wget http://download.savannah.nongnu.org/releases/freetype/freetype-2.3.4.tar.gz

tar -zxf freetype-2.3.4.tar.gz
cd freetype-2.3.4
mkdir -p /usr/local/freetype
    ./configure –prefix=/usr/local/freetype
  1. make
  2. make install
  3. 複製程式碼
  4. 5、安裝GD

wget ftp://ftp.sunfreeware.com/pub/freeware/SOURCES/gd-2.0.33.tar.gz

tar -zxf gd-2.0.33.tar.gz
cd gd-2.0.33
mkdir -p /usr/local/gd2
    ./configure –prefix=/usr/local/gd2 –with-jpeg= /usr/local/jpeg6/ –with-png=/usr/local/lib/ –with-zlib=/usr/local/lib/ –with-freetype=/usr/local/freetype/
  1. make
  2. make install
  3. 複製程式碼
安裝jpg時,如果出錯,則需要先裝libtool: libtool-1.X.tar.gz //是我下載的版本
./configure make make install 再裝jpegsrc.v6b.tar.gz ./config集 -- enable-shared --enable-static 這些lib這種套件用預設路徑就行。 複製程式碼

不然如果其他的需要這個包還得指它的路徑 這裡可能會出錯 checking host system type… Invalid configuration `x86_64-unknown-linux-gnu ‘: machine `x86_64-unknown ‘ not recognized checking build system type… Invalid configuration `x86_64-unknown-linux-gnu ‘: machine `x86_64-unknown ‘ not recognized configure: error: libtool configure failed 或者 /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 解決方法 cp /usr/share/libtool/config/config.guess . cp /usr/share/libtool/config/config.sub . cp到jpeg的安裝檔目錄,注意後面的個“.” make clean 再重新 ./configure --prefix=/usr/local/libjpeg/ --enable-shared --enable-static make make install -------------------------------- 如果已經安裝php,建議透過追加編譯安裝 進入「[php解壓縮目錄]/ext/gd」目錄,執行下列指令: [php安裝目錄]/bin/phpize ./configure --with-php-config=[php安裝目錄]/bin/php-config --with-jpeg=[jpeg-6b安裝目錄] --with-png=[libpng安裝目錄] --with- freetype=[freetype安裝目錄] --with-gettext=[gettext安裝目錄] --with-gd=[gd安裝目錄] make make install 安裝成功後會在「[php安裝目錄]/lib/php/extensions/no-debug-non-zts-20060613」目錄下產生gd.so文件, 然後cp [php安裝目錄]/lib/php/extensions/no-debug-non-zts-20060613/gd.so /opt/php/ext 修改php.ini檔案載入gd元件,新增extension_dir=/opt/php/ext和extension=gd.so,如果有extension_dir=/opt/php/ext則不需要增加 extension_dir=/opt/php/ext extension=gd.so



陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn