thewebhosting

Well-Known Member
May 9, 2008
1,201
1
68
Hi,

How can I enable PDO PHP module. Do I need to recompile Apache and PHP to enable it?

Thanks,
 

thewebhosting

Well-Known Member
May 9, 2008
1,201
1
68
I have tried to recompile Apache from WHM's "Apache Update" option, but I could not find the option to enable PDO. Can you tell me at which step I will get the option to it?
 

thewebhosting

Well-Known Member
May 9, 2008
1,201
1
68
I have got the below details by running "/usr/local/cpanel/3rdparty/bin/php -i | grep -i pdo" command:

Code:
[[email protected] ~]# /usr/local/cpanel/3rdparty/bin/php -i | grep -i pdo
<h2><a name="module_PDO">PDO</a></h2>
<tr class="h"><th>PDO support</th><th>enabled</th></tr>
<tr><td class="e">PDO drivers </td><td class="v">sqlite2, sqlite </td></tr>
<h2><a name="module_pdo_sqlite">pdo_sqlite</a></h2>
<tr class="h"><th>PDO Driver for SQLite 3.x</th><th>enabled</th></tr>
<tr><td class="e">PECL Module version </td><td class="v">(bundled) 1.0.1 $Id: pdo_sqlite.c,v 1.10.2.6.2.2 2007/03/23 14:30:00 wez Exp $ </td></tr>
But when I try to connect using sample test script it gives me an error "Fatal error: Class 'PDO' not found "

Sample code:
PHP:
<?php
$username = dbusername;
$password = dbuserpassword;
$dbh = new PDO('mysql:dbname=dbname;host=localhost', $username, $password);
// let's have exceptions instead of silence.
// other modes: PDO_ERRMODE_SILENT (default - check $stmt->errorCode() and $stmt->errorInfo())
//              PDO_ERRMODE_WARNING (php warnings)
$dbh->setAttribute(PDO_ATTR_ERRMODE, PDO_ERRMODE_EXCEPTION);
// one-shot query
$dbh->exec("create table test(name varchar(255) not null primary key, value varchar(255));");
?>
I am using mysql 5.0.45.

How can I fix the issue?

Thanks,
 
Last edited:

cPanelKenneth

cPanel Development
Staff member
Apr 7, 2006
4,576
49
308
cPanel Access Level
Root Administrator
I have got the below details by running "/usr/local/cpanel/3rdparty/bin/php -i | grep -i pdo" command:

That is not the PHP binary used for Apache processes. It is what cPanel uses for internal applications, such as Horde and Squirrelmail.

Apache uses the system PHP, which you will find here:

/usr/bin/php
/usr/local/bin/php
/usr/local/apache/modules/libphp5.so

To enable PDO in the system PHP:

1. Login to WHM
2. Click Apache Update
3. Click Start Customizing Based on Profile
4. Select an Apache version
5. Click Next Step
6. Select PHP 5
7. Click Next Step
8. Select a version of PHP 5
9. Click Next Step
10. Click Exhaustive Options List button
11. Scroll down to the check box labeled PDO
12. Click Save and Build
 
  • Like
Reactions: Alexandru Serban