安裝擴展支持jpeg格式:php
第一步:首先下載文件: 版本v8: wget http://www.ijg.org/files/jpegsrc.v8b.tar.gz 版本v9: wget http://www.ijg.org/files/jpegsrc.v9c.tar.gz 把jpeg安裝到home目錄:
./configure --prefix=/home/jpeg --enable-shared --enable-static make && make install 第二步:安裝到配置文件中 1、找到php 源碼目錄 cd /home/ubuntu/downphp/php-7.0.0 2、進入 ext/gd 目錄 cd /home/ubuntu/downphp/php-7.0.0/ext/gd 3、執行命令:/home/php/bin/phpize [root@daokr gd]#/home/php/bin/phpize Configuring for: PHP Api Version: 20151012 Zend Module Api No: 20151012 Zend Extension Api No: 320151012 4、注意 with-freetype-dir 路徑必須加載不然報錯 ./configure --with-php-config=/home/php/bin/php-config --with-jpeg-dir=/home/jpeg --with-freetype-dir=/usr/local/include/freetype2 5、make && make install 6、重啓 httpd 若是上面的步驟解決不了那就從新安裝php吧:
記得把
--with-jpeg-dir=/home/jpeg 加上
從新安裝phpconfigmysql
./configure --prefix=/home/php --with-config-file-path=/home/php/etc --with-fpm-user=ubuntu --with-fpm-group=ubuntu --with-pdo-mysql --with-openssl --with-pear --with-mhash --with-xmlrpc --with-zlib --with-mcrypt --with-curl --with-jpeg-dir=/home/jpeg --with-gd --with-freetype-dir=/usr/local/include/freetype2 --without-sqlite3 --without-pdo-sqlite --disable-rpath --without-pear --enable-fpm --enable-maintainer-zts --enable-pcntl --with-tsrm-pthreads --enable-mbstring --enable-mbregex --enable-bcmath --enable-zip --enable-sockets --enable-soap --enable-gd-native-ttf --enable-xml --enable-inline-optimization --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
liconv close 錯誤解決:vim MakeFilesql
EXTRA_LIBS = -lcrypt -lz -lresolv -lcrypt -lmcrypt -lltdl -lpng -lz -ljpeg -lcurl -lz -lrt -lm -ldl -lnsl -lxml2 -lssl -lcrypto -lcurl -lxml2 -lssl -lcrypto -lfreetype -lxml2 -lxml2 -lcrypt -lxml2 -lxml2 -lxml2 -lxml2 -lssl -lcrypto -lcrypt -liconv
這個版本不能用imagecreatefromjpeg:ubuntu
Warning: imagecreatefromjpeg(): gd-jpeg: JPEG library reports unrecoverablevim
爲啥呢;百度了半天沒解決最後仍是從新編譯php安裝了。curl
最終仍是從新編譯了PHP配置socket
1 ./configure --prefix=/home/php --with-config-file-path=/home/php/etc --with-fpm-user=ubuntu --with-fpm-group=ubuntu --with-pdo-mysql --with-openssl --with-pear --with-mhash --with-xmlrpc --with-zlib --with-mcrypt --with-curl --with-jpeg-dir --with-png-dir --with-gd --with-freetype-dir=/usr/local/include/freetype2 --without-sqlite3 --without-pdo-sqlite --disable-rpath --without-pear --enable-fpm --enable-maintainer-zts --enable-pcntl --with-tsrm-pthreads --enable-mbstring --enable-mbregex --enable-bcmath --enable-zip --enable-sockets --enable-soap --enable-gd-native-ttf --enable-xml --enable-inline-optimization --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-ftp --with-gettext --enable-opcache
$f = 'uploads/face/010/00/00/2296f8b53a3324e528ff37cba61cb14f_240_240.jpg'; var_dump(getImageSize($f)); $a = imagecreatefromjpeg($f); var_dump($a);die;
成功輸出:url