You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Ivan Zanev <iv...@gmail.com> on 2008/12/22 08:04:48 UTC

[users@httpd] Subdomains Hosting

 Well, Hi!

I'm developing a Free Web Hosting Site. And I'm stuck, so pleease help, if
you can and if you want! :)

Every user will have the feature to add one or more subdomains to his
account. For example, if the site is called: thehost.com, a user might want
to create two subdomains: sub1 and sub2. So, he should be able to use the
File Manager to manage his created subdomains and see the results at
sub1.thehost.com and sub2.thehost.com. Now, in my File System I would like
to structure the directories in the following way:


users/Superman/sub1/
users/Superman/sub2/

Where Superman is our username (He added the two subdomains noted above).

The problem: How to do this? I've read much about the htaccess files and I
found several solutions:

Solution 1: To Write a perl program, which connects to the database, and
selects path for a given virtualhost. The RewriteMap of the htaccess will
execute the perl program and for the subdomain sub1, it will SELECT vpath
FROM vhosts WHERE vname = "sub1". It will return: users/Superman/sub1/. The
htaccess will substitute and everything works fine.
Now, I don't like this, because if everytime we access sub1.thehost.com, we
make a select query, the mysql server (yes, i'm using mysql) will die in
pain for sure.

Solution 2: Don't give the users feature to add subdomains, but when a user
is created, we created a subdomain called superman.thehost.com. Now, this
will work fine, because we only need the 'superman' subdomain name to find
out where is our 'superman' subdomain path. This solution I would not like
to use.

Please, If you know how to deal with this problem, tell me. I've pointed out
two solutions, but if you know a third one....better one, please let me now.

Thank you in advance...

Re: [users@httpd] Subdomains Hosting

Posted by Ivan Zanev <iv...@gmail.com>.
So, you are suggesting a directory with symbolic links. The symbolic link
names are the subdomain names and they point to the user directories. Well,
thank you, i didn't think of that and I'll test it.

On Mon, Dec 22, 2008 at 3:46 PM, Eric Covener <co...@gmail.com> wrote:

> On Mon, Dec 22, 2008 at 2:04 AM, Ivan Zanev <iv...@gmail.com>
> wrote:
> > Well, Hi!
> >
> > I'm developing a Free Web Hosting Site. And I'm stuck, so pleease help,
> if
> > you can and if you want! :)
> >
> > Every user will have the feature to add one or more subdomains to his
> > account. For example, if the site is called: thehost.com, a user might
> want
> > to create two subdomains: sub1 and sub2. So, he should be able to use the
> > File Manager to manage his created subdomains and see the results at
> > sub1.thehost.com and sub2.thehost.com. Now, in my File System I would
> like
> > to structure the directories in the following way:
> >
> > users/Superman/sub1/
> > users/Superman/sub2/
> >
> > Where Superman is our username (He added the two subdomains noted above).
> >
> > The problem: How to do this? I've read much about the htaccess files and
> I
> > found several solutions:
> >
> > Solution 1: To Write a perl program, which connects to the database, and
> > selects path for a given virtualhost. The RewriteMap of the htaccess will
> > execute the perl program and for the subdomain sub1, it will SELECT vpath
> > FROM vhosts WHERE vname = "sub1". It will return: users/Superman/sub1/.
> The
> > htaccess will substitute and everything works fine.
> > Now, I don't like this, because if everytime we access sub1.thehost.com,
> we
> > make a select query, the mysql server (yes, i'm using mysql) will die in
> > pain for sure.
>
> You can do this with a flat file or DBM map that just maps superman to
> "thehost", or use a symlink to get from superman to "thehost". It
> should be a lot simpler to avoid the prg: map.
>
> I don't see why you should be sweating finding yourself all the way
> down to sub1 in one step, when superman->thehost seems to be the real
> problem.
>
> --
> Eric Covener
> covener@gmail.com
>
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP Server Project.
> See <URL:http://httpd.apache.org/userslist.html> for more info.
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Re: [users@httpd] Subdomains Hosting

Posted by Eric Covener <co...@gmail.com>.
On Mon, Dec 22, 2008 at 2:04 AM, Ivan Zanev <iv...@gmail.com> wrote:
> Well, Hi!
>
> I'm developing a Free Web Hosting Site. And I'm stuck, so pleease help, if
> you can and if you want! :)
>
> Every user will have the feature to add one or more subdomains to his
> account. For example, if the site is called: thehost.com, a user might want
> to create two subdomains: sub1 and sub2. So, he should be able to use the
> File Manager to manage his created subdomains and see the results at
> sub1.thehost.com and sub2.thehost.com. Now, in my File System I would like
> to structure the directories in the following way:
>
> users/Superman/sub1/
> users/Superman/sub2/
>
> Where Superman is our username (He added the two subdomains noted above).
>
> The problem: How to do this? I've read much about the htaccess files and I
> found several solutions:
>
> Solution 1: To Write a perl program, which connects to the database, and
> selects path for a given virtualhost. The RewriteMap of the htaccess will
> execute the perl program and for the subdomain sub1, it will SELECT vpath
> FROM vhosts WHERE vname = "sub1". It will return: users/Superman/sub1/. The
> htaccess will substitute and everything works fine.
> Now, I don't like this, because if everytime we access sub1.thehost.com, we
> make a select query, the mysql server (yes, i'm using mysql) will die in
> pain for sure.

You can do this with a flat file or DBM map that just maps superman to
"thehost", or use a symlink to get from superman to "thehost". It
should be a lot simpler to avoid the prg: map.

I don't see why you should be sweating finding yourself all the way
down to sub1 in one step, when superman->thehost seems to be the real
problem.

-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Subdomains Hosting

Posted by Bob Ionescu <bo...@googlemail.com>.
2008/12/22 Ivan Zanev <iv...@gmail.com>:
> Now, in my File System I would like
> to structure the directories in the following way:
>
> users/Superman/sub1/
> users/Superman/sub2/
>
> Where Superman is our username (He added the two subdomains noted above).
>
> The problem: How to do this? I've read much about the htaccess files and I
> found several solutions:

Don't use .htaccess files, if you have access to the server config.

> Solution 1: To Write a perl program, which connects to the database, and
> selects path for a given virtualhost. The RewriteMap of the htaccess will
> execute the perl program and for the subdomain sub1, it will SELECT vpath
> FROM vhosts WHERE vname = "sub1". It will return: users/Superman/sub1/. The
> htaccess will substitute and everything works fine.

Use the map type dbd or fastdbd to perform a SQL query, the later one
will cache the results but you've to restart httpd in order to perform
a db look-up against the latest db.

> Please, If you know how to deal with this problem, tell me. I've pointed out
> two solutions, but if you know a third one....better one, please let me now.

You can extend solution 2 by using sub.superman.example.com. Another
way to do that on-the-fly without db look-ups is changing the path to
users/sub1/ .

Bob

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org