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.

cPanel PHP : How does it work ?

Discussion in 'cPanel Developers' started by tizoo, Oct 6, 2012.

  1. tizoo

    tizoo Well-Known Member

    Joined:
    Jan 6, 2004
    Messages:
    66
    Likes Received:
    0
    Trophy Points:
    6
    Hi all,

    For the module I'm developping I need the SOAP support in PHP and PDO support for SQLite.

    The module has one cPanel part for the customer and one WHM part for the adminstrator.

    The cPanel module was ok, the PHP version used seemed to be the same as the one generated by easyapache for the customers (5.3.14 I guess). It had PDO and SOAP support.

    The problem was with the WHM module that seemed to use another PHP version (5.2.9 I guess) that didn't include SOAP support.

    As I didn't know how to rebuild the cPanel PHP version I posted the question on the forum.

    And then I started to search information about the file *makecpphp.profile.yaml* and the script */scripts/makecpphp* and found that there are 2 differents directory where we can found the file :

    1) /var/profiles/easy/apache/profile/makecpphp.profile.yaml
    2) /var/cpanel/easy/apache/profile/makecpphp.profile.yaml

    Modifying the first file seems doing nothing and modifying the second do... some really strange things as the file seems to be rewritten before build... As modifying it dont change anything to the PHP configuration what is also viewable during build time (the selected version of PHP is 5.3.17):

    /bin/sh /home/cpeasyapache/src/php-5.2.17/libtool ....

    Then the idea was to prevent the process to change the file by setting its immutable flag (chattr +i). I succeded then in having the PHP version I selected with the SOAP support.

    BUT... I lost PDO support.

    The PDO extensions were not loaded in the /usr/local/cpanel/3rdparty/etc/php.ini file. What means that the build process generated a php.ini file that is not related to the configuration.

    Finally, even when adding the corresponding lines in the php.ini file to load PDO extensions it doesn't work as the PDO extensions are not present in the *extension_dir* (/usr/local/cpanel/3rdparty/lib/php/extensions/no-debug-non-zts-20060613).

    And what is also strange is that this process of rebuilding PHP with makecpphp changes the PHP version used in my WHM module as in my cPanel module which were different before.

    Searching on the forum didn't give me any interesting information about the right way to do this.

    Could some one explain what is what in this rebuild process and how to do it the right way ?

    Especially :

    1) What is the right file to modify ?
    2) How to be certain it is used in the build process ?
    3) How to have PDO extension and support if we lost it ?
    4) How to recover the default PHP installation (with PDO) ?
    5) How to add SOAP (or anything else) to the default PHP installation without loosing anything ?

    Thanks a lot in advance for any tips that could help me to at least recover the default PHP with PDO support (point 4)

    Cheers,
    Philippe
     
  2. tizoo

    tizoo Well-Known Member

    Joined:
    Jan 6, 2004
    Messages:
    66
    Likes Received:
    0
    Trophy Points:
    6
    Having a more indeep look to the documentation, I discovered the file :

    /var/cpanel/usecpphp

    That let me fall back to the PHP version build for my customers, if I delete it. Which is the solution for my cPanel module that perfectly works in this configuration.

    The problem is that the PHP version of WHM is now 5.2.6 and NOT the same as the cPanel one. And it doesn't contain the support for SOAP.

    What I understand now is that when I build a new PHP with */scripts/makecpphp* the file */var/cpanel/usecpphp* is created and then cPanel and WHM modules use the newly created PHP binary. But...

    1) The makecpphp script dont take my configuration into account unless I set it as immutable.

    2) I must have a look to the end of the build process and to the new PHP binary as it is installed in :

    /var/cpanel/3rdparty/bin/php

    And its extensions in :

    /var/cpanel/3rdparty/include/php/

    But it reads its configuration from :

    /usr/local/cpanel/3rdparty/etc/php.ini

    Which states that the extension modules should be here :

    /usr/local/cpanel/3rdparty/lib/php/

    Then when I test the PHP newly build, I lost the PDO support as it cannot load the modules.

    Then I modified */usr/local/cpanel/3rdparty/etc/php.ini* as follow :

    ;PNY: Added */var/cpanel/3rdparty/lib/php/* after having recompiled PHP.
    include_path = "/var/cpanel/3rdparty/lib/php/:/usr/local/cpanel/3rdparty/lib/php/:."
    ;PNY: After having recompiled PHP, the extensions are in another place..
    ;;;extension_dir = "/usr/local/cpanel/3rdparty/lib/php/extensions/no-debug-non-zts-20060613"
    extension_dir = "/var/cpanel/3rdparty/lib/php/extensions/no-debug-non-zts-20090626"

    And now the WHM module works with PDO and SOAP but it is the cPanel module that don't work anymore as it use the *CPANEL* class to be integrated in the interface and it seems that this doesn't work anymore.

    Then now, the new question is "Why does the CPANEL class works with the PHP 5.3.17 build for customer with easyapache and not with the one built for cPanel ?"

    As always, any tips welcome, even an rtfm with a link that I haven't already found.

    Philippe
     
  3. tizoo

    tizoo Well-Known Member

    Joined:
    Jan 6, 2004
    Messages:
    66
    Likes Received:
    0
    Trophy Points:
    6
    And now the end of the answer.

    So it seems that the CPANEL class doesn't work when accessed with PHP 5.3.17.

    Then I rebuilt cPanel PHP in version 5.2.17 and modified */usr/local/cpanel/3rdparty/etc/php.ini* as follow :

    ;PNY: After having recompiled PHP, the extensions are in another place..
    ;;;extension_dir = "/usr/local/cpanel/3rdparty/lib/php/extensions/no-debug-non-zts-20060613"
    ;;;extension_dir = "/var/cpanel/3rdparty/lib/php/extensions/no-debug-non-zts-20090626"
    extension_dir = "/var/cpanel/3rdparty/lib/php/extensions/no-debug-non-zts-20060613"

    And now I have PDO and SOAP in my cPanel plugin as well as in my WHM one.

    I hope that this could be helpfull for somebody else.

    Cheers,
    Philippe
     
Loading...

Share This Page