LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 05-31-2010, 12:36 PM   #1
rnx
LQ Newbie
 
Registered: Nov 2009
Posts: 7

Rep: Reputation: 0
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!
 
Old 05-31-2010, 12:40 PM   #2
Blue_Ice
Member
 
Registered: Jul 2006
Location: Belgium
Distribution: Debian, Fedora, CentOS, Windows
Posts: 352

Rep: Reputation: Disabled
Did you also change the <Directory "/var/www"> to <Directory "/home/user/www">?
 
Old 05-31-2010, 01:04 PM   #3
rnx
LQ Newbie
 
Registered: Nov 2009
Posts: 7

Original Poster
Rep: Reputation: 0
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.
 
Old 05-31-2010, 01:22 PM   #4
rnx
LQ Newbie
 
Registered: Nov 2009
Posts: 7

Original Poster
Rep: Reputation: 0
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!
 
Old 05-31-2010, 03:34 PM   #5
Blue_Ice
Member
 
Registered: Jul 2006
Location: Belgium
Distribution: Debian, Fedora, CentOS, Windows
Posts: 352

Rep: Reputation: Disabled
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...

Last edited by Blue_Ice; 05-31-2010 at 03:39 PM.
 
Old 06-01-2010, 01:30 AM   #6
rnx
LQ Newbie
 
Registered: Nov 2009
Posts: 7

Original Poster
Rep: Reputation: 0
How do you make a sym link? Sounds like fun ^^
 
Old 06-01-2010, 02:39 AM   #7
Blue_Ice
Member
 
Registered: Jul 2006
Location: Belgium
Distribution: Debian, Fedora, CentOS, Windows
Posts: 352

Rep: Reputation: Disabled
Code:
# rm -r /var/www
# ln -sv /home/user/www /var/www
 
Old 06-01-2010, 02:42 AM   #8
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,128

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
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...
 
Old 06-01-2010, 03:35 AM   #9
rnx
LQ Newbie
 
Registered: Nov 2009
Posts: 7

Original Poster
Rep: Reputation: 0
I see, thanks mates
I'll sym link the directory for sure. Blue_ice, are you sure about removing the /var/www directory?
 
Old 06-01-2010, 05:02 AM   #10
Blue_Ice
Member
 
Registered: Jul 2006
Location: Belgium
Distribution: Debian, Fedora, CentOS, Windows
Posts: 352

Rep: Reputation: Disabled
Yes, unless you have data in it.
The www directory will be replaced with the www sym linked directory.
 
Old 06-01-2010, 05:02 AM   #11
henkoegema
LQ Newbie
 
Registered: Jul 2006
Posts: 11

Rep: Reputation: 0
Quote:
Originally Posted by Blue_Ice View Post
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.
 
Old 06-01-2010, 05:04 AM   #12
Blue_Ice
Member
 
Registered: Jul 2006
Location: Belgium
Distribution: Debian, Fedora, CentOS, Windows
Posts: 352

Rep: Reputation: Disabled
As there will be no sym link to /var/www. /var/www will be the sym link.
 
Old 06-01-2010, 10:12 AM   #13
rnx
LQ Newbie
 
Registered: Nov 2009
Posts: 7

Original Poster
Rep: Reputation: 0
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 :<
 
  


Reply

Tags
apache2, documentroot, server, ubuntu


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
APACHE2 DocumentRoot does not exist for Vhost Wonderm00n Linux - Software 2 04-09-2010 09:33 PM
apache2: DocumentRoot, Location, mod_python GSMD Linux - Server 3 07-24-2007 07:31 AM
apache2 on debian, DocumentRoot confusion andrews-mark Debian 2 03-10-2007 05:17 AM
apache2 group/owner DocumentRoot security deadeyes Linux - Security 3 02-24-2007 07:05 PM
Apache is giving me 403 when changing DocumentRoot Lazy Foo' Linux - Software 7 01-30-2006 08:39 PM


All times are GMT -5. The time now is 02:37 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration