php 致命错误:调用未定义的函数:imagecreate()
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3106991/
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
Fatal error: Call to undefined function: imagecreate()
提问by Marcelo
I'm trying to put some graphics on a web page and at my prototype at the computer it's all working fine at the localhost. But now I uploaded the files to a server and I'm having a problem to plot some graphics. In my computer they are plotted, but on the server they are not.
我正在尝试将一些图形放在网页上,并且在计算机上的原型中,在本地主机上一切正常。但是现在我将文件上传到服务器,但在绘制一些图形时遇到了问题。在我的电脑上,它们被绘制出来,但在服务器上它们不是。
I'm getting this error
Fatal error: Call to undefined function ImageCreate() in /home/t1g01/phplot.php on line 248
我收到这个错误
Fatal error: Call to undefined function ImageCreate() in /home/t1g01/phplot.php on line 248
Line 248
第248行
$this->img = ImageCreate($this->image_width, $this->image_height);
$this->img = ImageCreate($this->image_width, $this->image_height);
I'm using phplot, and I uploaded the files form phplot too. Can anyone help me ?
我正在使用 phplot,并且我也从 phplot 上传了文件。谁能帮我 ?
Sorry for any mistake in English and thank you in advance.
抱歉,英语有任何错误,提前致谢。
回答by Ben Rowe
This means your installation of php doesn't have the gd library installed/enabled.
这意味着您安装的 php 没有安装/启用 gd 库。
回答by Jonathan Gurebo
If you are using a Linux machine then execute this command from console:
如果您使用的是 Linux 机器,则从控制台执行此命令:
sudo apt-get install php5-gd
to install the php_gd2.dll extension. It will then work after an Apache restart.
安装 php_gd2.dll 扩展。然后它将在 Apache 重新启动后工作。
PS: should first check your current php version
PS:应该首先检查你当前的php版本
php -v
In My Case:
在我的情况下:
PHP 7.3.5-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: May 3 2019 10:00:24) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.5, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.5-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
PHP 7.3.5-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: May 3 2019 10:00:24) ( NTS ) 版权所有 (c) 1997-2018 The PHP Group Zend Engine v3。 3.5,版权 (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.5-1+ubuntu18.04.1+deb.sury.org+1,版权 (c) 1999-2018,Zend Technologies
So, my PHP version is 7.3, so, the command for my version is :
所以,我的 PHP 版本是 7.3,所以,我的版本的命令是:
sudo apt-get install php7.3-gd
回答by Mike Sherov
Your server most like does not have GD (the built in PHP image processing library) enabled. You can check this by looking for "GD" in the output of :
您的服务器最喜欢没有启用 GD(内置的 PHP 图像处理库)。您可以通过在以下输出中查找“GD”来检查这一点:
<?php
phpinfo();
?>
If not, check the PHP docs on how to enable it: http://www.php.net/manual/en/book.image.php
如果没有,请查看有关如何启用它的 PHP 文档:http: //www.php.net/manual/en/book.image.php
回答by Gayan Weerakutti
For Fedora, CentOS
对于 Fedora、CentOS
dnf install php-gd
systemctl restart httpd.service
On Ubuntu
在 Ubuntu 上
apt-cache search php*-gd
apt-get install php<version>-gd
systemctl restart apache2.service
Windowsusers see: http://php.net/manual/en/image.installation.php
Windows用户见:http: //php.net/manual/en/image.installation.php
回答by Russell Dias
It seems that your GD library is not being used. Double check your php.inifile.
似乎您的 GD 库没有被使用。仔细检查您的php.ini文件。
回答by mymahdi
Copy the file php_gd2.dll from your PHP's ext/ directory to where you have your php extensions. (No need to copy if php_gd2.dll is in the extension dir already. Look in php.ini for 'extension_dir' directive to find what is your current extension directory)
Modify your php.ini and change the following line:
将文件 php_gd2.dll 从 PHP 的 ext/ 目录复制到 php 扩展所在的位置。(如果 php_gd2.dll 已经在扩展目录中,则无需复制。在 php.ini 中查找“extension_dir”指令以找到您当前的扩展目录)
修改您的 php.ini 并更改以下行:
;extension=php_gd2.dll
;extension=php_gd2.dll
to:
到:
extension=php_gd2.dll
回答by Abdul Rahman
For Ubuntu 16.04:
对于 Ubuntu 16.04:
sudo apt-get install php7.0-gd
Stop and then restart Apache Server.
停止然后重新启动 Apache 服务器。
PS: should first check your current php version
PS:应该首先检查你当前的php版本
php -v
In My Case:
在我的情况下:
PHP 7.3.5-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: May 3 2019 10:00:24) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.5, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.5-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
PHP 7.3.5-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: May 3 2019 10:00:24) ( NTS ) 版权所有 (c) 1997-2018 The PHP Group Zend Engine v3。 3.5,版权 (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.5-1+ubuntu18.04.1+deb.sury.org+1,版权 (c) 1999-2018,Zend Technologies
So, my PHP version is 7.3, so, the?command for my version is :
所以,我的 PHP 版本是 7.3,所以,我的版本的?命令是:
sudo apt-get install php7.3-gd

