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

4

我正在使用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}

同时,当我尝试打印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.*

这可以在 http://cubeee.co.in/worm/tester.php 上查看。
然而,当我回到我的主机提供商那里时,他们告诉我他们已经修改了php.ini以启用PDO支持,并将再次检查。那么我需要做什么或者要求我的主机提供商做什么呢?
3个回答

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

我希望这个能够正常工作


这个回答比被采纳的回答更有帮助。我的 phpinfo() 显示 --disable-pdo,但这告诉我 PDO 是可用的。 - HellaMad
这证实了我的怀疑,谢谢! - Drewdin

5
您的 PHP 输出中的 configure 命令显示:
'--disable-pdo'

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


1
他们本可以事后构建扩展,然后使用extension=php_pdo加载它。但这也会显示在phpinfo()的输出中 - 但它没有,没有pdo支持。 - VolkerK
这就是为什么共享主机是一场噩梦的原因! - David Snabel-Caunt
是的 - 你有mysql、mysqli,但没有PDO。如果你想查看是否安装了PDO,只需在页面中搜索PDO,并查看它是否在真实模块中提到。 - Justin

0

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

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


你不需要Pdo吗?我有误解吗? - David Snabel-Caunt

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接