3
瀏覽器會顯示錯誤消息試圖建立PHP和GD與PNG和JPEG支持
Fatal error: Call to undefined function imagecreatefrompng() in...
這裏是一個失敗的源代碼:
$img = imagecreatefrompng($file);
這是一個本地的PHP函數。
我打算構建GD和PHP。
的GD libgd-2.2.4
圖書館建得很好:
Support for Zlib: yes
Support for PNG library: yes
Support for JPEG library: yes
Support for WebP library: no
Support for TIFF library: no
Support for Freetype 2.x library: yes
Support for Fontconfig library: no
Support for Xpm library: yes
Support for liq library: no
Support for pthreads: yes
我使用的命令:
./configure \
--prefix=/home/stephane/programs/install \
--with-jpeg=/home/stephane/programs/install \
--with-png=/home/stephane/programs/install \
--with-freetype=/home/stephane/programs/install \
--with-zlib=/home/stephane/programs/install \
--with-xpm
make
make install
的make
和make install
命令是成功的。
的PHP php-5.6.30
引擎也建立了良好:
checking for GD support... yes
checking for the location of libvpx... no
checking for the location of libjpeg... /home/stephane/programs/install
checking for the location of libpng... /home/stephane/programs/install
checking for the location of libXpm... no
checking for FreeType 2... /home/stephane/programs/install
checking for T1lib support... no
checking whether to enable truetype string function in GD... yes
checking for gdSetErrorMethod in -lgd... yes
checking for gdImageCreateFromPng in -lgd... yes
checking for gdImageCreateFromWebp in -lgd... no
checking for gdImageCreateFromJpeg in -lgd... yes
checking for gdImageCreateFromXpm in -lgd... yes
checking for gdImageStringFT in -lgd... yes
checking for gdVersionString in -lgd... yes
checking for gdImageCreate in -lgd... yes
我使用的命令:
./configure \
--prefix=/home/stephane/programs/install \
--with-apxs2=/home/stephane/programs/install/apache/bin/apxs \
--with-config-file-path=/home/stephane/programs/php-5.6.30/ \
--with-mysql=/home/stephane/programs/install/mariadb \
--with-mysqli=/home/stephane/programs/install/mariadb/bin/mysql_config \
--with-pdo-mysql=/home/stephane/programs/install/mariadb \
--with-zlib-dir=/home/stephane/programs/install \
--with-jpeg-dir=/home/stephane/programs/install \
--with-png-dir=/home/stephane/programs/install \
--with-gd=/home/stephane/programs/install \
--enable-gd-native-ttf \
--with-freetype-dir=/home/stephane/programs/install \
--enable-ftp \
--enable-xml \
--enable-zip \
--with-bz2 \
--enable-wddx \
--enable-libgcc \
--without-pear \
--enable-mbstring \
--enable-intl \
--enable-calendar \
--with-openssl \
--with-curl \
--enable-debug \
--disable-phar \
--enable-fpm \
--with-oci8=instantclient,/home/stephane/programs/oracle/instantclient_11_2
make
make install
的make
和make install
命令也是成功的。
下面是創建的庫文件:
$ ll /home/stephane/programs/install/lib/
total 22M
-rw-r--r-- 1 stephane 6,3M juin 12 14:30 libfreetype.a
-rwxr-xr-x 1 stephane 1,1K juin 12 14:30 libfreetype.la*
lrwxrwxrwx 1 stephane 21 juin 12 14:30 libfreetype.so -> libfreetype.so.6.13.0*
lrwxrwxrwx 1 stephane 21 juin 12 14:30 libfreetype.so.6 -> libfreetype.so.6.14.0*
-rwxr-xr-x 1 stephane 3,0M juin 12 14:30 libfreetype.so.6.13.0*
-rwxr-xr-x 1 stephane 3,1M juin 10 13:11 libfreetype.so.6.14.0*
-rw-r--r-- 1 stephane 1,7M juin 12 15:08 libgd.a
-rwxr-xr-x 1 stephane 1,2K juin 12 15:08 libgd.la*
lrwxrwxrwx 1 stephane 14 juin 12 15:08 libgd.so -> libgd.so.3.0.4*
lrwxrwxrwx 1 stephane 14 juin 12 15:08 libgd.so.3 -> libgd.so.3.0.4*
-rwxr-xr-x 1 stephane 1,1M juin 12 15:08 libgd.so.3.0.4*
-rw-r--r-- 1 stephane 2,2M juin 7 12:36 libjpeg.a
-rwxr-xr-x 1 stephane 938 juin 7 12:36 libjpeg.la*
lrwxrwxrwx 1 stephane 16 juin 7 12:36 libjpeg.so -> libjpeg.so.9.2.0*
lrwxrwxrwx 1 stephane 16 juin 7 12:36 libjpeg.so.9 -> libjpeg.so.9.2.0*
-rwxr-xr-x 1 stephane 1,2M juin 7 12:36 libjpeg.so.9.2.0*
-rw-r--r-- 1 stephane 1,7M juin 10 12:43 libpng16.a
-rwxr-xr-x 1 stephane 958 juin 10 12:43 libpng16.la*
lrwxrwxrwx 1 stephane 19 juin 10 12:43 libpng16.so -> libpng16.so.16.29.0*
lrwxrwxrwx 1 stephane 19 juin 10 12:43 libpng16.so.16 -> libpng16.so.16.29.0*
-rwxr-xr-x 1 stephane 905K juin 10 12:43 libpng16.so.16.29.0*
lrwxrwxrwx 1 stephane 10 juin 10 12:43 libpng.a -> libpng16.a
lrwxrwxrwx 1 stephane 11 juin 10 12:43 libpng.la -> libpng16.la*
lrwxrwxrwx 1 stephane 11 juin 10 12:43 libpng.so -> libpng16.so*
-rw-r--r-- 1 stephane 151K juin 5 22:46 libz.a
lrwxrwxrwx 1 stephane 14 juin 5 22:46 libz.so -> libz.so.1.2.11*
lrwxrwxrwx 1 stephane 14 juin 5 22:46 libz.so.1 -> libz.so.1.2.11*
-rwxr-xr-x 1 stephane 120K juin 5 22:46 libz.so.1.2.11*
drwxrwxr-x 4 stephane 4,0K juin 8 17:08 php/
drwxrwxr-x 2 stephane 4,0K juin 12 15:08 pkgconfig/
但一看phpinfo
顯示不完整的GD部分:
GD Support enabled
GD headers Version 2.2.4
GD library Version 2.2.4
GIF Read Support enabled
GIF Create Support enabled
WBMP Support enabled
XPM Support enabled
libXpm Version 30411
XBM Support enabled
沒有安裝任何默認包:
$ sudo apt-cache show libpng
N: Impossible de trouver le paquet libpng
E: Aucun paquet n'a été trouvé
[[email protected] fatec]
$ sudo apt-cache show libjpeg
N: Impossible de trouver le paquet libjpeg
E: Aucun paquet n'a été trouvé
這裏有一點關於我的操作系統和機器:
$ uname -a
Linux stephane-ThinkPad-X201 4.4.0-79-generiC#100-Ubuntu SMP Wed May 17 19:58:14 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
我的Apache配置沒有指向正確的PHP目錄:
<IfModule mod_php5.c>
PHPIniDir "/home/stephane/programs/php-5.6.30"
</IfModule>
$ ll /home/stephane/programs/php-5.6.30/php.ini
-rw-r--r-- 1 stephane 73K juin 12 14:05 /home/stephane/programs/php-5.6.30/php.ini
考慮分享一些您的代碼,其中包含錯誤或不工作。 –
這是一個本地PHP函數調用。沒有更多的代碼需要。 – Stephane
同樣,錯誤表示該函數未定義。 – Stephane