Hi, does anybody now what is the best way to create a new subdomain and a new database and then populating them with files and sql dump when a new user register to a website? I read online it could be done with cPanel API and php but all the articles I’ve found so fare are quite dated.
cPanel, Inc. produces four current and two deprecated APIs, and they all include separate sets of functions. Make certain that the function and module that you call exist in the API version that your code uses.
I would like to add ‘trial and error’ to Mittineague’s remarks.
Be prepared to make lots of mistakes and loose data occasionally so backups are a must. I’ve been coding a long time and managed to mess up my localhost about 8 weeks ago. It took me about an an hour to put it back together.
Every coding mistake is a learning experience. The bigger the mistake the easier it is to remember what you learned.
I ALWAYS look forward to days that I get all the learning I can handle.
Hi @Mittineague thanks for your reply, I’m thinking to get a VPS and not a normal shared host, I’m not going to create infinite subdomain because it will be a payment subscription so the application will be installed into a new subdomain only if the user has paid for a yearly subscription.
Thanks for providing the link to the API, I’ve found this article http://www.learnsourcecode.com/blogs/create-mysql-database-using-cpanel-api-in-php that explains how to create a database but nothing for new subdomains.
Do you think this approach will work in a VPS I tried to test it on shared host and it doesn’t work maybe because there are some limitation made by the host provider.
Hi @spaceshiptrooper thanks for your help. Now I need to work out how to create the php application to check subdomain availability, create the subdomain and move files into the subdomain folder. Also how can create a new database?
Many thanks
I have never done this before so I can’t say that I’m an expert at it. I have just read up on a few of these. So it’s out of my scope to say how one would create new databases based on the subdomains.