nginx php-fpm 无法打开流权限被拒绝
nginx php-fpm failed to open stream permission denied
我的 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);
?>
但这只有在我给 "www" 文件夹 777 权限时才有效。我的 Index.php 放在我的 www 文件夹中。
我在 nginix 和 php-fpm 上的用户设置有什么问题?
在我将我的 www 文件夹的所有权交给我的 nginx 用户(如 /etc/nginx/nginx.conf
中所定义)后,它起作用了!
chown -R www-data:www-data www
我的 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);
?>
但这只有在我给 "www" 文件夹 777 权限时才有效。我的 Index.php 放在我的 www 文件夹中。
我在 nginix 和 php-fpm 上的用户设置有什么问题?
在我将我的 www 文件夹的所有权交给我的 nginx 用户(如 /etc/nginx/nginx.conf
中所定义)后,它起作用了!
chown -R www-data:www-data www