php ubuntu中的php GD库错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6148679/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:29:19  来源:igfitidea点击:

php GD library error in ubuntu

phpubuntu

提问by NewUser

I am using ubuntu 11.04 and when I am opening terminal and typing php -ait is showing some error like this

我正在使用 ubuntu 11.04,当我打开终端并输入php -a它时,它显示了一些这样的错误

PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626/gd.so' - /usr/lib/php5/20090626/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0

I think there is some problem with GD library.Is there any option to solve it?

我认为 GD 库有问题。有什么办法可以解决吗?

回答by stefgosselin

Yeah. Just try:

是的。你试一试:

sudo apt-get install php5-gd

You probably will have to remove the offending line in your php.ini, either in php.ini or in /etc/php5/conf.d/gd.ini maybe.

您可能必须删除 php.ini 中的违规行,可能是在 php.ini 或 /etc/php5/conf.d/gd.ini 中。

回答by vickirk

Probably something like

大概是这样的

sudo apt-get install php-gd

should do it, if not try

应该这样做,如果不尝试

apt-cache search php | grep gd

回答by hobs

For me the solution was:

对我来说,解决方案是:

locate --regex /mcrypt[.]so$ /gd[.]so$ /suhosin[.]so$ /pdo_mysql.so$ /pdo[.]so /mysqli[.]so$ '/php5/.*/mysql[.]so$'

Which returned the location of all the libraries that my php5 install was having trouble finding:

它返回了我的 php5 安装无法找到的所有库的位置:

/usr/lib/php5/20090626+lfs/gd.so
/usr/lib/php5/20090626+lfs/mcrypt.so
/usr/lib/php5/20090626+lfs/mysql.so
/usr/lib/php5/20090626+lfs/mysqli.so
/usr/lib/php5/20090626+lfs/pdo.so
/usr/lib/php5/20090626+lfs/pdo_mysql.so

I was a little worried that these look they might be old versions, but I used their paths anyway. Stefgosselin identified the location of the ini files, /etc/php5/conf.d/. I modified them all. The command below will modify allof the *.inifiles there, so make sure all of yours really need modifying. Obviously you need to use the target path you discovered with the locate command in place of mine, /usr/lib/php5/20090626+lfs/:

我有点担心这些看起来可能是旧版本,但我还是使用了它们的路径。Stefgosselin 确定了 ini 文件的位置,/etc/php5/conf.d/. 我都修改了它们。下面的命令将修改所有的的*.ini有文件,所以一定要确保所有真正需要修改你的事。显然,您需要使用通过 locate 命令发现的目标路径来代替我的/usr/lib/php5/20090626+lfs/

 sudo sed -ri -e "s|^(extension=)(\w{2,10}[.]so)$|/usr/lib/php5/20090626+lfs/|g" /etc/php5/conf.d/*.ini

Before finding this solution I tried several apt-get purgeand apt-get reinstallcommands without luck. I'm not sure, but my problem may have originated with installation of zend from source or phpmyadmin with aptitude. It never caused any php errors, just the annoying warning you mentioned. Finally php5 can launch without errors:

找到这个解决方案之前我试了几个apt-get purgeapt-get reinstall命令没有运气。我不确定,但我的问题可能源于从源代码或具有 aptitude 的 phpmyadmin 安装 zend。它从未导致任何 php 错误,只是您提到的烦人警告。最后 php5 可以启动而没有错误:

php5 --version

php5 --version

gives ...

给...

PHP 5.3.5-1ubuntu7.2 with Suhosin-Patch (cli) (built: May  2 2011 23:18:30)  Copyright (c) 1997-2009 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH