Magento 2: Site not working after delete pub/static folder manually
-
11-10-2020 - |
Question
I am running Magento 2.1 in developer mode. I manually deleted everything in the pub/static/
folder, and then ran the deploy command.
I then cleared cache, I am now getting this error I can't solve? Any advice?
1 exception(s): Exception #0 (Magento\Framework\Exception\FileSystemException): The path "_requirejs/frontend/AZ/az/en_US/requirejs-config.js:
///home/xxx/public_html/xxx/pub/static/home/xxx/public_html/xx/pub/static/" is not writable
Solution 4
I solved the problem by running:
php bin/magento setup:upgrade
then,
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
and finally,
rm -rf var/cache/*
note: that fixed the frontend. But for some reason now, trying to access the backend is giving me the same error. Even though the front end is totally fine.
OTHER TIPS
First of all, give permission of pub and var folder
Make sure you must have .htaccess file in pub/static folder. Don't remove .htaccess file from pub/static and pub folder.
If you accidentally remove .htaccess from pub and pub/static copy it from fresh magento setup.
And run php bin/magento setup:static-content:deploy
Don't run each command every time when you made little changes, Hear is my answer about which changes need which commands in magento2: https://magento.stackexchange.com/a/184927/35758
You should press command
sudo chmod -R 777 var/ pub/
It is because of the permission mode. Try this command in the root folder of your app:
sudo chmod -R 777 var/ pub/
If the command above don't work.Try the following command:
sudo chown wwwuser -R var/ pub/
The problem is that when you delete the whole content of pub/static, you also delete the .htaccess file and this causes your problems with generating symlinks to static resource in developer mode.
So,
- Don't delete .htacess file.
- Delete only the directory of your specific theme, ex. delete contents only in pub/static/frontend/Your/theme
From my experience, when using symlinks to static files in Developer mode, you don't need to delete them in order to see your changes.
Along with var/cache, you also need to delete files in var/view_preprocessed
I had an issue once with blank screens on both frontend and backend, restarting Apache fixed the issue.
sudo systemctl restart apache2
service httpd restart
it could be a problem with the language. You can try to list languages used in back office after the command php bin/magento setup:static-content:deploy
For example :
php bin/magento setup:static-content:deploy en_US fr_FR
If no language is done after static deploy, only default language is deployed