I am setting up a hosted web service; it doesn't matter for the sake of this question exactly what the service is. A feature which I hope to add shortly will allow users to point their own domain to it, so that they use their domain to access their branded "website" on my service.
So by default they get a subdomain like
example.mydomain.com, but they should have the option of pointing a domain such as
example.com to my servers so that they can use that name instead.
Ideally, they should be able to create a CNAME record pointing to my domain, and notify my system of their domain, and it should "just work".
However, at the moment I have to manually add each domain as a "parked domain" in my CPanel before the domain will resolve to my site correctly.
At the moment I am using shared hosting. Once I have a few customers I will be moving to a dedicated server. My service is built using PHP (based on WordPress, in fact, though with heavy modifications and customisations).
So I have two questions :
Is there a way that can I make my system "automatically" handle new domains pointed to it, without having to manually add each one via CPanel? (For example, is there a way for PHP to interact with CPanel to do this automatically?)
Presumably once I have mved to a dedicated server this will be easier since I will have control over the whole system. What will then be the best way to achieve the same result?