anhtran
anhtran

Reputation: 2044

How to configure Apache httpd to set multi-site for multi-user?

I have a system CentOS with Django and MySQL.

/home/user1/
    -/vhost/*.conf
    -/webapps/
        abc.com
        xyz.com

/home/user2/
    -/vhost/*.conf
    -/webapps/
        123.com
        789.com

Thanks for help!

UPDATE 1: In httpd.conf:

User user1
Group apache

And httpd cannot access /home/user2/webapps.

Upvotes: 0

Views: 3062

Answers (1)

Konerak
Konerak

Reputation: 39773

You'll want to read up on Apache Vhost Configuration.

Tell us what you tried, what is working, what is not working, or what you don't understand.

Most common configuration

If your system has 1 IP address for all sites, you're going to want something like this:

#This is your 'default' host, 
#people accessing the site via IP-address will see this site.
<VirtualHost *:80>
        ServerName abc.com
        ServerAlias xyz.com
        DocumentRoot /home/user1/webapps/
</VirtualHost>

#This is the 123 and 789 vhost
<VirtualHost *:80>
        ServerName 123.com
        ServerAlias 789.com
        DocumentRoot /home/user2/webapps/
</VirtualHost>

You can add all directives as explained by the <VirtualHost> Directive

EDIT: Updated question

  1. There is a module called perchild for apache that allows to run different threads under different users, configurable by vhost. The module is not considered functional, and not under current development. Unless you know what you're doing or are willing to take the risk, you probably shouldn't use it.
  2. Another solution might be mpm-itk, which appears to be more reliable. Read this serverfault question for more information, or visit their homepage.
  3. If you don't want to use either of both modules, you could always create a new user and group, run both vhosts under that user, and make both homedirs readable to the user by setting their group to the new group.

Upvotes: 1

Related Questions