`
ling凌yue月
  • 浏览: 334253 次
  • 性别: Icon_minigender_1
  • 来自: 郑州
社区版块
存档分类
最新评论

linux安装php,gd支持jpeg

阅读更多
这几天弄一个项目的服务器,一同事突然告诉我报错误了
:Fatal error: Call to undefined function imagecreatefromjpeg()

解决办法:
[size=large]
1,重新安装php不要安装gd
[size]
#./configure --prefix=/usr/local/php --with-config-file-path=/etc \
--with-mysql=/usr/local/mysql --with-iconv-dir \
 --with-zlib --with-libxml-dir --enable-xml --disable-debug --disable-rpath \
--enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop \ --enable-sysvsem --enable-inline-optimization --with-curl \
--with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm \
--with-iconv=/usr/local --enable-force-cgi-redirect --enable-mbstring  --with-openssl \
#make && make install

2,分别在/lib、/usr/lib、/usr/local/lib 下面都加上libjpeg.so库(软连接就行)
ln -sv /usr/lib/libjpeg.so.62.0.0 /lib/libjpeg.so

3,进入php源码下的ext/gd目录下,编译安装gd,注意:如果有gd.so.要删除了
#./configure --with-php-config=/usr/local/php/bin/php-config --with-jpeg-dir \
--with-freetype-dir
#make && make install

4,配置php.ini 加入
extension=gd.so

重启nginx,php-fpm(貌似只重启php-fpm就可以了)


解决过程:
网上一查原来是gd不支持jpeg,打开phpinfo一看果然。
一、于是就重新编译,安装php

./configure --prefix=/usr/local/php --with-config-file-path=/etc \
--with-mysql=/usr/local/mysql --with-iconv-dir \
--with-gd --enable-gd-native-ttf  --with-freetype-dir --with-png-dir --with-jpeg-dir  \  
--with-zlib --with-libxml-dir --enable-xml --disable-debug --disable-rpath \
--enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop \ --enable-sysvsem --enable-inline-optimization --with-curl \
--with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm \
--with-iconv=/usr/local --enable-force-cgi-redirect --enable-mbstring  --with-openssl \

make && make install

再查看phpinfo,结果还没有。
二、网上搜素 “gd支持jpeg” 结果还真有很多人遇到同样的问题。
1,有人说:php自带的gd不支持
2,有人说:需要自己安装jpeg
3,还有就是重装
于是,先查自己jpeg安装了没有

#rpm -ql libjpeg

发现自己安装了libjpeg, 而且i386和x86_64都安装了(其实一个就够了)。
这就纳闷了呀,自己明明安装了呀。想想自己安装的gd是php自带的。于是就到php-5.2.17/ext/gd下面自己安装,运行以下:

#phpize
#./configure --with-php-config=/usr/local/php/bin/php-config --with-jpeg-dir \
--with-freetype-dir
#make && make install

在php.ini 里配上“extention = gd.so”重启nginx和php-fpm(如果你安装的是apache,就只重启apache就行了)
提示:gd already load
哦。。。刚才php已经安装上了,还得重装php,把gd相关的参数去掉(上面第三行)

#./configure --prefix=/usr/local/php --with-config-file-path=/etc \
--with-mysql=/usr/local/mysql --with-iconv-dir \
 --with-zlib --with-libxml-dir --enable-xml --disable-debug --disable-rpath \
--enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop \ --enable-sysvsem --enable-inline-optimization --with-curl \
--with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm \
--with-iconv=/usr/local --enable-force-cgi-redirect --enable-mbstring  --with-openssl \
#make && make install

重启nginx、php-fpm,
gd已经加载了,可它大爷的还没有jpg。。。。
那肯定是安装gd的时候出的问题。于是到php-5.2.17下运行:

#make clean
#cd ext/gd
#phpize


生成configure文件,调试configure文件发现,找libjpeg.so默认到/usr/local/lib下面(貌似各个电脑情况不一样).于是吧/usr/local/lib下做了个软连接,重新编译安装gd,终于成功了。终于弄清楚了,花了我整整一天啊

分享到:
评论
1 楼 Aceslup 2016-07-19  
很感谢分享。清晰的思路。

相关推荐

    linux php 所支持的安装文件:libpng

    linux php安装所需要的支持安装文件:jpegsrc, freetype-2.3.9, gd-2.0.35, libxml2-2.6.32, libpng-1.2.37 zlib-1.2.3等(分别上传,都有)

    LINUX gd-2.0.35.tar.gz

    The following 3rd-party libraries will be used by gd if found by configure. While gd will compile and install even without these, we suggest that at least zlib and libpng are installed, and recommend ...

    suse linux下安装php5、Lighttpd .

    1.下载各种PHP5需要的相关安装包(如jpeg8、libpng、freetype、zlib、GD库、curl、libxml2==),编译,安装,注意与服务器版本相同。 a.64位服务器对软件的编译: CFLAGS="-O3 -fPIC" ./configure bzip2及zlib...

    gd-2.0.33.tar.gz

    GD creates PNG, JPEG and GIF images, among other formats. GD is commonly used to generate charts, graphics, thumbnails, and most anything else, on the fly. While not restricted to use on the web, the...

    php-5.6.37.tar.gz下载及php5.6源码安装说明

    --with-jpeg-dir=/usr/lib\ --with-gettext\ --with-mhash\ --with-ldap make && make install cp php.ini-production /usr/local/php/etc/php.ini cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm # 设置...

    LAMP PHP+MySQL+Apache

    Linux 下 Apache MySQL PHP GD libpng jpeg freetype eaccelrator ZendOptimier LAMP 配置

    linux下为php添加iconv模块的方法

    ./configure –with-mysql=/backup/mysql –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-curl –with-gd –enable-gd-native-ttf –with-apxs2=/usr/local/apache/bin/apxs –enable-...

    php-7.2.26.tar.xz

    php 7.2.26 linux安装包 解压源码 解压源码之前,请先下载解压工具: yum install -y tar xz 然后我们先将 XZ 归档解压为 tar 归档: xz -d php-7.2.26.tar.xz 执行完成后,我们输入 ls 命令,你会看到...

    ntop-3.3.9.tar.gz

    linux下的网络监控软件,非常著名的,但是安装前需要linux系统需要安装好:apache2.2.6+php5.2.4+gd (freetype +zlib+jpeg+libpng+libxml2),然后安装时还要装Libpcap、Rrdtool、Cgilib

    libgd-2.2.5.tar.gz.zip

    libgd linux上的图片拓展,php生成验证码需要用到,原官网经常无法下载 ..../configure --prefix=/usr/local/gd2 --with-jpeg --with-png --with-zlib --with-freetype --with-fontconfig make make install

Global site tag (gtag.js) - Google Analytics