R
R
Romua1d2018-05-17 08:45:48
linux
Romua1d, 2018-05-17 08:45:48

How to set permissions for linux user and www-data?

chown -R www-data:www-data folder gave permissions
folder is in the root of the user.
The user does not have access to folder
I understand that ideally you need to throw the user into the www-data group and use 775 and 664 permission settings.
But at creation by one user of a file. 644 is generated and www-data has no rights. Also and vice versa.
I see that on hosting, we go under the user and edit files and in parallel www-data can edit them.
How to do this locally?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alexander Karabanov, 2018-05-17
@Romua1d

On hosting, the web server also works with user rights. If it's Apache use apache2-mpm-itk if it's Nginx+php-fpm then configure php-fpm accordingly.
Access via FTP is also carried out with the rights of this user.
SSH/SFTP access too. Well, you understand. That's the whole secret.

I
ivankomolin, 2018-05-17
@ivankomolin

Everything is correct about the user user in the www-data group.
Now you need to set the correct umask for the user user.
So that when creating a file, the rights are set to 0664.
The basic rights for directories are 0777 (rwxrwxrwx) and for files 0666 (rw-rw-rw).
umask allows you to create rights when creating for each user separately.
Example of creating a file with mask 0022:
Default permissions: 0666
Subtracted umask value: 0022 (-)
Final rights: 0644
To get the correct permissions, you need to set the mask to 0002
Example of creating a file with mask 0002:
Default permissions: 0666
Subtracted umask value: 0002 (-)
Final rights: 0664

R
Reversaidx, 2018-05-17
@Reversaidx

Usually on hosting this is solved by using one uuid for the user and www-data (for the system they stop being different)

A
Andrey Gavrilov, 2018-05-29
@thexaver

chown -R www-data:www-data /var/www

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question