The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Enable PDO

Discussion in 'General Discussion' started by thewebhosting, May 11, 2008.

  1. thewebhosting

    thewebhosting Well-Known Member

    Joined:
    May 9, 2008
    Messages:
    1,201
    Likes Received:
    1
    Trophy Points:
    38
    Hi,

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

    Thanks,
     
  2. jayh38

    jayh38 Well-Known Member

    Joined:
    Mar 3, 2006
    Messages:
    1,215
    Likes Received:
    0
    Trophy Points:
    36
    Yes you will need to recompile apache and select the option.
     
  3. thewebhosting

    thewebhosting Well-Known Member

    Joined:
    May 9, 2008
    Messages:
    1,201
    Likes Received:
    1
    Trophy Points:
    38
    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?
     
  4. thewebhosting

    thewebhosting Well-Known Member

    Joined:
    May 9, 2008
    Messages:
    1,201
    Likes Received:
    1
    Trophy Points:
    38
    I have got the below details by running "/usr/local/cpanel/3rdparty/bin/php -i | grep -i pdo" command:

    Code:
    [root@server ~]# /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_ERRMODEPDO_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,
     
    #4 thewebhosting, May 13, 2008
    Last edited: May 13, 2008
  5. cPanelKenneth

    cPanelKenneth cPanel Development
    Staff Member

    Joined:
    Apr 7, 2006
    Messages:
    4,461
    Likes Received:
    22
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator

    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
     
    Alexandru Serban likes this.
  6. thewebhosting

    thewebhosting Well-Known Member

    Joined:
    May 9, 2008
    Messages:
    1,201
    Likes Received:
    1
    Trophy Points:
    38
    Thanks Kenneth,

    I managed to enable PDO.
     
Loading...

Share This Page