php 如何检查我的 Apache 安装中是否启用了 PDO 支持?

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

How to check if PDO support is enabled in my Apache Installation?

phpapachezend-frameworkhostingpdo

提问by Arc

I am using a shared hosting through CIPL.in. They use cpanel. I am trying to deploy a ZEND app on my website. However it keeps giving the error.

我正在通过 CIPL.in 使用共享主机。他们使用cpanel。我正在尝试在我的网站上部署 ZEND 应用程序。但是它不断给出错误。

An error occurred
Application error
Exception information:

Message: The PDO extension is required for this adapter but the extension is not loaded
Stack trace:

#0 /home/cubeeeco/worminc/library/Zend/Db/Adapter/Abstract.php(770): Zend_Db_Adapter_Pdo_Abstract->_connect()
#1 /home/cubeeeco/worminc/library/Zend/Db/Adapter/Abstract.php(840): Zend_Db_Adapter_Abstract->quote('windchimes', NULL)
#2 /home/cubeeeco/worminc/library/Zend/Auth/Adapter/DbTable.php(354): Zend_Db_Adapter_Abstract->quoteInto('`password` = MD...', 'windchimes')
#3 /home/cubeeeco/worminc/library/Zend/Auth/Adapter/DbTable.php(285): Zend_Auth_Adapter_DbTable->_authenticateCreateSelect()
#4 /home/cubeeeco/worminc/library/Zend/Auth.php(117): Zend_Auth_Adapter_DbTable->authenticate()
#5 /home/cubeeeco/worminc/application/controllers/LoginController.php(117): Zend_Auth->authenticate(Object(Zend_Auth_Adapter_DbTable))
#6 /home/cubeeeco/worminc/library/Zend/Controller/Action.php(503): LoginController->processAction()
#7 /home/cubeeeco/worminc/library/Zend/Controller/Dispatcher/Standard.php(285): Zend_Controller_Action->dispatch('processAction')
#8 /home/cubeeeco/worminc/library/Zend/Controller/Front.php(934): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#9 /home/cubeeeco/public_html/worm/index.php(47): Zend_Controller_Front->dispatch()
#10 {main}

Also when I try to print out the phpinfo I get:

此外,当我尝试打印出 phpinfo 时,我得到:

System  Linux bear.dnsracks.com 2.6.18-92.1.13.el5PAE #1 SMP Wed Sep 24 20:07:49 EDT 2008 i686
Build Date  Jun 8 2009 13:50:29
Configure Command   './configure' '--disable-pdo' '--enable-bcmath' '--enable-calendar' '--enable-ftp' '--enable-gd-native-ttf' '--enable-libxml' '--enable-magic-quotes' '--enable-mbstring' '--enable-sockets' '--prefix=/usr' '--with-curl=/opt/curlssl/' '--with-freetype-dir=/usr' '--with-gd' '--with-gettext' '--with-imap=/opt/php_with_imap_client/' '--with-imap-ssl=/usr' '--with-jpeg-dir=/usr' '--with-kerberos' '--with-libxml-dir=/opt/xml2/' '--with-mcrypt=/opt/libmcrypt/' '--with-mysql=/usr' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--with-mysqli=/usr/bin/mysql_config' '--with-openssl=/usr' '--with-openssl-dir=/usr' '--with-png-dir=/usr' '--with-ttf' '--with-xpm-dir=/usr' '--with-zlib' '--with-zlib-dir=/usr'
Server API  CGI
Virtual Directory Support   disabled
Configuration File (php.ini) Path   /usr/lib
Loaded Configuration File   /usr/local/lib/php.ini
Scan this dir for additional .ini files     (none)
additional .ini files parsed    (none)
PHP API     20041225
PHP Extension   20060613
Zend Extension  220060519
Debug Build     no
Thread Safety   disabled
Zend Memory Manager     enabled
IPv6 Support    enabled
Registered PHP Streams  php, file, data, http, ftp, compress.zlib, https, ftps
Registered Stream Socket Transports     tcp, udp, unix, udg, ssl, sslv3, sslv2, tls
Registered Stream Filters   string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, convert.iconv.*, zlib.*

This can be seen at http://cubeee.co.in/worm/tester.php

这可以在http://cubeee.co.in/worm/tester.php上看到

However when I get back to my hosting providers, they tell me that they have modified the php.ini to enable the PDO support and they will check again. What is it that I need to do or ask my hosts to do?

然而,当我回到我的托管服务提供商那里时,他们告诉我他们已经修改了 php.ini 以启用 PDO 支持,他们会再次检查。我需要做什么或要求我的主人做什么?

回答by krishna

if (!defined('PDO::ATTR_DRIVER_NAME')) {
echo 'PDO unavailable';
}
elseif (defined('PDO::ATTR_DRIVER_NAME')) {
echo 'PDO available';
}

I hope this works

我希望这有效

回答by karim79

The configure command in your PHP output shows:

PHP 输出中的配置命令显示:

'--disable-pdo'

so I think it's safe to assume that they haven't enabled it.

所以我认为可以安全地假设他们没有启用它。

回答by David Snabel-Caunt

Does this application want Pdo_Mysql? If so you may be able to use the Mysqli adapter instead - it depends on the software but it's possible.

这个应用程序需要 Pdo_Mysql 吗?如果是这样,您可以改用 Mysqli 适配器 - 这取决于软件,但这是可能的。

In the area where you set your database connection details, there's probably an option called 'adapter'. Try setting its value to 'mysqli'

在您设置数据库连接详细信息的区域中,可能有一个名为“适配器”的选项。尝试将其值设置为 'mysqli'