Hi
When i run this commands
sudo chown -R www-data:www-data /var/www
and then this one:
sudo chmod -R 775 /var/www
My user tokar86a dont have access to upload files any more in the www folder. How can i give him that access? whiteout changing the folder permission i have set above. I need to have that so wordpress works.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
So the problem is that
www-data
needs to have write permission to some of the files and folders you upload. It would be good to know which files WordPress requires write permission to and only give it to those files.There is a less secure solution which involves giving write permission to only your user and
www-data
.First lets take care of the initial permissions.
Give
setgid
to/var/www
so every file created in it will inherit it’s group ID.Now make sure that uploaded files will get
rw- rw- ---
permissions. Opensshd_config
.Find the line
Subsystem sftp /usr/lib/openssh/sftp-server
and append-u 017
to it.Save the file and reload SSH to activate the modification.
Reconnect to SFTP and the problem should be solved. Uploaded files should be owned by your user. The group should be
www-data
and the permission should berw- rw- ---
.If you want to retain read permission to world you can use
013
instead of017
.What is happening here is that the files you upload through FTP are owned by the user you used to upload with and they probably have
rwx --- ---
permissions sowww-data
can’t do anything with them.I assume you use VSFTPD as the FTP server. In which case you can find a setting called
local_umask
invsftpd.conf
which probably equal with077
. That is the permission of the uploaded files.You could change
local_umask
to022
which would make the uploaded files haverwx r-x r-x
andwww-data
would be able to read all the files.Don’t forget to restart the FTP server after changing it’s configuration.
In a production environment I would not recommend setting
local_umask
in a way that gives write permissions automatically. I would give write permissions specifically by hand to the required directories and users.If you are developing something and not deploying to a production environment you can set
local_umask
to000
to speed up the process, but only do this if you doing it on a private development environment!One possible solution is that to change the group to your user’s group. That way www-data and tokar86a will both have write permission.