在 PHP 中启用 GD 支持

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4646456/
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 13:50:26  来源:igfitidea点击:

Enable GD support in PHP

phpgd2

提问by Dónal

I'm trying to install pixelpost on an Apache server on windows. The installer is failing because:

我正在尝试在 Windows 上的 Apache 服务器上安装 pixelpost。安装程序失败,因为:

Pixelpost will not run if your PHP installation is not compiled with the GD graphics library.

如果您的 PHP 安装未使用 GD 图形库编译,则 Pixelpost 将不会运行。

I've added the following line to php.ini

我已将以下行添加到 php.ini

extension=php_gd2.dll

But I still get the same error message. When I run phpinfo()I don't see any reference to GD, so I guess it really isn't installed. I searched for php_gd2.dlland it's in the extsubfolder of my PHP root dir.

但我仍然收到相同的错误消息。当我运行时,phpinfo()我没有看到任何对 GD 的引用,所以我想它确实没有安装。我搜索了php_gd2.dll它,它在ext我的 PHP 根目录的子文件夹中。

I know nothing about PHP, so be gentle with me.

我对 PHP 一无所知,所以对我温柔一点。

Update

更新

To answer the questions raised in the comments:

回答评论中提出的问题:

  • I restarted Apache after modifying php.ini
  • php.iniis in the root dir of my PHP installation C:\php\php.ini
  • 修改后我重启了Apache php.ini
  • php.ini位于我的 PHP 安装的根目录中 C:\php\php.ini


回答by Amil Waduwawara

Following are the steps for any phpextension (on MS-Windows):

以下是任何php扩展的步骤(在MS-Windows):

  1. Give absolute path (not relative) to extensions directory [use forward slashes (/) instead of backslashes (\); I'm not too sure whether it's required to end the path with trailing slash.
    • e.g.: extension_dir = c:/php5/ext
  2. Make sure phpis referring your php.ini, now php.inican be inside your phpinstallation root dir.
    • If your changes to php.iniare reflected on phpinfo(), it's OK. If not, please refer to INSTALLfile in phproot dir.
  3. Restart apacheif you're binding phpas a module to apache
  1. 提供扩展目录的绝对路径(不是相对路径)[使用正斜杠 ( /) 而不是反斜杠 ( \); 我不太确定是否需要用斜杠结束路径。
    • 例如: extension_dir = c:/php5/ext
  2. 确保php是指您的php.ini, 现在php.ini可以在您的php安装根目录中。
    • 如果您对 的更改php.ini反映在 上phpinfo(),则没关系。如果没有,请参考根目录中的INSTALL文件php
  3. 重新启动apache,如果你要绑定php的模块apache