I just started running a LAMP server with an AMI from turnkeylinux.com.

It is running on AWS, all is well, pretty simple to just get things going.

Now, I want to host multiple sites on this server, and I've figured that out too. The place I really run into problems with is giving users appropriate access to via SFTP.

I can create a user than can log in, but can't figure out how to actually let them change certain files or folders in their home folder.

For example:

I am logged in as root, getting things set up. I create /var/www/site1.com and upload a bunch of files. I have set up my DNS and VHosts so that if I go to www.site1.com it works, excellent.

I have created a user named User1 and made them a member of the users group. and then done

chown -R User1:www-data /var/www

It seems to work, but I'm just not sure that this was the RIGHT was to do it. And is this how I should continue to manage the sites. It has made all of the files 755. I'm new to linux, so any advice on how to proceed is appreciated.

link|improve this question

25% accept rate
chown does not set the RWX rights of files, you must have also done a chmod at some point. Also, setting the rights of /var/www doesn't really have anything to do with granting SFTP rights, per-se. – Perception Sep 21 '11 at 20:13
Off topic; belongs on Serverfault or Webmasters. – Ex Umbris Sep 21 '11 at 20:29
feedback

migrated from stackoverflow.com Sep 21 '11 at 23:58

This question came from our site for professional and enthusiast programmers.

1 Answer

The "right" way depends on a lot of factors, but the simplest case where:

1) The webserver runs as www-data and needs to display pages in /var/www//

2) The users need to be able to write to their own folders

So lets say you have /var/www/user1 with site1 and user2 with /var/www/ site2

A way to acheive what you want is to have all files owned by group :www-data throughout the /var/www folder heirachy

chown :www-data /var/www -R

And individual folders and files owned by the respective user:

chown user1 /var/www/site1 -R

Then you can use 640 permissions for files (owner: read-write, group: read, universal: nothing) And 750 for directories (owner: read-write-execute, group: read-execute, universal: nothing)

It gets more involved if you want to be able to upload files via websites for example...

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.