• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Rolling out subdomains automatically

elpatron

New Pleskian
I've written a php cli that will add subdomains. It does this by adding the user/subdomain directory and sub-directories/vhost.conf/copying site files/create mysql db/user etc....

But after more review (learning more) I got interested in using the subdomain.exe. This appears a way for me to add subdomains within the confines of plesk (i.e. can see the subdomains via my plesk panel).

Curious as to others experience when it comes to automating subdomain creation.

Also I think my plesk is restricted (godaddy) to x number of domains/subdomains/mysql db's.

-Is it preferable to use the plesk command line to generate the subdomains or use the php cli method?
-If I use the php cli creation method, can I bypass the restrictions in the plesk panel?
-If I use the subdomain.exe do I first need to create the directories for the subdomain in var/www/vhost/<domain>/subdomains/<new subdomain>

Thanks in advance for your review.
 
[resolved]

I threw out the php cli I wrote and now use the Plesk CLI's to autocreate user subdomains and database. This allows me to see the subdomains and the db's via the plesk control panel.

I could not be more pleased! Nice job Parallels!
 
I am glad you got this resolved but just wanted to throw my 2 cents out there since you asked for input - I would recomend using the XML API to do operations as then you dont have to depend on a CLI being able to be called via script - that can lead to security issues if you allow things like exec php functions to be ran on the server.
 
Hi Amin Taheri,

Thank you for the input. I am looking at the Plesk 9.0 API RPC protocol reference which I would not have found without your help.

I had a concern as well using the CLI method but don't have a grasp of the security issues going this route. I rather like XML and have done a little work in that arena but would like to do more.

I suppose my main question would be in approach. Something like this?

Note: I require add domain processing to work out of CRON, as the site needs to be built while the customer is still engaged on the site.

- When my customer signs up for a service, build the mysql db record along the lines of the xml schema I will need. add sub/domain for example
- Export the record from mysql as an xml record
- Pass the xml over to the Plesk 9 API RPC

Advice on how to proceed would be much appreciated.

(I also would like to know if there is a post/event type way of doing this), i.e. when the customer signs up I can post an event that will be picked up by my add call).
 
The API calls wont take too much time, so you could probably do it in real time - otherwise you could build out a queue type system.

Your queue could have a mysql backend that your web page inserts customer data into. Then every X minutes the cron could run, build teh XML and call the API - log the results, and delete the queue item from teh DB.

In my experience this works well for things that dont need to be in real time - IE you dont need to display the results to the user right away - you would send them an email later on once its all setup.

For items that need to be in real time and show a real time status at the end, then you cant really use the queue method as when they click on submit you would need to be able to create the account in real time and tell them if it worked or not, and then give them the next steps (like sorry, that username is taken, try again - or congrats, click here to login, etc). You could do this via ajax on your form, or a normal php post process that locks the page state - that part is up to you.

In terms of the event, those only really happen in Plesk itself, but making an API call that triggers that event is possible. For example, you can have an event for domain created, or sub domain created, and have that then call a php or SH file with some passed in params which then could populate data or copy files, etc all outside of your php page signup process so it happens in the background, and you can set that up to log to files, database, etc on the status so you can always come back and check it out later.
 
Today everyone batches web space application builds, get a site in ten minutes or less etc.

Our current flow: when the customer registers for their application an email human check verification is built and sent to the customer. The customer then clicks on the registration link which will set the mysql field to Y. Then a cron child will check to see if there is any work to do and if so, for now just add the sub/domain. (we also have spam checks internally)

Preferably we would like to offer when the user verifies their registration,ssue build request started/completed messages, and on good completion a link to their front/back ends, logon information etc. To do this I would need to post and wait for linux/plesk to do a build and return to the caller (a php page) to update the customer.

Outside (API RPC code). Here are the things I would currently do outside of the Plesk CLI, if any can be resolved using either the Plesk 9 CLI OR API RPC please let me know.

o we copy bundle files depending on what the customer selected.

-root files using Linux CP to copy the root bundle, problem is that the original bundles site files own/group file permissions are part of the copy. So a CLI is needed to shell_exec chown user:grp. on httpdocs/* As I understand : Plesk 9+ does not support having Manage Virtual Host Templates. Else I could just put my bundle in a template.
-using mysql dump to load the bundle mysql db.

o application unique processing
-changes required for application port (like emeded site url's), yes they are still doing it!
-site customer information and personalization.

Thanks again.

note: on virtual domain templates. cpanel as I understand has an 'experimental' version.
 
PHP does not have a post/event processor that would work between cli/sapi. If I were to choose a realtime 'pseudo' path, I'd have to go with MYSeries.
 
Back
Top