S
S
seredaes2017-11-08 00:52:17
PHP
seredaes, 2017-11-08 00:52:17

How to setup apache access in ubuntu?

Hello.
Created a folder in home directory

/home/myusername/www/home/
drwxrwxr-x  3 myusername myusername 4096 Nov  7 16:42 www/
drwxrwxr-x  2 myusername myusername 4096 Nov  7 16:43 home/

So, inside the index.php file with the code
<?php
    file_put_contents("www1.txt","Test");
  echo "OK";

And the file is not created. I understand that apache works on behalf of www-data and the www-data group.
I added my user to the www-data group
. edit files and Apache had access?
Today I did chmod -R 777 /var/www /
well, you understand :( I demolished the rights and could not log in as an admin. Therefore, I decided to solve this issue once and for all.
Thanks for the help!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2017-11-08
@seredaes

Make the user of this directory yourself and the group www-data and add yourself to it.
Set the permissions on the directory to 660

S
seredaes, 2017-11-08
@seredaes

I set the rights to
drw-rw-r-- 3 myusername www-data 4096 Nov 7 16:42 www/
now I can’t enter this folder at all ...
But doesn’t this mean that me and the www-data group can edit files and read, and everyone else just read?
In general, chmod -R 774 www/
solved the problem. And apache works and the user can edit everything.
Does anyone know if this is normal?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question