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

Using suPHP my goal is to have my website point to my /home folder and every user within the home folder have their own index.html page. I don't currently have an index.html page in my /home folder, but that would be the logical place to put a login page. Here is the structure I am after

home
├── index.html
├── user1
│   └── index.html
├── user2
│   └── index.html
├── user3
│   └── index.html
├── user4
│   └── index.html
├── user5
│   └── index.html
└── user6
    └── index.html

When I go to 192.168.1.8, I want it to load up /home/index.html. When I go to 192.168.1.8/user1 I want it to load up /home/user1/index.html.

Currently Apache is telling me I don't have rights to /home or any of the nested folders. I am guessing it is because /home belongs to root? Any suggestions on how to reshape this

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

First the following should be a (virtual)host in apache:

<VirtualHost 192.168.1.8:80>

    DocumentRoot /home

</VirtualHost>

To serve a page Apache needs read rights to the file it is trying to access. The simplest way to achieve what you are trying is would be run as root:

# find /home -type d -exec chmod 755 {} \;

# find /home -type f -exec chmod 744 {} \;

These will give global read rights to every file in every home directory. Normally I would warn against this, since individual users may not want every file read by users, but since these files will be readable over the web, it makes little difference.

If you want to give the option of users having both public and private files then consider creating a parallel directory /home/www. Within this create a directory for each user with 0755/0655 permissions and chown it to them. Then they can put just the files they want everyone to see in /homw/www/user, while keeping private files in /home/user.

share|improve this answer
    
Perhaps you should take a look at mod_userdir. –  Iain Nov 6 '11 at 15:04
    
Could you please be more specific as to where the Virtual Host tag should go. In the /etc/apache2/httpd.conf file 1 or the /etc/apache2/sites-available/vhosts.conf file 2 –  puk Nov 7 '11 at 18:25
    
Also why do I need to use a virtual host if this is the only site I am hosting –  puk Nov 7 '11 at 18:26
    
@puk You do not need a virtual host if it is your only site, but I always use virtual hosts just to keep myself organized. As for where to put it, it depends on what you want to do. Use httpd.conf in your case since sites-available is useful if you want to be able to switch hosts on and off without deleting them. Since you only have one host, this is not needed –  erm410 Nov 7 '11 at 22:15
    
@puk Also make sure that /etc/apache2/ports.conf includes the directive NameVirtualHost *:80. –  erm410 Nov 7 '11 at 22:28
show 1 more comment

I'm not sure if this will still fit with your plan, but;

The easiest way to achieve this, is probably with the userdir-directive. It also makes it possible to put each users webroot in a subdirectory of their home directory - so they don't have to expose all their files on the webserver.

Check out the documentation for userdir here: http://httpd.apache.org/docs/2.0/mod/mod_userdir.html#userdir

I would put the files that you were planning to put in /home somewhere else.

share|improve this answer
    
I don't think this will suit me. –  puk Nov 7 '11 at 0:39
1  
puk -- IMO I think you're proposed file/folder structure is particularly flawed. Whereas configuring things as @Kvisle suggests is (afaik) the conventional way to implement a 'per user' web-folder set-up! That is, after all, kind of what mod_userdir is designed for. However you might also want to look in to mod_vhost_alias -- together these two mods allow for the kind of set-ups large internet web-hosts use, with hundreds or thousands of users! –  Chris Aug 23 '12 at 7:37
add comment

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.