943,892 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 2797
  • PHP RSS
Oct 21st, 2008
0

how create subdomain using php

Expand Post »
how can i create a subdomain using php?

Thanks in advance
Similar Threads
Reputation Points: 10
Solved Threads: 7
Junior Poster in Training
danishbacker is offline Offline
97 posts
since Apr 2008
Oct 21st, 2008
0

Re: how create subdomain using php

You can't, Sub-Domains are managed by the web server. Speak to your host for information on how to set one up.
Reputation Points: 96
Solved Threads: 124
Master Poster
Will Gresham is offline Offline
728 posts
since May 2008
Oct 22nd, 2008
0

Re: how create subdomain using php

I'm a beginner,
I mean is there any way to create a subdomains like some free hosting sites do?
Is there any other way to make subdomain creation upon user request.
I used create sub domains from my control panel.
i don't know what actually CGI is, is it possible with that? or ruby or perl?

Forgive me if my question is a blunder .
Thanks a lot for your reply.
Reputation Points: 10
Solved Threads: 7
Junior Poster in Training
danishbacker is offline Offline
97 posts
since Apr 2008
Oct 22nd, 2008
0

Re: how create subdomain using php

unix-like or windows server?
Moderator
Featured Poster
Reputation Points: 1784
Solved Threads: 574
Moderator
jbennet is offline Offline
16,519 posts
since Apr 2005
Oct 23rd, 2008
0

Re: how create subdomain using php

unix-like server
Reputation Points: 10
Solved Threads: 7
Junior Poster in Training
danishbacker is offline Offline
97 posts
since Apr 2008
Oct 23rd, 2008
0

Re: how create subdomain using php

The only way that I know how to make subdomains (other than using the servers control panel) is by editing the apache httpd.conf file which you may be able to program a php script to do if you have full permissions of the server. Guides can be found at http://apptools.com/phptools/virtualhost.php So if you are the server administrator then just program a php script to edit the httpd.conf file as instructed in the above and the apache codes would look something like:
PHP Syntax (Toggle Plain Text)
  1. NameVirtualHost realdomain.com
  2.  
  3. <VirtualHost realdomain.com>
  4. DocumentRoot "C:\My Sites\Site1"
  5. ServerName subdomain.realdomain.com
  6. </VirtualHost>
  7.  
  8. <VirtualHost realdomain.com>
  9. DocumentRoot "C:\My Sites\Site2"
  10. ServerName realdomain.com
  11. </VirtualHost>
And obviously replace in the code above the term "realdomain.com" with your registered domain and replace the word "subdomain" with the name of your subdomain. But that is a sketch of what I think the apachie code needs to look like but would wait for further comments on the above code before copying it.

Also in the link I provided, you will need to ignore the information below the title: "Resolving the DNS issue" as you have a domain in the first place instead of localhost.

So basically, the only thing that php can really do is edit the apache httpd.conf file.
Sponsor
Featured Poster
Reputation Points: 410
Solved Threads: 258
Occupation: Genius
cwarn23 is offline Offline
3,004 posts
since Sep 2007
Oct 23rd, 2008
0

Re: how create subdomain using php

Thanks a lot,
can you please tell me where to place the httpd.conf
or
i'll have to place http.conf with contents as above in my root folder?

i'm attaching directory structure of my domain.

Thanks.
Attached Thumbnails
Click image for larger version

Name:	dir.gif
Views:	58
Size:	14.9 KB
ID:	7891  
Last edited by danishbacker; Oct 23rd, 2008 at 8:14 am.
Reputation Points: 10
Solved Threads: 7
Junior Poster in Training
danishbacker is offline Offline
97 posts
since Apr 2008
Oct 23rd, 2008
0

Re: how create subdomain using php

You need server root access in order to manually modify the httpd.conf file. Very few hosting companies will give a site owner root access. Using cPanel to add a subdomain does the same thing.

Unless you are very familiar with Linux/Unix servers, you should not be doing anything at the server root level.

I think what you really want to do is to set up a widcard DNS that allows you to artificially create sub domains. I have used this article to do that. The article also shows you how to manually edit the httpd.conf file.

Wildcard DNS

Another option would be to create subdirectories for your users with PHP. That is easier to do.
Reputation Points: 15
Solved Threads: 5
Junior Poster in Training
TopDogger is offline Offline
87 posts
since Aug 2005
Oct 23rd, 2008
0

Re: how create subdomain using php

Thanks for your reply, I don't have the login details for my DNS ("Edit DNS Zone") configuration
I only have username and password for my cpanel. Then it seems to be a difficlut job for me. Also i didn't get you completely (wildcard DNS).

also I think I have to switch to the second methid you've suggested.
Reputation Points: 10
Solved Threads: 7
Junior Poster in Training
danishbacker is offline Offline
97 posts
since Apr 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Include problem
Next Thread in PHP Forum Timeline: Validate Selected Checkboxes





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC