Results 1 to 5 of 5
  1. #1

    How do i get my PHP script to create subdomains

    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.

  2. #2
    Join Date
    Apr 2009
    Pittsburgh, Pennsylvania
    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.

  3. #3
    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

    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.

    hope thats clear enough.

  4. #4
    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 * 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.

  5. #5
    Join Date
    Apr 2009
    Pittsburgh, Pennsylvania
    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.

Similar Threads

  1. Free custom made create short URLs and subdomains script. Limited time
    By leo1977 in forum Software & Scripts Offers
    Replies: 1
    Last Post: 04-24-2007, 11:58 PM
  2. create subdomains as a new account ?
    By activa in forum VPS Hosting
    Replies: 6
    Last Post: 12-09-2006, 04:45 AM
  3. how to create dynamic subdomains using php
    By feelexit in forum Programming Discussion
    Replies: 8
    Last Post: 10-10-2006, 12:06 PM
  4. How to create subdomains as domains?
    By roberth31 in forum Domain Names
    Replies: 5
    Last Post: 02-07-2006, 08:29 PM
  5. How to create subdomains?
    By superprogram in forum Programming Discussion
    Replies: 4
    Last Post: 10-20-2004, 09:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts