I stored my hosts in /home. To have full functionality of my scripts I
gave a write permission to www-data (my nginx user) through SSH with
chown command. Although www-data has full permission to /home but I have
problem for writing in sub-folders. For example I need to give
individually a write permission for .home/domain/images.
How I can give write permission to www-data fully?
Posted at Nginx Forum:
If the subdirectories were created before you chowned /home you’ll need
to run it recursively. For example:
cd /home && chown -R www-data .
try,
sudo chmod -R 755 /home/yourhosts
use the -R
On 7/27/11 9:31 AM, Adam Tucker wrote:
If the subdirectories were created before you chowned /home you’ll need to run
it recursively. For example:
cd /home && chown -R www-data .
This is fine if you want all of the files in /home to be writable. If
there are files that should not be writable, you can change ownership of
all of the directories only with:
cd /home
find . -type d -exec chown www-data {} ;
or
change write privileges with chmod:
cd /home
find . -type d -exec chmod 777 {} ;
Doing either of these can be a security risk. You should consider only
giving privileges to write to files and directories that should be
writable by the web server (like an “uploads” or “images” directory). To
do this you have to manually change them one by one.
How I can give write permission to www-data fully?
nginx mailing list
[email protected]
nginx Info Page
–
Jim O.
On 27 Jul 2011 14h50 WEST, [email protected] wrote:
Thanks folks. Let me conclude that it is better to keep the owner of
my folders to be “root”. Then give permission to www-data (nginx
user) for every writable folder like upload and images? right?
Yes. Normally a simple 775 is enough with:
chown -R sites-user.www-data /path/to/writabledirs
find /path/to/writabledirs -type d -exec chmod 775 {} ;
My main question is about the folder ownership; which is better?
root or www-data? Because when I normally create folder by SSH or
SSH tunnel to server, I am there as root and create folder with root
ownership.
Unless you have some sort of esoteric requirements you should,
never, ever, run a web site under the root user. Create a new user
and move all sites to a sites dir like this.
adduser sites-user
mkdir /home/sites-user/sites
ln -s /home/sites-user/sites /var/www/sites
Now move all site related files and dirs to /home/sites-user/sites.
Done.
— appa
On 7/27/11 9:50 AM, etrader wrote:
Thanks folks. Let me conclude that it is better to keep the owner of my
folders to be “root”. Then give permission to www-data (nginx user) for
every writable folder like upload and images? right?
My main question is about the folder ownership; which is better? root or
www-data?
Because when I normally create folder by SSH or SSH tunnel to server, I
am there as root and create folder with root ownership.
This is really off the topic of this list. However the answer to your
question is it’s a matter of choice.
You can create the directory as root and change the ownership with
“chown”, you can create the directory using “sudo -u www-data mkdir” or
you can leave the ownership as root and use “chmod”.
Posted at Nginx Forum:
Re: write permission for www-data
nginx mailing list
[email protected]
nginx Info Page
–
Jim O.
Thanks folks. Let me conclude that it is better to keep the owner of my
folders to be “root”. Then give permission to www-data (nginx user) for
every writable folder like upload and images? right?
My main question is about the folder ownership; which is better? root or
www-data?
Because when I normally create folder by SSH or SSH tunnel to server, I
am there as root and create folder with root ownership.
Posted at Nginx Forum:
Thanks Jim,
Yes, I run nginx as www-data; I just meant creating files and folders by
root. My own PC run on Ubuntu; thus I connect to server through OS
explorer. I connect to server via sftp with root user. Then, when I
create a folder or php file its ownership belongs to root. I just asked
if it is necessary to create each and every file and folder by nginx or
site user? or it is OK to be owned by root?
Posted at Nginx Forum:
On 29 Jul 2011 20h29 WEST, [email protected] wrote:
Yes, I run nginx as www-data; I just meant creating files and
folders by root. My own PC run on Ubuntu; thus I connect to server
through OS explorer. I connect to server via sftp with root
user. Then, when I create a folder or php file its ownership belongs
to root. I just asked if it is necessary to create each and every
file and folder by nginx or site user? or it is OK to be owned by
root?
No. It is not OK to be owned by root. Read my previous reply in the
thread.
— appa
On 7/27/11 10:12 AM, Antnio P. P. Almeida wrote:
find /path/to/writabledirs -type d -exec chmod 775 {} ;
My main question is about the folder ownership; which is better?
root or www-data? Because when I normally create folder by SSH or
SSH tunnel to server, I am there as root and create folder with root
ownership.
Unless you have some sort of esoteric requirements you should,
never, ever, run a web site under the root user.
Don’t confuse the guy or make the issue more comlplicated than it is. He
clearly stated that he runs nginx under user “www-data” and didn’t ask
this question. He wants to know about file write permissions.
…
— appa
nginx mailing list
[email protected]
nginx Info Page
–
Jim O.