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

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

When I go to, I want it to load up /home/index.html. When I go to 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


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


    DocumentRoot /home


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.

| improve this answer | |
  • Perhaps you should take a look at mod_userdir. – user9517 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

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.

| 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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