creating subdomains

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

creating subdomains

Post 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.
User avatar
arturm
Forum Commoner
Posts: 86
Joined: Fri Apr 13, 2007 8:29 am
Location: NY
Contact:

Post 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.
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post 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.
User avatar
arturm
Forum Commoner
Posts: 86
Joined: Fri Apr 13, 2007 8:29 am
Location: NY
Contact:

Post 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
User avatar
arturm
Forum Commoner
Posts: 86
Joined: Fri Apr 13, 2007 8:29 am
Location: NY
Contact:

Post by arturm »

restart dns daemon not server :)
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Post 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
Post Reply