Just moved my websites to my first vps (centos 7). So i'm very new to linux. Now I have a problem: php cant write anything. Can't make dirs, files, edit them. Php runs as "apache" Things I tried:
- Chmod all dirs and files to 777
- Chown all dirs and files to "apache"
- Chown all dirs and files to "nobody"
Its simply wants to edit with file_put_contents(req.log, $content).
How can I fix it?
Edit: Ls -l:
root@vps314463 data]# ls -l
total 120
drwxrwxrwx. 2 apache apache 4096 Sep 8 11:12 EMAIL
-rwxrwxrwx. 1 apache apache 30357 Sep 8 10:49 login.log
-rwxrwxrwx. 1 apache apache 510 Sep 8 10:49 loginfail.log
-rwxrwxrwx. 1 apache apache 73268 Sep 8 10:49 req.log
-rwxrwxrwx. 1 apache apache 837 Sep 8 10:49 users copy 3.db
-rwxrwxrwx. 1 apache apache 994 Sep 8 10:49 users.db
Edit: Tried the answer of Kostas I chmoded and chowned public_html/data. Then opened test.php in public_html in webbrowser with the following code:
<?php
mkdir("data/testdir")
?>
Nothing happened and this error occurred:
[Thu Sep 08 22:39:20.138500 2016] [:error] [pid 24286] [client xx.xx.xxx.xxx:47632] PHP Warning: mkdir(): Permission denied in /var/www/example.com/public_html/usertest.php on line 3