is there a way to have a LAMP server and create subdomain programatically via PHP?
I don’t want to install Plesk or cPanel, I know they have API’s which lets me create subdomains. But is there a way to go around them and have a bare server with just LAMP services installed.
You can look at the mass virtual hosting module provided by Apache:
With your PHP, when you want to create a new domain, simply create a new directory … and implement parts of this configuration (consult the link above) on how to configure your Apache. This will allow a seperate vhost per host … as opposed to the alternate answer which still requires more configuration work per unique hostname…