Help - Search - Members - Calendar
Full Version: Virtual Host in user's public_html [solved]
MandrivaUsers.org > Advanced Topics > Networking
tyme
I want to be able to point virtual hosts to directories inside a users public_html folder in their home directory while not having the site available via http://domain/~username/blah - is this simply a matter of removing the UserDir param in http's config? For some reason I have this feeling that doing that would make apache incapable of recognizing/using the public_html folder to serve up the sites, or am I wrong about that?

Basically I want users to be able to go to:
CODE
http://userssite.tld/

and get the site, but not at:
CODE
http://servers.tld/~username/usersite.tld/


This is a server with multiple domains, and various users. I want them all to be able to administrate their own stuff from within their user directory, so far as I allow them. I'm currently doing a whole bunch of moving and setting up of various services (my first time setting up a server from scratch for LAMP + Mail + whatever else I want to mess with), so I may have more questions forthcoming.
ianw1974
If you don't have the userdir parameter in Apache, then it won't allow you do to the http://server/~username bit. However, what I would then do, is set an apache config file in /etc/apache2/conf.d/vhosts or wherever they are located, and then set the url you want to access, and point it to the DocumentRoot of the home directory of the user /home/user/public_html. For example, you could set:

ServerName username.domain.com

and then ensure that you set the Document path's correctly, and you should be up and running. I'll check my apache config and update what I did for one of my domains as I have multiple domains on one single ip all in different vhosts.
ianw1974
This was from my vhost file:

CODE
<IfDefine DEFAULT_VHOST>

<VirtualHost *:80>
        ServerName      www.lsltd.org
        ServerAlias     lsltd.org
        DocumentRoot "/var/www/localhost/htdocs/joomla"
        <Directory "/var/www/localhost/htdocs/joomla">
                Options Indexes FollowSymLinks
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>

        Include /etc/apache2/vhosts.d/99_joomla_default_vhost.include

        <IfModule mpm_peruser_module>
                ServerEnvironment apache apache
        </IfModule>
</VirtualHost>
</IfDefine>


and from the default.include file (you can merge this into the one file if you like, it was just something I left as is because of how apache was working on Gentoo):

CODE
ServerAdmin root@localhost

<IfModule alias_module>
        ScriptAlias /cgi-bin/ "/var/www/localhost/cgi-bin/"
</IfModule>

<Directory "/var/www/localhost/cgi-bin">
        AllowOverride None
        Options None
        Order allow,deny
        Allow from all
</Directory>


this is on a gentoo system, therefore the vhost conf file was in /etc/apache2/vhosts.d. This was to get my domain - www.lsltd.org working on a system that had multiple vhosts and only one single static IP address assigned. Hope it helps a bit.

Effectively, all you need to be doing is creating a vhost for each user, and then pointing each vhost to their home directory. I don't know if there will be a permissions problem, but it's worth testing anyway, and this is how I would do it if I didn't want the userdir parameter enabled and used.
tyme
i got it working. i just turned off userdirs and pointed the virtual hosts to the right directory - it was easier than i expected.
ianw1974
Ah cool 2thumbsup.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.