I am trying to install a theme to a magento site, but running setup:upgrade after the files are transferred breaks all css and javascript. I read that the file permissions may be an issue, so after running chmod -R 777 . the whole site breaks, and returns a 500 Internal Server Error. What can I do to install this theme without breaking the site, and if it is a permissions problem how do you change the file permissions without breaking the website?

  • Do you find anything in server log? Jun 7, 2019 at 12:07
  • Add the error_reporting( E_ALL); and ini_set('display_errors',1); in top of your index.php file after php tag <?php to get actual error. Jun 7, 2019 at 15:29

1 Answer 1


You should set the permission so it matches the permissions your webserver is running under. I wouldn't recommend using 777 permissions as this allows global write permissions. In a shared hosting environment i prefer to use :

chown -R webserveruser:webservergroup ./ PATH

Replace webserveruser etc.. with the actual user/group. you can check this by doing ls -la


Don't use chmod 777, the reason you get this error is the user you are logged in as when you run setup:upgrade has root(or higher permissions) than the user your webserver/php is running under. Any files/folders created with the setup script (eg: var/generation) will be owned by root and so is not accessible by the webserver/php when you reload the page in your browser.

The fix for this isn't to grant permission to every user on your server but only grant permission to the user who actually needs access.

The next time you run setup:upgrade consider doing a

su webserveruser

first as this will ensure the files modified are still accessible by the webserver.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.