0

I have a dedicated server, installed with Debian, Apache and PHP installed using "sudo apt-get install php5 php5-curl" command.

You can force all created files in folder and sub​​-directories are always user www-data?

If I log into sftp and I send it to a file on FTP, it is always as root, because I'm logged in as root, it is also possible to change, for example, I want to send the file to the server logged in as root but it is his owner www-data?

2
  • you have to be user www-data to create as user www-data but after the fact you can issue a command such as chown -R www-data:www-data /files/xx/yy/
    – user557846
    Commented Jan 30, 2014 at 20:14
  • Thanks :) This command I have used here, it works, changes in all files recursively from www folder, but it is only at the time of command, what I want is something definitive, is it possible?
    – D3F4ULT
    Commented Jan 30, 2014 at 20:26

1 Answer 1

1

Having all files under www-data being owned by the web server - assuming write permissions by default - is dangerous, as a bug in a script or the web server itself could lead to source code injection.

The files under /var/www shouldn't be owned by the web server unless a certain web application really needs write access to a folder.

Even then and especially in a shared hosting environment there are better solutions than making the web server owner of such directories because this would allow every other PHP script - started by the web server - to write into that directory.

2
  • "The files under /var/www shouldn't be owned by the web server unless a certain web application really needs write access to a folder." The files in /var/www then who should be? I always knew you were www-data
    – D3F4ULT
    Commented Jan 30, 2014 at 20:28
  • If it is a single application server the files may be owned by root.. Or something like website_owner (better)
    – hek2mgl
    Commented Jan 31, 2014 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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