Page 1 of 1

creating subdomains

Posted: Wed Jul 11, 2007 11:12 am
by itsmani1
Today I was browsing ebay.com and I come to know that for every main category they created a sub domain, like there is a category watches and the URL for watches will be like watches.ebay.com etc.
Now I wanted to know what whey is to so that I can create a sub domain using PHP script.

Posted: Wed Jul 11, 2007 12:08 pm
by arturm
using just PHP with apache you can't
You need root privileges on a server to create a subdomain.
So you can use some PHP-CGI script or Perl and call it with proper parameters from your web application
There are dozens of examples on the internet.

other option is to give permissions to "nobody" (apache user) to DNS config files but it is a very high security risk.

Posted: Wed Jul 11, 2007 12:59 pm
by itsmani1
well thanks for the reply man.

but can you please tell if php has any function which can do this type of thing or i need to use something else?


thanks.

Posted: Wed Jul 11, 2007 1:07 pm
by arturm
if you have root permissions (from perl or php-cgi) you just edit a dns file:
look here for example (at the bottom)
so pretty much you just have to use fopen() fwrite() etc

after edit you have to restart dns server

Posted: Wed Jul 11, 2007 1:09 pm
by arturm
restart dns daemon not server :)

Posted: Wed Jul 11, 2007 1:13 pm
by itsmani1
thanks you what if have root permissions then?

basically the thing i want to copy ebay model and that's why i am looking for making these sub domains.

if any one has any good suggestion also suggest me on it and you know they [ebay] people has a huge database can mysql bear this thing or not?

thanks