LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Ubuntu server apache2 changing documentroot gives a 403 (https://www.linuxquestions.org/questions/linux-server-73/ubuntu-server-apache2-changing-documentroot-gives-a-403-a-811319/)

rnx 05-31-2010 12:36 PM

Ubuntu server apache2 changing documentroot gives a 403
 
Hi all!

First off, thank you for taking your time to help me out!

I have a basic setup with ubuntu-server (10.04) and apache2 (by apt-get).
The thing is I can't change the documentroot of my web page from /var/www to example /home/user/www although the directory is created and the necessary changes has been made in /etc/apache2/sites-available/default.

I've figured this is a permission issue since I always get a 403 error every time I try to access my http://local-ip-to-server. My permissions set to the new folder is as follows:

drwxr-xr-x 2 user user 4096 2010-05-31 18:27 www

(where user is me)

Same goes for the files inside www

drwxr-xr-x 2 user user 4096 2010-05-31 18:27 .
drwx------ 6 user user 4096 2010-05-31 18:48 ..
-rw-r--r-- 1 user user 29 2010-05-31 18:27 index.html

Also, the desktop installation I have of ubuntu 10.04 has no problem with changing the documentroot to /home/user/www by just creating that folder and putting a basic index.html inside. The permissions are exact as I figure it.

Am i missing something here? Please help!

Blue_Ice 05-31-2010 12:40 PM

Did you also change the <Directory "/var/www"> to <Directory "/home/user/www">?

rnx 05-31-2010 01:04 PM

Hi Blue_Ice

Yes I did, no luck. I also saw that apache2.conf refers to envvars to be user and group www-data, so I changed chown www-data:www-data to my /home/user/www directory, still though, no luck. Still 403.

rnx 05-31-2010 01:22 PM

FYI
I don't know if this is safe, but I changed the group from www-data/www-data to user/user in envvars in /etc/apache2/, and now it works like a charm.
Get back to me if this is wrong!

Cheers all!

Blue_Ice 05-31-2010 03:34 PM

Probably because the useraccount www-data is not allowed to access /home/user, you get the 403 error. By using useraccount user you gave apache access to the directory. Although I don't think that this is the correct way to give access to user directories. I would have created a sym link from /home/user/www to /var/www.

Using mod_userdir is possible as well...

rnx 06-01-2010 01:30 AM

How do you make a sym link? Sounds like fun ^^

Blue_Ice 06-01-2010 02:39 AM

Code:

# rm -r /var/www
# ln -sv /home/user/www /var/www


btmiller 06-01-2010 02:42 AM

Use the "ln -s" command to make a symbolic link (symlink). Read "man ln" for more details.

If you want your user account to be able to edit files in the web root, it would be better to change the permissions on /var/www to allow that. You generally don't want Apache to have access to your user account (especially if you're allowed to use sudo). That can allow a cracker to have all sorts of fun...

rnx 06-01-2010 03:35 AM

I see, thanks mates
I'll sym link the directory for sure. Blue_ice, are you sure about removing the /var/www directory?

Blue_Ice 06-01-2010 05:02 AM

Yes, unless you have data in it.
The www directory will be replaced with the www sym linked directory.

henkoegema 06-01-2010 05:02 AM

Quote:

Originally Posted by Blue_Ice (Post 3988248)
Code:

# rm -r /var/www
# ln -sv /home/user/www /var/www


Why has the /var/www/ to be removed?

I don't understand how a symlink can point to (from ?) a non existing directory.

Blue_Ice 06-01-2010 05:04 AM

As there will be no sym link to /var/www. /var/www will be the sym link.

rnx 06-01-2010 10:12 AM

So lads, when creating the sym link... Do I use /var/www as documentroot in /etc/apache2/site-available/default or do I use my user ?
I've tried it with default documentroot (/var/www/) and then its back to good old 403 :<


All times are GMT -5. The time now is 08:46 AM.