0

I am using php/mysql on linux servers. I want to create a user sub domain for each user upon sign up. For instance, john doe --> johndoe.example.com

The issue is, we are going to allow customizations such as adding custom features for clients wanting customizations. So, is it better we automate the process or manually create sub domains for clients requiring customizations and let other users just use basic login?

And how can i automate the process if need be?

AAA
  • 21
  • 2
  • Is the code on the subdomain going to be the same as the code on the main domain, just with personalisation for the user? – Alex C Sep 07 '10 at 01:10
  • The code will be different in the sense that any feature they want added we will. But mostly they will have the same features as the main domain. For example: All user have access to user posts, but one client says add an option to email and and post comments. – AAA Sep 07 '10 at 01:14
  • Related: [How to let PHP to create subdomain automatically for each user?](http://stackoverflow.com/questions/183928/how-to-let-php-to-create-subdomain-automatically-for-each-user/183971#183971) – kenorb Mar 17 '15 at 12:06

1 Answers1

2

Instead of creating subdomains, have a wildcard subdomain which is mapped into one folder and with PHP figure out which user's data you want to show.

If you are using a cPanel hosting, creating a wildcard subdomain should be pretty easy and wont require any manual adjustment to the httpd.conf file. Otherwise whenever you will add individual subdomains Apache will be restarted in the background, which is not at all good.

I rephrased my answer for clearer understanding.

Sabeen Malik
  • 10,816
  • 4
  • 33
  • 50
  • Is that a good way to go if i want to allow individual user accounts to ask for customizations? Like, I want to be able to go into their account like a developer of a website would to go in and make changes. – AAA Sep 07 '10 at 01:28
  • If the subdomain sites are actual sites with their own individual content, even in that case this can help you. Will you be coping over data and creating new folders on the fly too when a new user signs up? You can probably just point the wildcard subdomain to /home/someone/public_html/subdomains and inside that folder create folders for new users and with the help of mod rewrite direct the requests to the appropriate folder. So user1 will have a folder /home/someone/public_html/subdomains/user1 – Sabeen Malik Sep 07 '10 at 01:33
  • 1
    -1: Apache supports wildcard subdomains via `ServerAlias` without the need to restart Apache. cPanel uses that feature (cPanel is powered by Apache). – Andrew Moore Sep 07 '10 at 01:43
  • @Andrew . i m not sure why the down vote, i just said that if you use a wildcard subdomain you wont need to restart Apache at all. Secondly adding anything to the server config programmatically would be tough, so just create one wildcard subdomain and do the rest from one fixed directory with php or htaccess – Sabeen Malik Sep 07 '10 at 01:48
  • @sabeen I would say 80-90% of the features will be shared. 10% will be client customizations. – AAA Sep 07 '10 at 02:02
  • So i guess just keep a copy of the master code somewhere and whenever you create a new user, just create a new user directory and copy over all the files into the new directory, that should get you going. – Sabeen Malik Sep 07 '10 at 02:08
  • Pls see the homepage of tumblr.com and see their url field in the sign up form, something like that is what i am looking for: http://www.tumblr.com/ – AAA Sep 07 '10 at 02:11
  • I know what you are looking for and that is exactly what i am proposing a solution for :) – Sabeen Malik Sep 07 '10 at 02:15
  • @Sabeen Malik: Your original answer stated wrongfully that you could not have a wildcard domain with Apache. This is why I had given a negative vote. You CAN configure Apache to redirect all requests from a set of subdomains (wildcarded or not) via `ServerAlias`. – Andrew Moore Sep 07 '10 at 02:23
  • @Andrew , i realized after reading my answer for a cpl of times that my use of the "otherwise" could have created a completely different meaning than what i intended , just getting really late here. Thanks for pointing out the confusion and also commenting after a down vote, instead of just a down vote :) – Sabeen Malik Sep 07 '10 at 02:25