无法在 apache 2.0 中找到我的 php.ini 文件的“扩展”部分,它在哪里?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5939149/
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
Unable to find the "extensions" portion of my php.ini file, in apache 2.0, where is it?
提问by JustinKaz
I'm trying to add support for the GD extension on my Ubuntu, Apache 2, php box. However my php.ini file does not seem to be the same as most versions of the INI file and it appears that their are no ;extensions comments or a place holder for them. Where did this move to? Is their a new location or new method for adding extensions?
我正在尝试在我的 Ubuntu、Apache 2、php 框中添加对 GD 扩展的支持。但是,我的 php.ini 文件似乎与 INI 文件的大多数版本不同,而且它们似乎没有 ; 扩展注释或占位符。这搬到哪里去了?他们是添加扩展的新位置或新方法吗?
I'm at a loss, I only found 2 php.ini files. One for Apache 2 and one for the command line interface.
我不知所措,我只找到了 2 个 php.ini 文件。一种用于 Apache 2,一种用于命令行界面。
Ultimately I'm asking this question because the normal fix for the error Undefined offset: 1 in [...]images.php on line 50 Fatal error: Call to undefined function imagecreatefrompng() in [...]functions.php on line 309does not work.
最终我问这个问题是因为错误Undefined offset: 1 in [...]images.php on line 50 Fatal error: Call to undefined function imagecreatefrompng() in [...]functions.php on第 309 行不起作用。
采纳答案by Marc B
Most distros, Ubuntu included, generally keep PHP extensions' .ini files in a seperate sub-dir from the main .ini file.
大多数发行版,包括 Ubuntu,通常将 PHP 扩展的 .ini 文件保存在与主 .ini 文件不同的子目录中。
You should have a /etc/php5
directory, with conf.d
sub-dir for the main configuration, and apache
and cli
sub-dirs for the individual versions.
你应该有一个/etc/php5
目录,与conf.d
子DIR为主要配置,apache
以及cli
子显示目录的各个版本。
However, Ubuntu has a php5-gd package which will install the extension automatically, so hacking up the .ini files should NOT be necessary, unless you have to compile a specific version of GD yourself.
然而,Ubuntu 有一个 php5-gd 包,它会自动安装扩展,所以不需要修改 .ini 文件,除非你必须自己编译特定版本的 GD。
回答by Lightness Races in Orbit
If there are no extensions in your php.ini, then that's fine. Just because the comments are missing in your .ini
file doesn't mean that the "section" has moved; they're just comments!
如果您的 php.ini 中没有扩展名,那就没问题了。仅仅因为.ini
文件中缺少注释并不意味着“部分”已经移动;他们只是评论!
If you want one, create it.
如果你想要一个,创建它。
It starts with the text extension=
.
它从文本开始extension=
。
回答by Femi
The gd extension configuration file is in /etc/php5/conf.d/gd.ini
: unless I'm wrong by default all the files in the /etc/php5/conf.d folder are automatically included in the PHP runtime.
gd 扩展配置文件位于/etc/php5/conf.d/gd.ini
: 除非我错了,否则 /etc/php5/conf.d 文件夹中的所有文件都会自动包含在 PHP 运行时中。
回答by Jamie Ramone
I'm using Ubuntu 14.04 LTS and have the package installed, but Drupal was not detecting it. I looked through the folders and found NOTHING regarding gd save
and empty section in the ini files. The error message went away when I manually created the file for the extension in /etc/php5/mods-available
. I copied one of the files and changed it to load gd.so, like this:
我正在使用 Ubuntu 14.04 LTS 并安装了该软件包,但 Drupal 没有检测到它。我查看了文件夹,发现gd save
ini 文件中没有任何内容和空白部分。当我手动创建扩展名的文件时,错误消息消失了/etc/php5/mods-available
。我复制了其中一个文件并将其更改为加载 gd.so,如下所示:
; configuration for php gd module
; priority=20
extension=gd.so
If you don't have the file either, try that, restart Apache2 and see if it helps.
如果您也没有该文件,请尝试该文件,然后重新启动 Apache2 并查看是否有帮助。