0

I'm trying to write contents to file, however I constantly receive error about lacking permission.

fopen(/var/www/html/files/l.log) Failed to open stream permission denied in /var/www/html/files/file.php

PHP code l use:

$path = __DIR__.'/l.log';
$logfile = fopen($path, "a+") or die();

After checking php and apache processes with:

ps aux | grep apache2
ps aux | grep httpd
ps aux | grep php

I know they both have root and www-data permissions

I tried transferring ownership to www-data or adding permissions for reading and write:

sudo chown www-data:www-data /var/www/html/files/l.log
sudo chmod 755 /var/www/html/files/
sudo chmod 664 /var/www/html/files/l.log

But that didn't work. I also don't have SElinux as mentioned in another post.

2
  • Is your PHP code running as part of Apache httpd module or as part of PHP-FPM manager? Commented Jul 6 at 11:03
  • ... hmm... maybe: Make sure /etc/group has DUMMY:65535: as the very last line.
    – Hannu
    Commented Jul 7 at 8:28

0

You must log in to answer this question.

Browse other questions tagged .