简体   繁体   English

当存在php.ini时,PDO从phpinfo()中消失

[英]When php.ini is present PDO disappears from phpinfo()

I have added the following php.ini (this is 100% of file): 我添加了以下php.ini(这是文件的100%):

upload_max_filesize = 200M
post_max_size = 200M
session.gc_maxlifetime = 6000
max_execution_time = 600

When it is present the phpinfo() lists PDO in the configure command but nowhere else. 如果存在,则phpinfo()会在configure命令中列出PDO,但没有其他地方。 The drivers, API version and SQLite version are all gone . 驱动程序,API版本和SQLite版本都消失了 I discovered this when queries started failing with "Class 'PDO' not found". 当查询因“找不到类'PDO'”而开始失败时,我发现了这一点。

If I remove the php.ini I get different results, see below. 如果删除php.ini,则会得到不同的结果,请参见下文。 This is on a shared server. 这是在共享服务器上。 How should I proceed? 我应该如何进行? I absolutely must have the php.ini modifications. 我绝对必须对php.ini进行修改。

PDO设定

如果您的ini文件仅包含这些变量,它将仅覆盖它们并使用其他变量的主值,但是在大多数情况下,默认情况下,诸如pdo,mysqli,mbstring,sqlite之类的扩展名被禁用,以节省资源,并且如今大多数共享主机都允许您启用它们。

I had the same problem. 我有同样的问题。 My solution was that in php.ini the line dictating the loadable extensions folder was incorrect. 我的解决方案是在php.ini中,指示可加载的扩展文件夹的行不正确。

I changed: 我变了:

; Directory in which the loadable extensions (modules) reside.
extension_dir = "/home/mycmecre/public_html/php_extensions"
;extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20060613"

to

; Directory in which the loadable extensions (modules) reside.
;extension_dir = "/home/mycmecre/public_html/php_extensions"
extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20060613"

and PDO magically loaded for me. 和PDO为我神奇地加载。 Hope this helps someone, as it took me hours to figure out, and apparently longer for my web host tech support, as they have not called me back yet. 希望这对某人有所帮助,因为我花了几个小时才弄清楚,而且显然还需要更长的时间来获得我的网络托管技术支持,因为他们还没有给我回电话。

It would appear that leaving out an extension in the php.ini , such as PDO, results in the extension becoming disabled. 似乎在php.ini扩展名(例如PDO)会导致该扩展名被禁用。

I would suggest you grab a sample/default php.ini file and add your modifications. 我建议您获取一个示例/默认php.ini文件并添加您的修改。 Here is a previous SO post about sample php.ini s, https://stackoverflow.com/a/9602645/1349295 . 这是有关示例php.ini的先前SO帖子, https://stackoverflow.com/a/9602645/1349295

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM