fopen() doesn't work on my apache2 local server on linux mint
<?php
error_reporting(E_ALL);
ini_set('display_errors',1);
include_once "c&f.php";
fopen("test.txt", 'w');
File test.txt
is created and I can open it and write something to it using Sublime. Directory for this particular project is /var/www/site02
. While I was configuring apache2 after installation, I specifically changed the ownership of this particular directory (site02) to be able to read and write files (sudo chown $USER:$USER -R ... you get the idea). And I indeed can read and write from my user account in this directory (I can use cli git commands in this directory freely without "sudo").
If I access the index.php
with the code I mentioned above, I get this error:
"Warning: fopen(test.txt): Failed to open stream: Permission denied in /var/www/site02/index.php on line 6"
What is going on? I've tried to google this issue but I get million different reasons which only confuse me more. Is the problem with apache server? Or I need to do some config changes for PHP?