Ubuntu – 403 Forbidden warning after installing/enabling usermod

apache-2.2debianlinuxmintUbuntuusermod

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?

Best Answer

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.

Related Topic