PHP function to add Addon Domain

fmosse

Well-Known Member
Jan 6, 2002
68
1
308
Hi,

I have a PHP script that uses cpaneluapi.class.php to create a MySQL database, user, password and connects the user to the database.

I need to add the code to create a ADDON DOMAIN and "put the domain addon" outsite public_html.

For example:

main domain: www.mywebsite.com in /home/user/public_html
addon domain: www.seconddomain.com in /home/user/seconddomain.com

Is this possible?

thanks,
Francisco
 
Last edited by a moderator:

cPanelThomas

Developer
Feb 16, 2023
32
23
83
cPanel
cPanel Access Level
Root Administrator
You'd need to ensure that the "Restrict document roots to public_html" setting is off in WHM's Tweak Settings. Only then is that allowed. Since your script is in the context of cPanel itself, you may not be able to accomplish this without the cooperation of the server administrator. If, of course, you are the server administrator (or run in that context at some point to install your script), then that shouldn't be a problem -- just ensure the following is run as root:
Code:
/usr/local/cpanel/bin/whmapi1 set_tweaksetting module=Main key=publichtmlsubsonly value=0
 
  • Like
Reactions: cPRex