不重新编译PHP文件的情况下php GD库扩展库的编译安装(centos)
gd-2.0.33.tar.gz http://www.boutell.com/gd/
jpegsrc.v6b.tar.gz http://www.ijg.org/
libpng-1.2.7.tar.tar http://sourceforge.net/projects/libpng/
zlib-1.2.2.tar.gz http://sourceforge.net/projects/zlib/
freetype-2.1.9.tar.gzhttp://sourceforge.net/projects/freetype/
安装前先创建jpeg安装文件所需(如下)目录,防止提示类似“无法创建一般文件‘/usr/local/jpeg/***’: 没有那个文件或目录" 的错误
3、安装 libpng
./configure --prefix=/usr/local/gd2 --with-jpeg=/usr/local/jpeg/ --with-png=/usr/local/libpng/ --with-zlib=/usr/local/zlib/ --with-freetype=/usr/local/freetype/
make install
(如果出错见下文)
6、集成PHP GD扩展 到PHP里
切换到PHP源码包
php,建议通过追加编译安装
(如果出现未知配置项--with-png**,--with-freetype之类的错误 在配置项后面加上-dir参数即可:既修编译参数为: ./configure --with-php-config=[php安装目录]/bin/php-config --with-jpeg-dir=[jpeg安装目录] --with-png-dir=[libpng安装目录] --with-freetype-dir=[freetype安装目录] --with-zlib=[zlib安装目录] --with-gd=[gd安装目录] 即可
)
./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 --with-zlib-dir=/usr/local/zlib --with-gd=/usr/local/gd2
执行编译安装
具体操作流程如下:
$ cd <php源码>/ext/gd
$ /usr/local/php5/bin/phpize
$ ./configure --with-gd=/usr/local/gd --with-jpeg-dir=/usr/local/jpeg --with-png-dir=/usr/local/libpng --with-freetype-dir=/usr/local/freetype --with-zlib-dir=/usr/local/zlib --with-php-config=/usr/local/php/bin/php-config
$ make && make install
修改php.ini
$ make && make install
添加extension=gd.so
最后,重启apache
可能出现的错误以及解决方法:
编译GD库时如果出现以下错误:
在./configure GD库,安装时出现了一个问题,下面是报错信息gd_png.c:16:53: error: png.h: No such file or directory
gd_png.c:47: error: expected specifier-qualifier-list before ‘jmp_buf’
gd_png.c:54: error: expected ‘)’ before ‘png_ptr’
gd_png.c:82: error: expected ‘)’ before ‘png_ptr’
gd_png.c:92: error: expected ‘)’ before ‘png_ptr’
gd_png.c:98: error: expected ‘)’ before ‘png_ptr’
gd_png.c: In function ‘gdImageCreateFromPngCtx’:
gd_png.c:125: error: ‘png_byte’ undeclared (first use in this function)
gd_png.c:125: error: (Each undeclared identifier is reported only once
gd_png.c:125: error: for each function it appears in.)
gd_png.c:125: error: expected ‘;’ before ‘sig’
gd_png.c:126: error: ‘png_structp’ undeclared (first use in this function)
gd_png.c:126: error: expected ‘;’ before ‘png_ptr’
gd_png.c:127: error: ‘png_infop’ undeclared (first use in this function)
gd_png.c:127: error: expected ‘;’ before ‘info_ptr’
gd_png.c:128: error: ‘png_uint_32′ undeclared (first use in this function)
gd_png.c:128: error: expected ‘;’ before ‘width’
gd_png.c:131: error: ‘png_colorp’ undeclared (first use in this function)
gd_png.c:131: error: expected ‘;’ before ‘palette’
gd_png.c:132: error: ‘png_color_16p’ undeclared (first use in this function)
gd_png.c:132: error: expected ‘;’ before ‘trans_gray_rgb’
gd_png.c:133: error: expected ‘;’ before ‘trans_color_rgb’
gd_png.c:134: error: ‘png_bytep’ undeclared (first use in this function)
gd_png.c:134: error: expected ‘;’ before ‘trans’
gd_png.c:135: error: expected ‘;’ before ‘image_data’
gd_png.c:136: error: ‘png_bytepp’ undeclared (first use in this function)
gd_png.c:136: error: expected ‘;’ before ‘row_pointers’
gd_png.c:144: error: ‘sig’ undeclared (first use in this function)
gd_png.c:157: error: ‘png_ptr’ undeclared (first use in this function)
gd_png.c:157: error: ‘PNG_LIBPNG_VER_STRING’ undeclared (first use in this function)
gd_png.c:157: error: ‘gdPngErrorHandler’ undeclared (first use in this function)
gd_png.c:166: error: ‘info_ptr’ undeclared (first use in this function)
gd_png.c:182: error: ‘jmpbuf_wrapper’ has no member named ‘jmpbuf’
gd_png.c:192: error: ‘gdPngReadData’ undeclared (first use in this function)
gd_png.c:195: error: ‘width’ undeclared (first use in this function)
gd_png.c:195: error: ‘height’ undeclared (first use in this function)
gd_png.c:196: error: ‘PNG_COLOR_TYPE_RGB’ undeclared (first use in this function)
gd_png.c:196: error: ‘PNG_COLOR_TYPE_RGB_ALPHA’ undeclared (first use in this function)
gd_png.c:204: error: ‘image_data’ undeclared (first use in this function)
gd_png.c:205: error: ‘row_pointers’ undeclared (first use in this function)
gd_png.c:220: error: ‘jmpbuf_wrapper’ has no member named ‘jmpbuf’
gd_png.c:233: error: ‘PNG_COLOR_TYPE_PALETTE’ undeclared (first use in this function)
gd_png.c:234: error: ‘palette’ undeclared (first use in this function)
gd_png.c:238: error: ‘PNG_INFO_tRNS’ undeclared (first use in this function)
gd_png.c:246: error: ‘trans’ undeclared (first use in this function)
gd_png.c:258: error: ‘PNG_COLOR_TYPE_GRAY’ undeclared (first use in this function)
gd_png.c:259: error: ‘PNG_COLOR_TYPE_GRAY_ALPHA’ undeclared (first use in this function)
gd_png.c:261: error: expected ‘)’ before ‘gdMalloc’
gd_png.c:280: error: ‘trans_gray_rgb’ undeclared (first use in this function)
gd_png.c:305: error: ‘trans_color_rgb’ undeclared (first use in this function)
gd_png.c:322: error: ‘rowbytes’ undeclared (first use in this function)
gd_png.c:327: error: expected ‘;’ before ‘gdMalloc’
gd_png.c:345: error: expected ‘;’ before ‘gdMalloc’
gd_png.c:357: error: ‘h’ undeclared (first use in this function)
gd_png.c:381: error: ‘PNG_INTERLACE_ADAM7′ undeclared (first use in this function)
gd_png.c:389: error: ‘w’ undeclared (first use in this function)
gd_png.c:390: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘r’
gd_png.c:390: error: ‘r’ undeclared (first use in this function)
gd_png.c:391: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘g’
gd_png.c:391: error: ‘g’ undeclared (first use in this function)
gd_png.c:392: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘b’
gd_png.c:392: error: ‘b’ undeclared (first use in this function)
gd_png.c:401: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘r’
gd_png.c:402: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘g’
gd_png.c:403: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘b’
gd_png.c:410: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘a’
gd_png.c:410: error: ‘a’ undeclared (first use in this function)
gd_png.c:419: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘idx’
gd_png.c:419: error: ‘idx’ undeclared (first use in this function)
gd_png.c: In function ‘gdImagePngCtxEx’:
gd_png.c:499: error: ‘png_byte’ undeclared (first use in this function)
gd_png.c:499: error: expected ‘;’ before ‘trans_values’
gd_png.c:500: error: ‘png_color_16′ undeclared (first use in this function)
gd_png.c:500: error: expected ‘;’ before ‘trans_rgb_value’
gd_png.c:501: error: ‘png_color’ undeclared (first use in this function)
gd_png.c:501: error: expected ‘;’ before ‘palette’
gd_png.c:502: error: ‘png_structp’ undeclared (first use in this function)
gd_png.c:502: error: expected ‘;’ before ‘png_ptr’
gd_png.c:503: error: ‘png_infop’ undeclared (first use in this function)
gd_png.c:503: error: expected ‘;’ before ‘info_ptr’
gd_png.c:508: error: ‘png_ptr’ undeclared (first use in this function)
gd_png.c:508: error: ‘PNG_LIBPNG_VER_STRING’ undeclared (first use in this function)
gd_png.c:509: error: ‘gdPngErrorHandler’ undeclared (first use in this function)
gd_png.c:520: error: ‘info_ptr’ undeclared (first use in this function)
gd_png.c:524: error: ‘png_infopp’ undeclared (first use in this function)
gd_png.c:529: error: ‘jmpbuf_wrapper’ has no member named ‘jmpbuf’
gd_png.c:537: error: ‘gdPngWriteData’ undeclared (first use in this function)
gd_png.c:538: error: ‘gdPngFlushData’ undeclared (first use in this function)
gd_png.c:595: error: ‘PNG_INTERLACE_ADAM7′ undeclared (first use in this function)
gd_png.c:595: error: ‘PNG_INTERLACE_NONE’ undeclared (first use in this function)
gd_png.c:602: error: ‘PNG_COLOR_TYPE_RGB_ALPHA’ undeclared (first use in this function)
gd_png.c:603: error: ‘PNG_COMPRESSION_TYPE_DEFAULT’ undeclared (first use in this function)
gd_png.c:604: error: ‘PNG_FILTER_TYPE_DEFAULT’ undeclared (first use in this function)
gd_png.c:609: error: ‘PNG_COLOR_TYPE_RGB’ undeclared (first use in this function)
gd_png.c:617: error: ‘PNG_COLOR_TYPE_PALETTE’ undeclared (first use in this function)
gd_png.c:623: error: ‘trans_rgb_value’ undeclared (first use in this function)
gd_png.c:672: error: ‘trans_values’ undeclared (first use in this function)
gd_png.c:694: error: ‘palette’ undeclared (first use in this function)
gd_png.c:725: error: ‘png_bytep’ undeclared (first use in this function)
gd_png.c:725: error: ‘row_pointers’ undeclared (first use in this function)
gd_png.c:731: error: ‘prow_pointers’ undeclared (first use in this function)
gd_png.c:747: error: expected ‘)’ before ‘gdMalloc’
gd_png.c:804: error: expected ‘)’ before ‘gdMalloc’
make[2]: *** [gd_png.lo] 错误 1
make[2]:正在离开目录 `/usr/local/src/modules/gd-2.0.35′
make[1]: *** [all-recursive] 错误 1<br>
make[1]:正在离开目录 `/usr/local/src/modules/gd-2.0.35′
make: *** [all] 错误 2很显然,这是引入png库出现的问题,解决方法进入gd源代码目录:vi gd_png.c将16行的png.h修改成 libpng安装目录/include/png.h我这边就是:/usr/local/libpng/include/png.hmake && make install 成功
在安装php GD扩展时,报如下错误
In file included from /kk/php-5.4.0/ext/gd/gd.c:103:
/root/php-5.4.0/ext/gd/gd_ctx.c: In function ‘_php_image_stream_putc’:
/root/php-5.4.0/ext/gd/gd_ctx.c:51: 错误:‘struct gdIOCtx’ 没有名为 ‘data’ 的成员
/root/php-5.4.0/ext/gd/gd_ctx.c: In function ‘_php_image_stream_putbuf’:
/root/php-5.4.0/ext/gd/gd_ctx.c:58: 错误:‘struct gdIOCtx’ 没有名为 ‘data’ 的成员
/root/php-5.4.0/ext/gd/gd_ctx.c: In function ‘_php_image_stream_ctxfree’:
/root/php-5.4.0/ext/gd/gd_ctx.c:67: 错误:‘struct gdIOCtx’ 没有名为 ‘data’ 的成员
/root/php-5.4.0/ext/gd/gd_ctx.c:68: 错误:‘struct gdIOCtx’ 没有名为 ‘data’ 的成员
/root/php-5.4.0/ext/gd/gd_ctx.c:69: 错误:‘struct gdIOCtx’ 没有名为 ‘data’ 的成员
/root/php-5.4.0/ext/gd/gd_ctx.c: In function ‘_php_image_output_ctx’:
/root/php-5.4.0/ext/gd/gd_ctx.c:153: 错误:‘gdIOCtx’ 没有名为 ‘data’ 的成员
make: *** [ext/gd/gd.lo] 错误 1
解决方法
vi <gd_dir>/include/gd_io.h
gdIOCtx结构中增加void *data;
格式如下
typedef struct gdIOCtx
{
int (*getC) (struct gdIOCtx *);
int (*getBuf) (struct gdIOCtx *, void *, int);
void (*putC) (struct gdIOCtx *, int);
int (*putBuf) (struct gdIOCtx *, const void *, int);
/* seek must return 1 on SUCCESS, 0 on FAILURE. Unlike fseek! */
int (*seek) (struct gdIOCtx *, const int);
long (*tell) (struct gdIOCtx *);
void (*gd_free) (struct gdIOCtx *);
void (*data);
}
gdIOCtx;
注:不知道是不是动态扩展gd的原因, 这个时候访问服务器并不能打开网页, 查找apache error_log, 上面写着:
/usr/local/apache//bin/httpd: symbol lookup error: /usr/local/php5/lib/php/extensions/no-debug-zts-20100525/gd.so: undefined symbol: gdJpegGetVersionString
和
/usr/local/apache//bin/httpd: symbol lookup error: /usr/local/php5/lib/php/extensions/no-debug-zts-20100525/gd.so: undefined symbol: gdPngGetVersionString
在网上找了好长时间, 找不到解决这个问题的办法, 或者这个问题引起的原因, 我想到了一个办法作为临时的解决办法:修改gd.c
$ vi $ cd <php源文件>/ext/gd/gd.c
/*
在这个文件的下面添加
# include <{libpng安装目录}png.h>
# include <{libjpeg安装目录}jpeglib.h>
const char * gdJpegGetVersionString()
{
switch(JPEG_LIB_VERSION) {
case 62:
return "6b";
break;
default:
return "unknown";
}
}
const char * gdPngGetVersionString()
{
return PNG_LIBPNG_VER_STRING;
}
*/
然后重新整合php & gd, 问题解决,可以生成验证码.
不重新编译PHP文件的情况下php GD库扩展库的编译安装(centos)的更多相关文章
- ng-file-upload(在单文件选择,并且通过点击“上传”按钮上传文件的情况下,如何在真正选择文件之前保留上一文件信息?)
文章前面研究ng-file-upload可能涉及指令: You can use ng-model or ngf-change instead of specifying function for ng ...
- Linux,在不使用U盘的情况下使用wubi.exe程序在Win7上安装ubuntu-14.04.3版系统
本文介绍如何在不使用U盘的情况下使用wubi.exe程序在Win7上安装ubuntu-14.04.3版系统. 花了一天的时间终于安装上了Ubuntu14.04,过程坎坷,是血泪史,开始报“cannot ...
- php 502 无错误行和报错文件的情况下使用gdb调试方法
lnmp环境 gdb /usr/local/php5.2/bin/php-cgi /tmp/coredump-php-cgi.20503 source /home/tmp/lnmp1.4-full ...
- 如何在没有core文件的情况下用dmesg+addr2line定位段错误
前言 在现网环境下,程序奔溃后不一定会留下core文件,原因有很多,比如存储空间不足就是其中一个常见的原因.此时我们只能依据linux记录的错误日志来定位问题. 涉及linux命令 本文涉及以下几条命 ...
- 自定义ListView适配器Adapter引用布局文件的情况下实现点击列表项时背景颜色为灰色
listview控件设置适配器的时候,如果使用自定义的adapter,比如MyArrayAdapter extends ArrayAdapter<String> 如果listitem布局文 ...
- java:多层文件夹情况下,判断文件夹下是否有文件夹,并获取到没有文件夹的名字的方法
业务问题案例 在公司遇到的一个问题,本以为很小很好解决,没想到花了一下午时间.图给的是文件路径,page1下有10个文件夹,每个有的有文件夹或者文件,要求得到page1下(即:123456789,10 ...
- Windows服务注册(需要指定config文件的情况下)
最近,遇到一个问题:需要将telegraf在Win平台下注册为windows服务(避免误操作关闭CMD窗口): 尝试了网上的几种注册Windows服务的方法,发现无法将telegraf这种需要在CMD ...
- python3 不知文件编码情况下打开文件代码记录
import chardet path='test.txt' bytes = min(100, os.path.getsize(path)) raw = open(path, 'rb').read(b ...
- SQL2005 如何在没有日志文件的情况下如何恢复MDF数据库文件?
第一步:先建立一个同名数据库,停止SQL SERVER2005,将没有日志的的.mdf数据库文件覆盖刚新建的.mdf数据库文件,重新启动数据库. 第二步:在查询分析器中运行如下代码(将数据库名修改为您 ...
随机推荐
- Oracle数据库时间修改
http://blog.csdn.net/tianlesoftware/article/details/6163859
- QT显示如何减轻闪屏(双缓冲和NoErase)
很多同志在些QT 程序后会遇见闪屏的问题, 有时速度非常快,但毕竟影响了显示效果,如何做到减轻屏幕抖动或闪屏呢?我曾试过如下的办法:1.使用双缓冲. 比如我们在一个Widget里面绘多个图的话, 先创 ...
- HDU 5782 Cycle(KMP+Hash)
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5782 [题目大意] 给出两个字符串,判断他们每一个前缀是否循环同构,循环同构的意思就是,字符串首位 ...
- delphi调用外部程序打开文件
delphi调用外部程序打开文件 ShellExecute的各种用法 一.利用系统默认的邮件收发器发送电子邮件 Uses ..., ShellAPI; Var lpHwnd: HWND; lpOper ...
- 160G 视频教程(Java+Android+项目视频)免费下载
我不喜欢多说没用,直接给下载链接,进去直接下载,下载不动的联系网站客服解决!我只和我的好朋友们分享好的视频教程 http://edu.csdn.net/main/video.shtml 视频教程目录过 ...
- 记userscripts.org
发现一些Firefox用户脚本不起作用,userscripts.org访问不能有一个很长的一段时间,我还以为出了什么问题没出去检查.前几天有时间检查脚本,在路上,然后返回到userscripts.or ...
- #ifdef _cplusplus
时常在cpp的代码之中看到这样的代码: #ifdef __cplusplus extern "C" { #endif //一段代码 #ifdef __cplusplus } #en ...
- SMACSS:一个关于CSS的最佳实践-1.Overview
什么是SMACSS? SMACSS(发音"smacks"),全称Scalable and Modular Architecture for CSS.顾名思义,SMACSS是一个可扩 ...
- zoj 1962 How Many Fibs?(字符串化为数字处理)
事实证明还是,题目拿到手之后,还是还是好好动手划一下比较好,不然直接想打哪!打到哪!很容易乱掉的.将数字倒着弄成字符串比较好处理. #include<stdio.h> #include&l ...
- Dos关闭进程命令
netstat -ao 查找占用端口的进程 taskkikk /pid 端口pid /f