Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Tue May 31, 2011 4:17 am 
Offline
Newbie

Joined: Tue May 31, 2011 3:57 am
Posts: 3
Hi All,

Quite new to *nix.

I have nginx webserver running under www-data user and group.
I have a problem when I upload via sftp, I don´t have permissions to overwrite files ( I don´t want to set 777 on all files)

Is there any way / approach / strategy that lets me set 755 permissions and upload / overwrite files via ftp / sftp ( preferably with different user) ?

With my previous hosting, I could even overwrite files with 600, so having full access for ftp users would be great.


Many thanks in advance.

L


Top
   
 Post subject:
PostPosted: Tue May 31, 2011 10:57 am 
Offline
Senior Member

Joined: Tue May 03, 2011 11:55 am
Posts: 105
There are probably two strategies I might try on this. First is simple - just log in to SFTP as www-data and then you should have full permissions over those files.
The second strategy is to have another user that you use to login with, let's call it "myuser". You then add myuser to the group of www-data by editing the group file. (I use CentOS with the "vigr" command to edit this file as root). Then you set ownership on the files you want to overwrite like this:
chown www-data:www-data somefile
chmod 0770 somefile

That should give the user www-data and any other users belonging to the www-data group (in our case, one) full permissions to the files.

Hope this helps.


Top
   
 Post subject:
PostPosted: Tue May 31, 2011 12:14 pm 
Offline
Senior Member

Joined: Wed Jul 21, 2010 8:04 pm
Posts: 119
My approach...

I just add my user to the www-data group and set the files to 775.

Code:
sudo usermod -a -G www-data jeff
sudo chmod -R 775 /var/www
sudo chown -R www-data:www-data /var/www


Top
   
 Post subject:
PostPosted: Thu Jun 02, 2011 6:14 pm 
Offline
Newbie

Joined: Tue May 31, 2011 3:57 am
Posts: 3
yes, did not like the 77x permissions but that is what I ended up doing.

Thanks to all.

L


Top
   
 Post subject:
PostPosted: Thu Jun 02, 2011 6:52 pm 
Offline
Senior Member

Joined: Fri May 02, 2008 8:44 pm
Posts: 1121
Umm, why are the files owned by www-data in the first place? That makes no sense. nginx does not require write access to any of your website files. It only needs to be able to read them. You can make all your website files owned by your own username, set the permissions to 755, and let nginx read them to its heart's content.

If you have any web application that requires write access, such as a PHP script, you just change a few things in the FastCGI/FPM init script so that PHP runs as the same user who owns the website files. With Apache, it was customary to run PHP as www-data, but with nginx, there's no need to do that anymore.


Top
   
 Post subject:
PostPosted: Sun Aug 28, 2011 7:17 am 
Offline
Newbie

Joined: Tue May 31, 2011 3:57 am
Posts: 3
hybinet wrote:
Umm, why are the files owned by www-data in the first place? That makes no sense. nginx does not require write access to any of your website files. It only needs to be able to read them. You can make all your website files owned by your own username, set the permissions to 755, and let nginx read them to its heart's content.

If you have any web application that requires write access, such as a PHP script, you just change a few things in the FastCGI/FPM init script so that PHP runs as the same user who owns the website files. With Apache, it was customary to run PHP as www-data, but with nginx, there's no need to do that anymore.


many thanks, this is what I have done and I think it is best scenario.

regards


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