Never use 777, use 644 for files, and 755 for dirs.
export APACHE_USER=$(ps -ef | grep -E '(httpd|apache2|apache)' | grep -v `whoami` | grep -v root | head -n1 | awk '{print $1}') find . -type f -exec chmod 644 {} \; find . -type d -exec chmod 755 {} \; chgrp -R $APACHE_USER ./storage ./bootstrap/cache chmod -R ug+rw ./bootstrap/cache ./storage/framework/cache storage/framework/sessions ./storage/framework/views
If you use SELinux set labels:
restorecon -Rv . chcon -R -t httpd_log_t storage/logs chcon -R -t httpd_sys_rw_content_t bootstrap/cache chcon -R -t httpd_sys_rw_content_t storage/framework/cache chcon -R -t httpd_sys_rw_content_t storage/framework/views chcon -R -t httpd_sys_rw_content_t storage/framework/sessions
Script ready at: https://gist.github.com/NeftaliYagua/825b6ce483b92a296caa0f37e4ff040a