I have a small website running on a VPS. I'm using Nginx
as a web server (a simple LEMP
configuration). But now i have a problem: i have a small php script that needs to be able to write a log every once in a while...and for that to work i've given owner permissions to www-data
over /var/www/html/
after i ren chmod -R 755 /var/www/html
as root
. But once i gave owner permissions to www-data user over /var/www/html/
and i was, obviously, able to run that php script which has to write some logs i started to ask myself: isn't this going to be a HUGE security issue?
So, is making www-data
the owner of /var/www/html/
a security issue?
If yes, can you tell me why and what's to be done about it?
Thank you!
No. You can also use "group"
www-data
.But this is ...
Generally you need 2 commands: 1 for directories and 1 for files. Setting every file to executable is bad. You should use this:
access.log
).If you really need your script to be executed you set THAT script itself and not the whole website.
You can also use
php-cli
(orphp-cgi
if it is cgi) to execute a php script from command line without the need to set the script itself executable.