Tired of "permission denied" errors? I have a fix I use on every machine:
sudo chmod -R 777 /var/www
Works every time. No more permission problems. I have never had one since. Why do people make this so complicated?
Tired of "permission denied" errors? I have a fix I use on every machine:
sudo chmod -R 777 /var/www
Works every time. No more permission problems. I have never had one since. Why do people make this so complicated?
It works in the same sense that taking the door off its hinges fixes a sticking door. The error went away because you removed the check, not because you solved the problem.
777 means every user on the system can read, write and execute everything in the tree. On a web server, that includes the account the web server runs as. Any bug in the application that can write a file now can write code in a directory that gets executed. You have turned a small bug into a large one.
The actual fix is boring: find out which user the process runs as (ps -o user= -p <pid>) and which user owns the files, then give that group write access to only the directories that need it:
sudo chgrp -R www-data /var/www/app/uploads
sudo chmod -R g+rwX /var/www/app/uploads
Everything else stays read-only to the web server. Then ls -l and namei -l on the path to see which directory in the chain was blocking.
Y por si ayuda: hay una variante peor, chmod -R 777 /, que rompe sudo, ssh y otras cosas que comprueban permisos estrictos a propósito. Lo he visto en un servidor ajeno, y la reparación fue reinstalar. Despacito y con namei -l.
Okay, but it worked on my machine. Fine, I will read about groups. What does the capital X in g+rwX do?
Capital X sets execute only on directories (and on files that already had execute for someone). Directories need x to be entered; ordinary files usually should not be executable. So you get the right bits on each without making every file a program.
Inicia sesión o únete para responder.