Unable to find the “extensions” portion of my php.ini file, in apache 2.0, where is it?

痞子三分冷 提交于 2019-12-10 14:54:07

问题


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?

I'm at a loss, I only found 2 php.ini files. One for Apache 2 and one for the command line interface.

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 309 does not work.


回答1:


Most distros, Ubuntu included, generally keep PHP extensions' .ini files in a seperate sub-dir from the main .ini file.

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.

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.




回答2:


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!

If you want one, create it.

It starts with the text extension=.




回答3:


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.




回答4:


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:

; 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.



来源:https://stackoverflow.com/questions/5939149/unable-to-find-the-extensions-portion-of-my-php-ini-file-in-apache-2-0-where

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!