apache/dns question?
Ian Stokes-Rees
ijstokes-/2FeUQLD3jedFdvTe/nMLpVzexx5G7lz at public.gmane.org
Tue May 24 09:13:19 EDT 2011
On 5/24/11 7:51 AM, Myrle Francis wrote:
> ello all and thank you in advance. (also sorry GAF, I sent you this question
> directly on accident :) )
>
>
> I have learned to set up apache to that each user can have their own webpage
> (ie http://mafmanet.us/~user1,http://mafmanet.us/~user2 etc)
> what I would like to configure instead is to have these webpages accessable
> via http://user1.mafmanet.us, http://user2).mafmanet.us)
Don't try doing this. Apache has a nice and easy way to translate the
http://example.com/~user into a directory on disk from which you serve
static content, or even CGI/PHP. It is called "UserDir" and used like
this in your httpd.conf:
UserDir public_html
will automatically translate the above URL into a file request in the
directory:
/path/to/home/user/public_html
One config option, easy to manage. "public_html" is the convention, but
you can call it whatever you like. Make sure your users know, or simply
create the directories for them in advance.
> Is there some reason why I would/should choose one convention over the
> other?
Basically, your webserver handles everything in the "path" portion of
the URL. The protocol (http or https), the domain name, and the port
are "dictated" by the client, and provide the route to your webserver.
If any of them are wrong then the client browser will never contact your
web server. You can point multiple domain names at the same webserver
instance, but you need to use something outside of the webserver to
configure that.
If you go the other route, you will need two do two much more
complicated things:
1. Manage DNS entries -- DNS names are handled by your DNS servers, not
by any web server
2. Create <VirtualHost> entries in your httpd.conf
> And can you please point me to some docs that would explain what I would
> like to achieve and what it is formally called? (ie http redirection?)
The one is called "UserDir" the other is called "VirtualHost", in terms
of apache configuration. I know of no "de facto" name for the two
techniques, but if I were having to refer to them, I'd call one
DNS-based, and the other tilde-mapping -- since it special handles the ~
"tilde" character and does the equivalent of command line resolution of
"pwd ~someuser" then appending the "UserDir" directory name.
A third, less conventional, option would be for you to use symlinks or
"Alias" statements to allow resolution of
http://example.com/someuser
to /path/to/home/someuser/public_html
This is just making work for yourself.
In summary, you really really should just use UserDir and live with
~username in the path part of the URL. Anything else is inviting a
whole world of extra work and problems for you.
Ian
More information about the Discuss
mailing list