I’ve built an app in PHP that runs on Apache.
I need to be able to add vhosts on the fly so I would make my app write to sites-enabled
and then reload Apache.
The only problem is, I have no choice but to use Plesk on this server as well. What would I edit on Plesk in order to be able to add vhosts on the fly without having Plesk overwrite it or cause any problems?
I’ve never had the chance to dig into Plesk too much so any guidance would be appreciated.
2
Answers
This is slightly tricky to handle with Plesk as the control panel likes to be in control of the Apache configuration files and certain files are automatically generated by Plesk to ensure that system settings remain consistent.
There are a number of approaches you could take depending on your requirements.
1) Make your app setup new sites on the local machine using the Plesk API. This would give you full control of the sites with the control panel and everything that entails. It’s also the most complicated solution.
2) If the sites can be addressed with the same domain, i.e. you are setting up subdomains a simple wildcard entry in the conf/vhost.conf for the master domain record would do it:
ServerAlias *.mydomain.com
You could then use this file to also associate other domains with the master domain by writing to it (carefully!) with your app.
3) Setup and configure the Apache module mod_vhost_alias – although Plesk is likely to cause you a headache with this approach.
Here is Zend Framework module class for Plesk API witch can help you:
And here you have plesk API Reference:
http://download1.parallels.com/Plesk/PP10/10.1.1/Doc/en-US/online/plesk-api-rpc/index.htm