Jump to content

Virtual Host in user's public_html [solved]


tyme
 Share

Recommended Posts

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:

http://userssite.tld/

and get the site, but not at:

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.

Edited by tyme
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This was from my vhost file:

 

<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):

 

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...