Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

<?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. My Index.php is placed in my www folder.

What is wrong with my user settings on nginix and php-fpm?

like image 462
codinglimo Avatar asked Sep 17 '15 07:09

codinglimo


1 Answers

After i give ownership of my www folder to my nginx user (as defined in /etc/nginx/nginx.conf), it works!

chown -R www-data:www-data www
like image 153
codinglimo Avatar answered Sep 20 '22 07:09

codinglimo