if you did chmod -r /var
nothing has changed.
-r
is not a valid option
/var/
is a root owned directory so will show a "permission denied".
The contents of /var/ needs to be:
drwxr-xr-x 2 root root 4096 dec 11 00:00 backups
drwxr-xr-x 20 root root 4096 okt 23 03:04 cache
drwxrwsrwt 2 root whoopsie 4096 dec 15 18:19 crash
drwxr-xr-x 73 root root 4096 okt 22 09:13 lib
drwxrwsr-x 2 root staff 4096 mrt 23 2022 local
lrwxrwxrwx 1 root root 9 apr 3 2022 lock -> /run/lock
drwxrwxr-x 15 root syslog 4096 dec 15 18:19 log
drwxrwsr-x 2 root mail 4096 mrt 30 2022 mail
drwxrwsrwt 2 root whoopsie 4096 mrt 30 2022 metrics
drwxr-xr-x 3 root root 4096 dec 7 17:18 opt
lrwxrwxrwx 1 root root 4 apr 3 2022 run -> /run
drwxr-xr-x 13 root root 4096 apr 18 2022 snap
drwxr-xr-x 7 root root 4096 mrt 30 2022 spool
drwxrwxrwt 12 root root 4096 dec 15 18:42 tmp
Compare yours with this one and adjust accordingly.
drwxr-xr-x = chmod 755
lrwxrwxrwx = chmod 777
drwxrwsrwt = chmod 2777 and then chmod o+t (with (s) setuid/setgid permissions (t) and sticky bit)
drwxrwxrwt = chmod 777 and then chmod o+t ((t) and sticky bit)
If /var/www
contains a website you own you can do this:
cd /var/www/
find . -type d -exec chmod 0755 {} \;
find . -type f -exec chmod 0644 {} \;
This tends to fix 99% of permissions problems for websites. You might need to adjust a couple of files manually.
Regarding the command: chmod 777 is almost never the correct solution. It is only used for symlinks and special directories (like /tmp that has a sticky bit).
Security wise strict mode would be for directories 750 (only user can execute, others can do nothing) and 640 for files that do not need executing. That way when you set up a webserver and you get errors you know you have a configuration issue that probably relates to a wrong user/group setting.