1

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

puk
  • 285
  • 1
  • 6
  • 18

2 Answers2

3

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.

Kvisle
  • 4,193
  • 24
  • 25
  • I don't think this will suit me. – puk Nov 07 '11 at 00: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 07:37
1

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.

user9517
  • 115,471
  • 20
  • 215
  • 297
erm410
  • 183
  • 3
  • Perhaps you should take a look at mod_userdir. – user9517 Nov 06 '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](http://www.serverwatch.com/tutorials/article.php/10825_1127571_2/Apache-Guide-Setting-Up-Virtual-Hosts.htm) or the `/etc/apache2/sites-available/vhosts.conf` file [2](http://www.simplehelp.net/2008/12/16/how-to-setup-virtual-hosts-in-apache/) – puk Nov 07 '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 07 '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 07 '11 at 22:15
  • @puk Also make sure that `/etc/apache2/ports.conf` includes the directive `NameVirtualHost *:80`. – erm410 Nov 07 '11 at 22:28
  • Yes it has the directive `NameVirtualHost *:80`. Also my `Virtual Host` tag is in the file `/etc/apache2/sites-available/default` – puk Nov 07 '11 at 22:53