Child pages
  • WHM API 1 Functions - php_set_vhost_versions

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Description

Excerpt

This function sets a virtual host's PHP versionallows WHM's MultiPHP Manager interface (Home >> Software >> MultiPHP Manager) to change the values of a domain.

Include Page
LIB:_

EA4Note

PHP-FPMRAMWarning76
LIB:_

EA4Note

PHP-FPMRAMWarning76

Multiexcerpt include
SpaceWithExcerptLIB
MultiExcerptNameAPIDisabledWebServerRole
PageWithExcerptLIB:_ServerRoleDisabledAPI

Panel
bgColor#F2F2F2
borderStylenone

Examples


Panel
bgColor#FFFFFF
borderStylenone


Expand
titlecPanel or Webmail Session URLJSON API


Code Block
languagetextxml
https://hostname.example.com:20832087/cpsess##########/executejson-api/LangPHP/php_set_vhost_versions?php-fpmapi.version=1&version=ea-php55&vhost=example.com&vhost-1=example1.com
Include Page
LIB:_CallUAPIFromBrowserLinkLIB:_CallUAPIFromBrowserLink
-0=rm5.tld



LiveAPI Perl Module
Expand
titleLiveAPI PHP ClassXML API
title


$cpanel = new CPANEL(); // Connect to cPanel - only do this once.   // Set the PHP version of the virtual hosts. $set_vhost_version = $cpanel->uapi( 'LangPHP', '
Code Block
languagephp
linenumberstrue
xml
https://hostname.example.com:2087/cpsess##########/xml-api/php_set_vhost_version',
    array(
		'php-fpm'	  => '1'
		'version'	  => 'ea-php-54',
        'vhost-1'     => 'example.com', 
        'vhost-2'	  => 'example1.com'
         )
);
Include Page
LIB:_LiveAPIPHPLinkLIB:_LiveAPIPHPLink
Expand
versions?api.version=1&version=ea-php55&vhost-0=rm5.tld



Expand
titleCommand Line


my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.   # Set the PHP version of the virtual hosts. my $set_vhost_version = $cpliveapi->uapi( 'LangPHP', '
Code Block
languageperlbash
linenumberstrue
titleSet a version for a vhost
whmapi1 php_set_vhost_version',
    (
		'php-fpm'	  => '1'
		'version'	  => 'ea-php-54',
        'vhost-1'     => 'example.com', 
        'vhost-2'	  => 'example1.com'
    )
);
Include Page
LIB:_LiveAPIPerlLinkLIB:_LiveAPIPerlLink
Expand
titlecPanel Template Toolkit
Code Block
languagexml
linenumberstrue
<!-- Set the PHP version of a vhost. -->
[% data = execute( 'LangPHP', 'versions version=ea-php55 vhost-0=rm5.tld


Code Block
languagebash
titleSet the PHP-FPM parameters
whmapi1 php_set_vhost_version'{ 'php-fpm' => '1','version' => 'ea-php-54','vhost-1' => 'example.com','vhost-2' => 'example.com' } ); %]
Include Page
LIB:_TTLinkLIB:_TTLink
Expand
titleCommand Line
Code Block
languagetext
uapi --user=username LangPHP php_set_vhost_versions php-versions vhost-0=rm5.tld php_fpm_pool_parms='{"pm_max_children":15,"pm_process_idle_timeout":100,"pm_max_requests":200}' php_fpm=1 version=ea-php55 vhost=example.com vhost-1=example1.comphp56

 

Include Page
LIB:_UAPICLINoteWHMAPI1CLINote
LIB:_UAPICLINoteWHMAPI1CLINote


Expand
titleOutput (JSON)


Code Block
languagetext
linenumberstrue
{  
   "messagesmetadata":null,{  
      "errorsreason":["OK",
      "Noresult":1,
users correspond to the domain  "example1.comcommand".":"php_set_vhost_versions",
   ],    "statusversion":01
   },
   "metadatadata":{  

   },

}



Expand
titleOutput (XML)


Code Block
languagetext
linenumberstrue
<result>
  "data":{  <metadata>
    "vhosts":[    <reason>OK</reason>
     "example.com"   <result>1</result>
   ]    }
} <command>php_set_vhost_versions</command>
        <version>1</version>
    </metadata>
    <data/>
</result>


Include Page
LIB:_cPanelAPIShellNoteWHMAPIShellNote
LIB:_cPanelAPIShellNoteWHMAPIShellNote


Parameters

Return
Type
Description
Possible values
Example

vhosts

arrayThe names of the changed virtual hosts.

A virtual host on the system.

example.com
ParameterTypeDescriptionPossible valuesExample
php-_fpm_pool_parmsBooleanWhether to enable the PHP FastCGI Process Manager (PHP-FPM) serviceJSON

A JSON string that encodes a hash of values.

Note
titleNote:

We added introduced this parameter in cPanel & WHM version 60.

  • 1 — Enable the service.
  • 0 — Disable the service.
1

version

string

Required

The PHP version of a virtual host.

A valid PHP version on the system.

 

ea-php54


vhost

string

Required

The virtual host's name.

A valid JSON string that contains the pm_max_children, pm_process_idle_timeout, and pm_max_requests parameters.

 

pm_max_children

integer

The maximum number of child pages per pool.

This parameter defaults to 5.

Note
titleNote:

You must supply this value in the php_fpm_pool_parms hash.


A valid child value.5

pm_process_idle_timeout

integer

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

This parameter defaults to 10.

Note
titleNote:

You must supply 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.

This parameter defaults to 20.

Note
titleNote:

To change the PHP version of multiple virtual hosts, duplicate or increment the parameter name. For example, to change three virtual hosts, you can:

  • Use the vhost parameter multiple times.
  • Use the vhost-1, vhost-2, and vhost-3 parameters.

A valid virtual host on the system.

example.com

Returns

You must supply this value in the php_fpm_pool_parms hash.


A valid request value.20
php_fpmBoolean

Whether PHP-FPM is enabled.

This parameter defaults to 0.

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

version

string

Required

The virtual host's PHP version.

Include Page
LIB:_APIPHPVersions
LIB:_APIPHPVersions

ea-php70

vhost-0

string

Required

The virtual host's name.

A valid hostname.otherchars.rm3.tld

Returns

This function only returns metadata.