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?
1 Answer
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
Edited:
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.
-
The server we have is Siteground Cloud hosting, would that still apply as it is not a shared hosting environment? Jun 7, 2019 at 15:31
-
-
chmod 777 is bad, have a read of this askubuntu.com/questions/20105/… Jun 8, 2019 at 6:06
error_reporting( E_ALL);
andini_set('display_errors',1);
in top of yourindex.php
file after php tag<?php
to get actual error.