hi, im currently running on a CentOS server with apache and currently using ISPConfig (i cannot afford paying for one of the other control panels). How would i go about setting up my php script to create a subdomain / bind DNS entry based on the information the user has provided.
please rephrase. Do you want to make a php script create a new subdomain name for you, or are you going to be offering free sub domains on your domain? If you're offering free subdomains, you might want to look into wild card sub domains and writing another php script that does a "catch all" for it.
If thats not what you're looking for, you will need to edit httpd.conf and append sub domains in it.. create a new folder and make the sub domain read from that folder, etc.
yeah, im offering free subdomains, but i dont want to use wildcard because i think its more insecure (for one, your ip can be accessed from anyhostname.domain.com)
what im wondering is if its possible for php to modify httpd.conf or add additional vhosts entries based on what the user inputs as well as create a home folder and DNS entry for that user and his subdomain.
What you want is to have a database handle all of the subdomain entries.
Then create a file, say /etc/httpd/conf/vsubs.conf
Have PHP create the new vhost subdomain files inside /etc/httpd/conf/vsubs/ (create a new directory)
Then each time a new subdomain is added (or rather through a cron job every 10 minutes) write the /etc/httpd/conf/vsubs.conf file again with all of the subs again. Restart Apache, etc.
Now you would just need to do the same but with BIND, or even just set *.domain.com to the IP and then all subdomains would go to the location they should go to and all other subdomains could go to the 'Add Subdomain' page for example.
If you don't need to have the subdomains up immediately or if you have a LOT of subdomains being added, then you can extend it to 30 minutes.
I dont agree with the whole idea that wildcarded sub domains isn't the best way to do something like this.
I go to a sub domain that isn't in your system, it could display a page for registering that sub domain.. and obviously, theres some you dont even want to be used.. then you would set it up so they can't create certain ones.. not too hard.
If you were creating vhosts over and over, and restarting apache all of the time, the overhead, and the down time of the web server would be noticeable if you had quite a few entries, and a lot of users using these sub domains.