1

I have a question regarding file permissions. I created a new user with sudo, and set the directory to chown (username). So far so good, only now the situation: When the system (magento2) creates new files, or I upload via magento 2 new files, the owner is 'www-data' instead of magento2 username.

Question:

What Do I need to do that every new file that magento will create or the file that I upload via magento will get the owner as: magento2 instead of www-data?

Server:

Ubuntu 16.04 Nginx 1.10 PHP7

I created the user like this:

  1. adduser magento2
  2. usermod -aG sudo magento2

Then I chownd like this:

  1. sudo chown -R magento2:www-data /home/magento2

  2. sudo find /home/magento2 -type d -exec chmod g+s {} \;

Thanks in advance,

HRR

HRR
  • 13
  • 1
  • 4
  • 2
    I think you have to change the user from nginx. Look here: http://stackoverflow.com/questions/18004018/changing-the-user-that-nginx-worker-processes-run-under-ubuntu-12-04 – deckerch Aug 10 '16 at 12:06
  • Thank you. I have set in nginx.conf the user magento2 instead of www-data. And in my .sock file i set permissions to magento2. That works! – HRR Aug 10 '16 at 18:35

1 Answers1

1

The problem is that the user running the webserver will be the owner of the new files. As suggested by deckerch, you need to change the user who is running nginx.

If you need to host multiple websites, you'll probably want different users to run nginx, so that every user will be able to create/access their files: https://www.digitalocean.com/community/tutorials/how-to-host-multiple-websites-securely-with-nginx-and-php-fpm-on-ubuntu-14-04