Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I want to set up a virtual hosting server on Linux/Apache2.2 that allows multiple users to set up multiple website domains as would be appropriate for commercial shared hosting.

I have seen examples (from my then perspective as a shared hosting customer) that allow users to store their web files in their user home directory with directories to correspond to the virtual host domain, e.g.:

/home/user1/www/example1.com
/home/user2/www/example2.com

instead of using /var/www

Questions:

  1. How would you configure this in your Apache configuration files? (Don't worry about DNS)
  2. Is this the best way to manage multiple virtual hosts? Are there others?
  3. What safety or security issues do you think I should be aware of in doing this?

Many thanks, folks.

Edit: If you want to only answer question 1, please feel free, as that is the most urgent to me at this moment and I would consider that an answer to the question. I have done it for myself since posting, but I am not confident that it's the best solution and I would like to know how an experienced sysadmin would do it. Thanks.

share|improve this question

3 Answers 3

up vote 0 down vote accepted

I'm not from hosting world, but I believe it's being done in following way (talking about commercial shared hosting):

in main apache's conf (usually httpd.conf) there are some basic settings and like like Include /etc/httpd/vhosts/*.conf.

Each file in /etc/httpd/vhosts/ represents a signle virtual host, configuration for it is being generated by some configuration panel (like ISPManager or cPanel, or something like this) or custom hoster's software using pre-defined templates.

So, management of vhosts is easy, there are more problems with resource tracking, security and so on.

share|improve this answer

I've got a similar situation happening with my VPS I was planning to specify extra locations for apache to get site configs from (i have trusted users) e.g.
/home/user1/sites-enabled
/home/user2/sites-enabled
then each user gets rights to reload apache (yay for sudo)

In the apache2.conf i add
Include /home/user1/sites-enabled/
Include /home/user2/sites-enabled/

Then your users can specify the sites they want to configure and configure the folders however they wish.

share|improve this answer
    
Interesting approach. For myself, I was thinking more in terms of how a commercial hosting provider would do it (though on a small scale) so the users would not be trusted and have no access to sudo. Thanks. –  authentictech Jan 24 '11 at 0:29
    
This is definitively not option if users not trusted, they can do some nasty things like global redirects and so on. –  rvs Jun 23 '11 at 16:30

For a user by user virtual hosting you can very easily use mod_userdir which is built into Apache on just about all major Linux distros. Here is a link: http://httpd.apache.org/docs/2.2/mod/mod_userdir.html

Just enable it and define the name of the folder users will use to host the files.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.