My environment is an AWS EC2 machine, with only one magento 2.2.3 store, with apache and Mysql. I've followed a few posts here from stackoverflow (here and here) and oficial documentation, but I'm not sure if I got all we need here. I've been setting my folder permissions as:
sudo find . -type f -exec chmod 740 {} \;
sudo chmod u+x bin/magento;
sudo find . -type d -exec chmod 750 {} \;
./var/view_preprocessed \( -type d -or -type f \) -exec chmod 777 {} \;
sudo find ./pub/media -type d -exec chmod 775 {} \;
sudo find ./pub/static \( -type d -or -type f \) -exec chmod 775 {} \;
sudo find app/code lib pub/static app/etc generated/code generated/metadata var/view_preprocessed \( -type d -or -type f \) -exec chmod g-w {} \; && chmod o-rwx app/etc/env.php;
sudo find . -maxdepth 1 -type f -exec chmod g-wr {} \;
sudo chmod g+rx index.php .htaccess composer.json composer.lock && sudo chmod g-w .;
My question is, is this file permissions secure? There is something to get better, if so, why?