douquanqiao6788 2016-08-10 12:02 采纳率: 100%
浏览 890
已采纳

Nginx将新文件www-data设置为所有者而不是我的用户

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

  • 写回答

1条回答 默认 最新

  • doumeng3080 2016-08-10 15:35
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?