create subdomain with php

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
hongco
Forum Contributor
Posts: 186
Joined: Sun Feb 20, 2005 2:49 pm

create subdomain with php

Post by hongco »

hi,

Do you know if we can create subdomain with php.
A user will register for a subdomain, and this script will create it on the fly.
I understand we need to have access to root.

Thanks!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

That's a DNS change. It should be possible, though.
hongco
Forum Contributor
Posts: 186
Joined: Sun Feb 20, 2005 2:49 pm

Post by hongco »

Thanks,

I will do some research on this part.
Termina
Forum Newbie
Posts: 18
Joined: Sat Apr 10, 2004 11:17 pm

Post by Termina »

Hello

If you use zoneedit.com (which I do! and suggest you do), you can create subdomains with a simple command:

lynx -source -auth=username:password 'http://dynamic.zoneedit.com/auth/dynami ... domain.com'

or

wget -O - --http-user=username --http-passwd=password 'http://dynamic.zoneedit.com/auth/dynami ... domain.com'

Replace www with the subdomain. This must be done on a computer with the IP you want.
User avatar
Fusioned
Forum Commoner
Posts: 32
Joined: Tue Jan 18, 2005 10:43 pm
Location: Philadelphia, PA

Post by Fusioned »

Correct me if I'm wrong, but isn't a subdomain just another folder in a directory? IE:

php.mywebsite.com is the same as http://www.mywebsite.com/php/

Therefore, you could just create a script that would create a new directory and set the proper permissions. I already did it but PHP safe mode is on so I cant take advantage of it.. :cry:
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

to a point, yes they are just a subdirectory. However, not all subdirectories are automatically subdomains. It still requires a DNS change to take effect.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

the easiest (and recommended way to go) is to write a (wrapper)script that uses nsupdate if you have bind as nameserver...
Post Reply