Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

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.

How to get or set php_directives using WHM API 1

Discussion in 'cPanel Developers' started by manish12345, Jul 5, 2017.

Tags:
  1. manish12345

    manish12345 Member

    Joined:
    Mar 2, 2017
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Indore
    cPanel Access Level:
    Website Owner
    How to get or set php_directives using WHM API 1

    i tried but i get below response
    {"metadata":{"result":0,"version":1,"reason":"Permission denied: You do not have the required privileges to run “php_ini_get_directives”.","command":"php_ini_get_directives"}}

    This is the issue of permission,
    What permissions is required to get or set php_directives.
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,425
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
  3. manish12345

    manish12345 Member

    Joined:
    Mar 2, 2017
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Indore
    cPanel Access Level:
    Website Owner
    I am using WHM account username and password while executing API but still get the permission issue,
    Look at the code below which i executes


    Code:
    <?php
    $whm_user = 'WHMUSER';
    $whm_pass = 'WHMPASSWORD;
    $directive_1 = "upload_max_filesize:500M";
    $encoded_directive_1 = urlencode($directive_1);
    $directive_2 = "post_max_size:500M";
    $encoded_directive_2 = urlencode($directive_2);
    $query = "https://example.com:2087/json-api/php_ini_set_directives?api.version=1&directive-1=".$encoded_directive_1."&directive-2=".$encoded_directive_2."&version=ea-php54";
    $curl = curl_init();                                // Create Curl Object
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,0);       // Allow self-signed certs
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,0);       // Allow certs that do not match the hostname
    curl_setopt($curl, CURLOPT_HEADER,0);               // Do not include header in output
    curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);       // Return contents of transfer on curl_exec
    $header[0] = "Authorization: Basic " . base64_encode($whm_user.":".$whm_pass) . "\n\r";
    curl_setopt($curl, CURLOPT_HTTPHEADER, $header);    // set the username and password
    curl_setopt($curl, CURLOPT_URL, $query);
    $result = curl_exec($curl);
    if ($result == false) {
        error_log("curl_exec threw error \"" . curl_error($curl) . "\" for $query");  // log error if curl exec fails
    }
    curl_close($curl);
    $resp = json_decode($result);
    print_r($resp);
    
    

    Is that anything wrong i do in API call , Please guide me any better way if exist,
    I am using PHP as backend language.
     
    #3 manish12345, Jul 6, 2017
    Last edited by a moderator: Jul 7, 2017
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,425
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Can you confirm if this is the "root" username, or a reseller username?

    Thank you.
     
  5. manish12345

    manish12345 Member

    Joined:
    Mar 2, 2017
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Indore
    cPanel Access Level:
    Website Owner
    WebHost Manager.png
    Yes this is reseller user, see the attached image of control panel after successful login.
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,425
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
  7. manish12345

    manish12345 Member

    Joined:
    Mar 2, 2017
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Indore
    cPanel Access Level:
    Website Owner
    I understand it but why its not allowed to change php directives using reseller account, a reseller account has privileges for creating and manipulating account but not allowed to configure simple settings via API call, thats not fair. I can easily configure it manually by going to cpanel dashboard, my requirement is to change it from API call and untill it is not solved my site functionality in not complete. Please allow it also for reseller accounts.
     
  8. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,425
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

    It's not possible to update PHP versions and settings through Web Host Manager as a reseller. However, you are correct that this is possible for individual cPanel accounts. Here is the corresponding UAPI module available for use with individual cPanel accounts:

    UAPI Modules - LangPHP - Software Development Kit - cPanel Documentation

    I encourage you to open a feature request if you'd like to see an option to modify PHP version and configuration settings as a reseller:

    Submit A Feature Request

    Thank you.
     
  9. manish12345

    manish12345 Member

    Joined:
    Mar 2, 2017
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Indore
    cPanel Access Level:
    Website Owner
    Thanks for reply, i have submit a feature request.

    and i tried the UAPI Module and its not working, give the following error

    {"status":0,"data":null,"messages":null,"errors":["(XID ypckg2) “PHP” is not installed on the system."],"metadata":{}}
     
  10. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    38,658
    Likes Received:
    1,425
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Could you let us know how we can reproduce the error message? Have you tried reproducing the issue using the UAPI function via the command line?

    Thank you.
     
Loading...

Share This Page