Child pages
  • UAPI Functions - LangPHP::php_get_vhost_versions
Skip to end of metadata
Go to start of metadata

Description

This function returns the PHP version of every virtual host that a reseller controls.


Note:

This document only applies to systems that run EasyApache 4.

Important:

In cPanel & WHM version 76 and later, when you disable the WebServer role, the system disables this function. For more information, read our How to Use Server Profiles documentation.

Examples


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/LangPHP/php_get_vhost_versions


Note:

This example calls the UAPI function via a cPanel session. For more information, read our Guide to UAPI documentation. 

 LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// List the user's virtual hosts and PHP versions.
$get_vhost_versions = $cpanel->uapi(
    'LangPHP', 'php_get_vhost_versions',
   );


Note:

For more information, read our Guide to the LiveAPI System.

 LiveAPI Perl Module
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# List the user's virtual hosts and PHP versions.
my $get_vhost_versions = $cpliveapi->uapi(
    'LangPHP', 'php_get_vhost_versions',
   );


Note:

For more information, read our Guide to the LiveAPI System.

 cPanel Template Toolkit
<!-- Get a hash of all the data, then display the vhost values. -->
[% data = execute( 'LangPHP', 'php_get_vhost_versions' ); %]
[% FOREACH q = data.vhost %]
     <p>
         [% q %]
     </p>
[% END %]
  
<!-- Get only the account value. -->
[% execute('LangPHP', 'php_get_vhost_versions' ).data.account %]


Note:

For more information, read our Guide to Template Toolkit documentation. 

 Command Line
uapi --user=username LangPHP php_get_vhost_versions


Notes:

  • You must URI-encode values.
  • username represents your account-level username.
  • For more information and additional output options, read our Guide to UAPI documentation or run the uapi --help command. 
  • If you run CloudLinux™, you must use the full path of the uapi command:

    /usr/local/cpanel/bin/uapi


 Output (JSON)
{
   "errors":null,
   "status":1,
   "messages":null,
   "data":[
      {
         "main_domain":1,
         "vhost":"blee.com",
         "version":"ea-php70",
         "account_owner":"root",
         "account":"blee",
         "documentroot":"/home/blee/public_html",
         "php_fpm":1,
         "phpversion_source":{
            "domain":"blee.com"
         },
         "homedir":"/home/blee",
         "php_fpm_pool_parms":{
            "pm_process_idle_timeout":10,
            "pm_max_requests":20,
            "pm_max_children":5
         }
      },
      {
         "php_fpm":0,
         "account":"blee",
         "documentroot":"/home/blee/first.blee.com",
         "php_fpm_pool_parms":{

         },
         "phpversion_source":{
            "domain":"first.blee.com"
         },
         "homedir":"/home/blee",
         "version":"ea-php70",
         "main_domain":0,
         "vhost":"first.blee.com",
         "account_owner":"root"
      },
      {
         "account_owner":"root",
         "vhost":"second.blee.com",
         "main_domain":0,
         "version":"ea-php56",
         "phpversion_source":{
            "system_default":1
         },
         "homedir":"/home/blee",
         "php_fpm_pool_parms":{

         },
         "php_fpm":0,
         "documentroot":"/home/blee/second.blee.com",
         "account":"blee"
      }
   ],
   "metadata":{
      "transformed":1
   },
   "warnings":null
}


Note:

Use cPanel's API Shell interface (cPanel >> Home >> Advanced >> API Shell) to directly test cPanel API calls.

Parameters

This function does not accept parameters.

Returns

ReturnTypeDescriptionPossible valuesExample
 array of hashesAn array of hashes of the virtual host's suspended status, versions, virtual hosts, and accounts.An array of hashes that contains the documentroot, main_domain, homedir, account, account_owner, php_fpm, version, and vhost returns, the phpversion_source array, and the php_fpm_pool_parms hash.  

documentroot

string

The virtual host's document root.

Note:

We introduced this return in cPanel & WHM version 54.

The function returns this value in the unnamed array.

A valid document root path./home/blee/public_html

version

string

The virtual host's PHP version.

The function returns this value in the unnamed array.

  • ea-php54
  • ea-php55
  • ea-php56
  • ea-php70
  • ea-php71
  • ea-php72
  • inherit
  • Any custom PHP package name.
ea-php70

vhost

string

The virtual host's name.

The function returns this value in the unnamed array.

A valid hostname.blee.com

account

string

The account's name.

The function returns this value in the unnamed array.

A valid cPanel account on the server.blee

account_owner

string

The account's owner.

The function returns this value in the unnamed array.

A valid cPanel account on the server.blee

main_domain

Boolean

Whether the virtual host is the primary domain.

Note:

We introduced this return in cPanel & WHM version 54.

The function returns this value in the unnamed array.

  • True — The primary domain.
  • False — Not the primary domain.

    Note:

    In cPanel & WHM version 60 and earlier, this function returns the following possible values:

    • 1 — The primary domain.
    • 0 — Not the primary domain.

True

homedir

string

The virtual host's home directory.

Note:

We introduced this return in cPanel & WHM version 54.

The function returns this value in the unnamed array.

A valid home directory./home/blee

php_fpm_pool_parms

hash

A hash that contain's the domain's PHP-FPM parameters.

Note:

We introduced this return in cPanel & WHM version 58.

The function returns this value in the unnamed array.

A hash that contains the pm_max_children, pm_process_idle_timeout, and pm_max_requests returns. 

pm_max_children

integer

The maximum number of child pages per pool.

The function returns this value in the php_fpm_pool_parms hash.

A valid number of child pages.5

pm_process_idle_timeout

integer

A specified time of idleness before the system kills an FPM child process.

The function returns this value in the php_fpm_pool_parms hash.

A valid timeout value.10

pm_max_requests

integer

The maximum number of requests per pool.

The function returns this value in the php_fpm_pool_parms hash.

A valid number of requests.20

php_fpm

Boolean

Whether FPM is enabled on the virtual host.

Note:

We introduced this return in cPanel & WHM version 60.

The function returns this value in the unnamed array.

  • True — PHP-FPM enabled.

  • False — PHP-FPM not enabled.

    Note:

    In cPanel & WHM version 60 and earlier, this function returns the following possible values:

    • 1 — PHP-FPM enabled.
    • 0 — PHP-FPM not enabled.

1

phpversion_source

array

How the virtual host determines its PHP version.

Notes:

  • We introduced this return in cPanel & WHM version 62.
  • In cPanel & WHM version 64 and later, this value returns an array.

The function returns this value in the unnamed array.

An array that contains either the system_default or domain return.

Note:

In cPanel & WHM version 62, this function returns one of the following values:

  • system:default
  • Any valid domain name, in domain:example.com format.

domain

string

The domain the virtual host inherits its PHP version from.

The function returns this value in the phpversions_source array.

Any valid domain name on the system.blee.com

system_default

integer

Whether the virtual host uses the system's default PHP version.

The function returns this value in the phpversion_source array.

  • 1 — Uses the system default PHP version.

Note:

The function only returns this value if true.

1