Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Sat Aug 27, 2011 6:43 am 
Offline
Senior Newbie

Joined: Sat Aug 27, 2011 6:35 am
Posts: 5
Website: http://fasckira.com
Location: Milton Keynes
So after a vanilla LAMP install on 11.04, Ive got my web directory in:

Code:
/srv/www/domain.com/public_html


My question is what should the group and user be set to on public_html? By default it was root and root post installation but recently I set it to my standard user account out of lazyness to create and edit files in there, is this safe to do?

It still serves the pages ok but I wasn't sure if www-data was supposed to be in charge or what? Any advice or tips much appreciated!


Top
   
 Post subject:
PostPosted: Sat Aug 27, 2011 7:07 am 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
Ownership doesn't really matter except under the following circumstances

1) You're using Suexec which requires the owner and executor are the same
2) Your web server needs to write files it tends to be wise to set the owner to www-data if you want to update wordpress for example
3) You're running a multi user environment, then the group sgid bit comes in handy

I tend to keep ownership to the user I sftp in as. But I don't run wordpress, suexec and work in a single user environment

_________________
Paid support
How to ask for help
1. Give details of your problem
2. Post any errors
3. Post relevant logs.
4. Don't hide details i.e. your domain, it just makes things harder
5. Be polite or you'll be eaten by a grue


Last edited by obs on Sat Aug 27, 2011 9:07 am, edited 1 time in total.

Top
   
 Post subject:
PostPosted: Sat Aug 27, 2011 8:45 am 
Offline
Senior Newbie

Joined: Sat Aug 27, 2011 6:35 am
Posts: 5
Website: http://fasckira.com
Location: Milton Keynes
Thank you for the answer!

So would it be practical to set www-data to group and owner and then add my standard user to www-data group or is that frowned up then?


Top
   
 Post subject:
PostPosted: Sat Aug 27, 2011 9:07 am 
Offline
Senior Member

Joined: Sun Mar 07, 2010 7:47 pm
Posts: 1970
Website: http://www.rwky.net
Location: Earth
If you want your web server to write to the site and you want your user to write to it I'd create a group say called "sitewritable" and add the web server and my user to that group then
Code:
chgrp -R serverwritable /path/to/files; chmod -R g+w /path/to/files; find /path/to/files -t d -exec chmod g+s {} \;
which sets the group, gives the group write permissions and sets the gid on execution of folders so new files should have group write perms

_________________
Paid support
How to ask for help
1. Give details of your problem
2. Post any errors
3. Post relevant logs.
4. Don't hide details i.e. your domain, it just makes things harder
5. Be polite or you'll be eaten by a grue


Top
   
 Post subject:
PostPosted: Sat Aug 27, 2011 5:46 pm 
Offline
Senior Member

Joined: Sat Jun 12, 2010 4:53 pm
Posts: 77
Quote:
I'd create a group say called "sitewritable" and add the web server and my user to that group then


Why do this when there is already something in place.

In ubuntu/debain it is:

group: www-data
user: www-data

Just do this:
Code:
sudo chown -R www-data /var/www/


Top
   
 Post subject:
PostPosted: Sat Aug 27, 2011 7:45 pm 
Offline
Senior Member

Joined: Sun Aug 31, 2008 4:29 pm
Posts: 177
reaktor wrote:
Just do this:
Code:
sudo chown -R www-data /var/www/


Don't do that.

If an exploit is discovered in a script you run then it could possibly be used to delete/overwrite every file and directory on the site.

www-data ownership should be assigned only under specific and controlled circumstances.

For most files and directories, assigned ownership to the shell user who maintains them.

_________________
sleddog


Top
   
 Post subject:
PostPosted: Mon Sep 19, 2011 7:02 am 
Offline
Senior Member

Joined: Fri May 20, 2011 2:45 am
Posts: 63
Location: Spain
Still not clear for me :(

Who should own the public_html/ ??? I have it with root...


Top
   
 Post subject:
PostPosted: Mon Sep 19, 2011 7:37 am 
Offline
Senior Member
User avatar

Joined: Sat Oct 16, 2004 11:13 am
Posts: 176
It depends on your setup.

I run everything through mod_suxec. This way all PHP, CGI, etc process are run as the user that owns the virtual host. I also give public_html ownership to that particular user. All this eliminates the need to give o+w permission when a web site needs to write to a file, and adds a mediocre level of security by making sure no website actually runs as the Apache user.


Top
   
 Post subject:
PostPosted: Mon Sep 19, 2011 8:52 am 
Offline
Senior Member

Joined: Sun Aug 31, 2008 4:29 pm
Posts: 177
fernandoch wrote:
Still not clear for me :(

Who should own the public_html/ ??? I have it with root...


If you administer the content in public_html, and you login to system as 'fernandoch', then the public_html directory and its content should be owned by user 'fernandoch'.

If a directory needs to be writeable by the webserver (e.g. for web-based uploads) then you have a choice of either: (a) changing permissions or ownership on the uploads directory to make it writeable; or (b) use suexec as saman007uk says, so that the upload script runs as user 'fernandoch' and has permission to write to the uploads directory, which is owned by user 'fernandoch'.

_________________
sleddog


Top
   
 Post subject:
PostPosted: Mon Sep 19, 2011 8:59 am 
Offline
Senior Member

Joined: Fri May 20, 2011 2:45 am
Posts: 63
Location: Spain
So it should not be the same user as apache's user?

And for sure not root?


Top
   
 Post subject:
PostPosted: Mon Sep 19, 2011 9:05 am 
Offline
Senior Member
User avatar

Joined: Sat Oct 16, 2004 11:13 am
Posts: 176
fernandoch wrote:
And for sure not root?

Yes.
fernandoch wrote:
So it should not be the same user as apache's user?
Depending on your setup. Basically the permissions need to be setup such that the Apache user can read any static data that you want available online.


Top
   
 Post subject:
PostPosted: Mon Sep 19, 2011 11:53 am 
Offline
Senior Member

Joined: Fri May 20, 2011 2:45 am
Posts: 63
Location: Spain
What do you guys think about this

Code:
# or B. More secure (recommended). Allow writting only in places Joomla! needs to write to (more secure)
sudo chown -R root:root /var/www/joomla
cd /var/www/joomla
PLACES='
administrator/backups
administrator/components
administrator/modules
administrator/templates
cache
components
images
images/banners
images/stories
language
mambots
mambots/content
mambots/editors
mambots/editors-xtd
mambots/search
media
modules
templates
'
for i in $PLACES; do
    sudo chown -R www-data:www-data $i
done


Taken from here https://help.ubuntu.com/community/Jooml ... ess_Rights


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group