[ CMD_API ] Have way to change PHP version of unique account ?

waldemarlima

Verified User
Joined
Jul 17, 2020
Messages
8
hello everyone !

i would like to know if have a way to change PHP version of specific account ?
 

scriptkitty

Verified User
Staff member
Joined
Jul 10, 2019
Messages
272
Hello,

These are the parameters

Code:
CMD_API_DOMAIN
Post string: php1_select=2&domain=DOMAIN.TLD&json=yes&action=php_selector&save=yes

Here is the API via curl to do this for the user 'fred' using his password 'password' and for his domain 'DOMAIN.TLD':

Code:
curl --request POST --user 'fred:password' --data 'php1_select=2&domain=DOMAIN.TLD&json=yes&action=php_selector&save=yes' http://1.2.3.4:2222/CMD_API_DOMAIN

I assume you'd like to know how to find these commands for yourself? If so:

Log into your server via SSH. Run DA in debug mode:

https://help.directadmin.com/item.php?id=293

I like to modify that last command like this:

Code:
./directadmin b2000 | grep "CMD_\|Post"

Now, open a browser and log into your DirectAdmin GUI and perform the action that you need to automate. You will see something like this among the output:

Code:
CMD_DOMAIN
Post string: php1_select=2&domain=DOMAIN.TLD&json=yes&action=php_selector&save=yes

Change CMD_DOMAIN to CMD_API_DOMAIN to use in the API (any CMD_* call can be altered to CMD_API_* to be used via API) and adjust the Post string accordingly. Now you can use this in your script! A PHP wrapper exists:

http://forum.directadmin.com/showthread.php?threadid=258

But I prefer most of my automation in bash using curl:

https://help.directadmin.com/item.php?id=580

More information:

https://www.directadmin.com/api.php

Thanks for choosing DirectAdmin! :)
 

scriptkitty

Verified User
Staff member
Joined
Jul 10, 2019
Messages
272
OH, and to clarify further just in case anyone needs it:

- php1_select is the php version your site will use (your primary choice)
- php2_select is the 2nd php version for your site (if you were to use 2 different php versions for your site - not common)
- the 2 in php1_select=2 corresponds to php2_release in the /usr/local/directadmin/custombuild/options.conf file

So, by setting php1_select to '2' will cause it to use whatever PHP version you have set for php2_release.
 

maxi32

Verified User
Joined
Jul 25, 2016
Messages
188
Location
Malaysia
any CMD_* call can be altered to CMD_API_* to be used via API) and adjust the Post string

Just found out I got error when using CMD_API_SECURITY_QUESTIONS.

"error": "no container class for data"

Changed back to CMD_SECURITY_QUESTIONS without 'API_' and it works. Maybe this is a bug ?
 

scriptkitty

Verified User
Staff member
Joined
Jul 10, 2019
Messages
272
Just found out I got error when using CMD_API_SECURITY_QUESTIONS.

"error": "no container class for data"

Changed back to CMD_SECURITY_QUESTIONS without 'API_' and it works. Maybe this is a bug ?
Maybe not added to the API yet. I'll inquire our developers. Thanks for noticing and reporting!
 
Top