我如何设置nginx让它在/ home / user文件夹上创建文件和dirs?

I rule a server where several users have their own webdir, set on /home/user/public_html. Nginx is running as http. Everything works OK, but if a php requires a file to be created, it outputs a permission error.

How may I fix this? Is possible to tell nginx to create all files under /home/username as "username"?

Regards && TIA ^^.

Yes, this is possible. Actually it's not Nginx, it's the FastCGI PHP module which is acting as a specific user. There is a good explanation of how to setup a Debian/Ubuntu system to do that.

Additionally I would create two users and one group per account (e.g. user1, user1-www and user1-group). For FTP you can use user1/user1-group. But the FastCGI PHP module can be configured to act as user1-www/user1-group.

  1. Now you can limit read and write access to the folders of one account.
  2. Your clients are free to allow or forbid write access to any file or directory based on their requirements.

If a PHP process can modify PHP code, you are exposed to be hacked and sites to be manipulated. Limiting write access to data files only reduces this danger. If you are on your own I wouldn't mind but providing hosting services to other people increased your responsibility.