The problem is that every time you clear your cache or add a new image, Magento wants to create / add directories as the "apache" user, which prevents him from writing generated images when the page loads.
If you run this from the root of your installation every time you visit different pages in Magento (shopping cart, product details page, main page), you should be fine. Other than that, I'm still looking for a fix:
chown -R correctuser:correctgroup media
That should do it.
source
share