I am not able to add image to magento with the following error.

Can't create directory /home/ccc/public_html/shop/var/generation/Magento/CatalogRule/Model/Indexer/Product/ProductRuleIndexer/.

I am able to save product details data but not the picture. Could anyone advise?


There are no write rights (sorry for the tongue twister) on the var/generation folder or a subfolder.
I usually solve this by running in the command line, in the magento root folder this: sudo chown -R www-data:www-data .

  • my server dont allow me to run the command. I have granted the permission to all app, pub and var folder to have 775 permission. I checked again on the var/generation folder is having the 775 too. Do i need to set to 777?
    – bedum
    Jun 30 '16 at 7:09
  • don't set 777. Make sure the var/generation folder has 775 recursively.
    – Marius
    Jun 30 '16 at 7:10
  • i use Filezilla to do that. In progress now. By the way, is that safe to have 775 permission for all 3 folders app, pub and var ?
    – bedum
    Jun 30 '16 at 7:14
  • Issue is still the same. I have used the Filezilla to do the 775 with recursive for folder var/generation. But the error is still showing
    – bedum
    Jun 30 '16 at 7:20


chmod -R 777 /home/ccc/public_html/shop
  • won't this create any security issue by granting 777?
    – bedum
    Jun 30 '16 at 7:27
  • 1
    Yes. Giving the whole Magento directory 777 permissions is the slegde hammer solution to permission related problems, it's effective, but also can do damage. What's important is that the var directory is writable by the web server. If it belongs to the web server group, chmod -R 770 /home/ccc/public_html/shop/var suffices. Jun 30 '16 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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