nginx php-fpm failed to open stream permission denied

10,699

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
Share:
10,699
codinglimo
Author by

codinglimo

Updated on June 19, 2022

Comments

  • codinglimo
    codinglimo almost 2 years

    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?