WHM API: Updating PHP version/Adding database on single account

Ricardo7

Registered
Jul 30, 2019
4
0
1
USA
cPanel Access Level
Root Administrator
I'm currently using WHM API and have successfully been able to use the createacct function to launch a new site on WHM. The only thing is, the default PHP version on our WHM account is PHP5.6 and I need these sites to be PHP7.2. I'd also like to be able to update the php.ini file per setup. And of course, set up an SMTP account with the API.

Added bonus would be help on how I can create a database using the API, and import my sql template. Also, cloning my project skeleton into file manager on the newly created accounts.

Please help!
 

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,304
363
Houston
The only thing is, the default PHP version on our WHM account is PHP5.6 and I need these sites to be PHP7.2
You can use the multiPHP manager to modify your PHP version for each account on the server - to set the default php version for accounts as well. You can use whmapi1 to do this too the function for this can be found here: WHM API 1 Functions - php_set_system_default_version - Developer Documentation - cPanel Documentation

I'd also like to be able to update the php.ini file per setup
Can you explain in more detail what you mean for this and I can probably get you pointed in the right direction.

set up an SMTP account with the API.
That can be done using UAPI - https://documentation.cpanel.net/display/DD/UAPI+Functions+-+Email::add_pop

Added bonus would be help on how I can create a database using the API,
You can use UAPI for this as well:

Create the DB
https://documentation.cpanel.net/display/DD/UAPI+Functions+-+Mysql::create_database

Create the User:
https://documentation.cpanel.net/display/DD/UAPI+Functions+-+Mysql::create_user

Set Privileges:
https://documentation.cpanel.net/display/DD/UAPI+Functions+-+Mysql::set_privileges_on_database

and import my sql template
I'm not entirely sure what you mean here as far as the template goes, can you elaborate?

Also, cloning my project skeleton into file manager on the newly created accounts.
I think this might for work for what you're looking for https://documentation.cpanel.net/display/82Docs/Skeleton+Directory
 

Ricardo7

Registered
Jul 30, 2019
4
0
1
USA
cPanel Access Level
Root Administrator
For php.ini, I would like to set: upload size to 100M, memory_limit to 100M, max_execution_time to 90.

For importing my sql template, this is a copy of the database tables with some prefilled content. It is a .sql I just need to import into the newly created database.

Thank you!!!
 

cPanelLauren

Product Owner II
Staff member
Nov 14, 2017
13,266
1,304
363
Houston
For php.ini, I would like to set: upload size to 100M, memory_limit to 100M, max_execution_time to 90.
You could set these globally for each PHP version
WHM API 1 Functions - php_ini_set_content - Developer Documentation - cPanel Documentation
WHM API 1 Functions - php_ini_set_directives - Developer Documentation - cPanel Documentation

For importing my sql template, this is a copy of the database tables with some prefilled content. It is a .sql I just need to import into the newly created database.
All the MySQL related UAPI functions can be found here: UAPI Modules - Mysql - Developer Documentation - cPanel Documentation

Though I don't think what you're looking for exactly is here, it almost sounds like importing a mysqldump is more along what you're looking to do.

Oh, and is there a way to add IMAP vs POP? I do not see that in the UAPI url you sent :/
While the UAPI function's name is deceiving any email account created within cPanel can be used as POP or IMAP when connecting to a mail client, when using webmail it's an IMAP connection
 

Ricardo7

Registered
Jul 30, 2019
4
0
1
USA
cPanel Access Level
Root Administrator
For php.ini, is there a way to set these individually for each account? There are many other accounts that don't need these updates, and could bog our server.