nginx php-fpm无法打开流权限被拒绝

cod*_*imo 3 php debian nginx server

我的NGINIX(带有php-fpm)上有一个php文件,可创建一个简单的txt文件。

<?php
$content = "some text here 123 myText.txt";
$fp = fopen($_SERVER['DOCUMENT_ROOT'] . "/myText.txt","wb");
fwrite($fp,$content);
fclose($fp);
?>
Run Code Online (Sandbox Code Playgroud)

但这仅在我授予“ www”文件夹777许可时有效。我的Index.php放在我的www文件夹中。

我在nginix和php-fpm上的用户设置有什么问题?

cod*_*imo 5

在将www文件夹的所有权提供给我的nginx用户(如中所定义/etc/nginx/nginx.conf)后,它就可以工作了!

chown -R www-data:www-data www
Run Code Online (Sandbox Code Playgroud)