如何让Linux支持PHP GD库的imagerotate方法

1 Comment

这里介绍的方法是经过试验可行的(虽然后来遇到了其他问题,见文章下面),在此感谢原作者的贡献!

原文地址:http://voae.com/enable-php-imagerotate-gd

Here is the steps for Ubuntu Server 8.04.1 and PHP5. Like Djamu said it will install a GD pre-compiled working version. It is a complete bundled (forked) GD libraries:
这是在Ubuntu Server 8.04.1 和 PHP5环境下的步骤(注:Debian下也成功了)。就像Djamu所说,这个方法安装的GD是预编译的可用版本。是完全绑定的GD库:

1. If not already done removing your current GD package and its configurations.
先删除你当前的GD包及其配置信息

sudo apt-get –purge remove

2. Adding 2 lines to your file /etc/apt/sources.list.
将上面两行加到系统的源列表文件/etc/apt/sources.list

deb http://packages.dotdeb.org stable all
deb-src http://packages.dotdeb.org stable all

3. Updating your current apt-get list.
更新你的apt-get列表

apt-get update

4. Installing working GD package.
安装可用的GD包

apt-get install php5-gd

It will complain about non-authenticated sources, just ignore, it will also update some additional php libs.
When prompt select keep_current modified php.ini.
它会警告这是没有身份验证的源,甭管它。它还会更新一些其他的php库。
当出现提示信息时,选择“keep_current modified php.ini”(保留之前所用的php.ini)

5. Restarting Apache
重启Apache。
/etc/init.d/apache2 restart

如果重启Apache失败,可能是由于某个模块版本不匹配,需要重新编译一下,具体哪个模块的问题要看error信息是什么。

————————-华丽的分割线————————–

发现问题:Apache有时会莫名kill掉进程,查看log有类似“child pid *** exit signal Segmentation fault”的错误,重启Apache后正常,但过儿又会异常依旧…
这种情况虽然偶尔出现,但却是不可忽视的隐患。经google,感觉似乎是由于PHP升级后,和模块间兼容性的bug。

所以迫不得已,只能rollback回之前的PHP版本,然后用Debian Etch libapache2-mod-php5 with bundled libgd (GDLib)一文中提到的方法,并实践成功!这个办法虽然麻烦些,但对系统影响最小,首推这个。(前面写了一大堆,最后首推另外一个,真不好意思)

其他可能会对你有帮助的链接:
Ubuntu 下安装php5-gd 不能使用imagerotate函数的解决方法
Debian Etch libapache2-mod-php5 with bundled libgd (GDLib)
imageRotate()函数不能用!!

One Comment (+add yours?)

  1. Ting
    Dec 23, 2009 @ 18:05:02

    为什么分割线一定要华丽的呢?

    [Reply]

Leave a Reply