简体   繁体   English

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

[英]nginx php-fpm failed to open stream permission denied

I have a php file on my NGINIX(with php-fpm) that create a simple txt file. 我的NGINIX上有一个php文件(用php-fpm)创建一个简单的txt文件。

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

But this works only when I give my "www" folder 777 Permission. 但这只有在我给出“www”文件夹777权限时才有效。 My Index.php is placed in my www folder. 我的Index.php放在我的www文件夹中。

What is wrong with my user settings on nginix and php-fpm? 我在nginix和php-fpm上的用户设置有什么问题?

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

chown -R www-data:www-data www

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM