2

When I try to Flush catalog images cache I get the following error

The file

/home/shaffersuiting/public_html/project/pub/media/catalog/product/cache/1/swatch_image/30x20/beff4985b56e3afdbeabfc89641a4582/i/n/inqalab_final_colour_08.jpg

Cannot be deleted

Warning!unlink(/home/shaffersuiting/public_html/project/pub/media/catalog/product/cache/1/swatch_image/30x20/beff4985b56e3afdbeabfc89641a4582/i/n/inqalab_final_colour_08.jpg): Permission denied

All my folders/files have 775 permission

Help required urgently

Chirag Patel
6,1662 gold badges26 silver badges66 bronze badges
asked Jan 13, 2018 at 19:57

2 Answers 2

1

Check permissions and ownership of this exact file:

/home/shaffersuiting/public_html/project/pub/media/catalog/product/cache/1/swatch_image/30x20/beff4985b56e3afdbeabfc89641a4582/i/n/inqalab_final_colour_08.jpg

Try deleting it manually and clearing image cache again.

It you can't delete it manually, I presume 2 situation might have caused such behaviour:

  1. you deployed static files with root privilages - so all files in your /pub/ folder have root owner and can't be deleted by the Magento file system owner.

  2. Your web server is missconfigured so the Magento file system owner doesn't have write permissions on these files - in this situation as a quick fix you'd need to give 777 permission to all your files, which is a bad idea overall.

The 1st situation is more likely, so you'd need to run:

sudo chown file_system_owner:file_system_owner /home/shaffersuiting/public_html/project/pub/ -R

Where "file_system_owner" is the owner of Magento root.

answered Jan 13, 2018 at 20:37
5
  • I can delete them manually, but when i refresh the folder from Cpanel they appear again ... any thoughts on that? Commented Jan 13, 2018 at 21:03
  • That's just a visual bug in cpanel. You didn't actually delete the file, since you don't have permissions to do so. If you have access to the command line, you should try the command I mentioned. Commented Jan 13, 2018 at 21:06
  • I did it and now i'm getting this errorFatal error: Uncaught Zend_Cache_Exception: cache_dir "/home/shaffersuiting/public_html/project/var/page_cache" is not writable in /home/shaffersuiting/public_html/project/vendor/magento/zendframework1/library/Zend/Cache.php:209 Stack trace: #0 Commented Jan 13, 2018 at 21:08
  • Fixed ... i defined the wrong user name in command ... after changing it with right user name the issue is resolved ... Thanks Commented Jan 13, 2018 at 21:35
  • No problem, glad I could help Commented Jan 13, 2018 at 21:36
0

It is happened due to permission issue. change the permission by using below command.

sudo chmod -R 777 .
answered Jan 14, 2018 at 7:20

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.