Reputation: 2318
I have the following test page
mkdir('test');
$f = fopen('test.txt', 'w+');
fwrite($f, 'gibberish');
fclose($f);
unlink('test2.txt');
Nothing of that happens and I get the following error messages on erro.log
PHP Warning: mkdir(): Permission denied in /var/www/html/test.php on line 5
PHP Warning: fopen(test.txt): failed to open stream: Permission denied in /var/www/html/test.php on line 7
PHP Warning: fwrite() expects parameter 1 to be resource, boolean given in /var/www/html/test.php on line 8
PHP Warning: fwrite() expects parameter 1 to be resource, boolean given in /var/www/html/test.php on line 9
PHP Warning: fclose() expects parameter 1 to be resource, boolean given in /var/www/html/test.php on line 10
PHP Warning: unlink(teste2.txt): Permission denied in /var/www/html/test.php on line 12
I can clearly see that I'm having permission issues, but I have no ideia what sort of permission it is and how do I even set that kind of permission.
Using git or terminal I can create/delete/chmod all files and directories without a problem. It's just PHP that can't.
Upvotes: 0
Views: 2089
Reputation: 757
ssh using your terminal and, first, change the files owner to apache group
chown -R www-data:www-data /var/www/html/
Next allow all members of this group to read and write files
chmod -R g+rw /var/www/html/
This should fix your issue. I strongly suggest you read more about permissions in ubuntu though
Upvotes: 3