Need Assistance with automagically create a db/site/insert the sql.


May 25, 2010
Hi their complete newbie with Cpanel stuff so bare with me.

I'm going to be offing a web based service. All I'm tring to determine is when the account gets created, how do I run a either a PHP script or the API Calls to automagically create a, db, copy source dir. to dest dir. for site and insert the sql into the new db.
I'm not tring to create actual plugin as this will be used as a per customer basis. My office staff will be using AccountLabPlus to manage Account creation, Suspension, and Kill, I just want cpanel to setup run this task on creation only.

Here is where I stand so far:
Step 1 -
postwwwacct - I realize I have to append something here (maybe) to start the execution or
I create a script of somesort and stick in the scripts dir?
I found this however it's for creating a addon I assume?
Creating a new cPAddon Script

Also I assume I would name the script with post/pre to have it execute either before/after the creation?
This is the most confusing part to me.

Either via API calls or php script execute the following:
Step 2 -
Fileman::dofileop(/srv, ,/home/user/public_html,copy) // Attempting to copy source dir to destination dir.
Will this work ? (my syntax may be wrong)

Step 3 -
Mysql::adddb(mydb) ; // create db
Mysql::adduser(dba,pwd); //create db user
Mysql::adduserdb(mydb,dba,all); // add user to db and grant ALL rights

Step 4 -
Run insert script to pouplate Database
My plan was going to have the sql file stored on the server and run a include/ require_once statement after step 3 is completed to execute the insert. Would this work?

Once completed do I end up with a 1 page script that in placed in the scripts directory, that calls/executes everything.

Sorry for the story tring to be specific as possible.
Thanks for any help in advanced.


Well-Known Member
Staff member
Dec 17, 2009
Houston, TX
cPanel Access Level
Root Administrator
Hi tommyb

You've got the basic concepts ;)

1) you need a postwwwacct script - can be any shebang shell you want. I prefer PHP cause it helps...

2) Make API calls to localhost. I utilize the XMLAPI PHP client class. It will do most of the heavy-lifting. You should use whatever language you're comfortable with to make these URL requests.

3) Send various API1 calls to XML-API binary on localhost - this could include doing file move and extraction and db creation, etc.. However, for file unpacking/moving you might do better just to do it in the shell script (depends).

4) Load in MySQL data to freshly created database with `mysql` CLI


There are a few forum threads around that talk about postwwwacct scripts.

Also, I know I probably helped you in the least way possible considering the level of detail in your question, and for that I'm sorry. However, I intend post on the Integration Blog (cPanel - cPanel Integration) later this week about database creation via account creation (courtesy /scripts/wwwacct). I still have to wrap up the details, which I'd need time to do for you anyway :D

So, hang tight and I'll get you more info ASAP.



May 25, 2010
Thanks Dave, look forward to reading the article. I'll post back my progress, or problems here.