0

I'd like to have per-user web directories on my Linux Mint workstation in the same general way I have had on OS X. In order to do this, I created a public_html directory in ~/. and chmod'd it to 755 and installed the userdir mod:

sudo a2enmod userdir
sudo /etc/init.d/apache2 restart

From what I understand of how usermod works, there should be no need to create vhost configs by hand, but even so I get this when I try to access http://127.0.0.1/~myusername:

Forbidden

You don't have permission to access /~dxh on this server.

Apache/2.2.22 (Ubuntu) Server at localhost Port 80

Am I missing some mysterious extra step?

huertanix
  • 197
  • 2
  • 11
  • 2
    The toplevel and public_html directories must be 711 at minimum for this to work on the username `myusername`. You are not clear that this has been done. It must be done for EACH username. Also, you have not indicated if you have changed your httpd.conf to activate the User directory modules and capabilities. – mdpc Jan 21 '13 at 06:13

2 Answers2

2

I'd check a few things.

Directory permissions: If your home directory is /home/dxh/ and you just created /home/dxh/public_html/ to hold your web content, make sure the parent level directories are allowing access:

ls -ld /home
ls -ld /home/dxh
ls -ld /home/dxh/public_html

The permissions need to be at least '711' for each of these directories. That means the output of the 'ls' command above should look like this:

drwx--x--x 33 dxm dxm 4096 2013-01-18 16:51 /home/dxm

or

drwxr-xr-x 33 dxm dxm 4096 2013-01-18 16:51 /home/dxm/public_html

Index Pages/Indexes

Next, Apache might throw a 403 forbidden error if you don't have an 'index' file in your public_html folder AND don't have Indexes enabled.

solution 1: create an index.html file

echo "index.html works" >> /home/dxm/public_html/index.html
echo "index.htm works" >> /home/dxm/public_html/index.htm

solution 2: enabled Indexes in your .htaccess file

echo 'Options +Indexes' >> /home/dxm/public_html/.htaccess

Note: Enabling Indexes will show the entire contents of your public_html folder. If you have sensitive stuff in there, don't enable it.

Otherwise, check your apache logs. Run

tail -f /var/log/apache2/error.log

and then hit the page a few times to see what error pops up.

  • Looks like chmod a+x on /home/dxh did that trick, thanks! Never would have suspected a permissions issue from a directory created during he Linux Mint install. – huertanix Jan 21 '13 at 20:16
0

On systems that implement selinux, you also need to issue the following command:

setsebool -P httpd_enable_homedirs true

I've setup user directorues several times, and yet I still always seem to forget that until I've pulled most of my hair out. This time it only took me two hours to remember it!