0

I'm use Symfony 3.2 with LiipImagineBundle 1.8.0 and Nginx with php7 fpm in production. In desenv the webserver is the php built-in server. In desenv works fine and cache dir are created in web folder, but in production not and Symfony return 404 for images. Any idea what that might be? This is my configuration:

Nginx

location / {
    try_files $uri @rewriteapp;
}

location @rewriteapp {
    rewrite ^(.*)$ /app.php/$1 last;
}

location ~ ^/app\.php(/|$) {

    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    fastcgi_split_path_info ^(.+\.php)(/.*)$;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
    fastcgi_param DOCUMENT_ROOT $realpath_root;
    internal;
}

location ~ \.(png|jpeg|jpg|gif)$ {
    if (-f $request_filename) {
        expires 18h;
        add_header Cache-Control "public, must-revalidate, proxy-revalidate";
        access_log off;
    }

    try_files $uri @rewriteapp;
}

Symfony Config

liip_imagine:
    resolvers:
        default:
            web_path:
                web_root: "%kernel.root_dir%/../web"
                cache_prefix: "media/cache"


    filter_sets:
        cache: ~

        slide:
            quality: 80
            filters:
                thumbnail: { size: [364, 244]}
                watermark:
                    image: Resources/data/logo.png
                    size: 0.2
                    position: bottomleft

Symfony Routing

_liip_imagine:
    resource: "@LiipImagineBundle/Resources/config/routing.xml"

Twig filter use

<img src="{{ asset( 'bundles/app/uploads/' ~ image.id ~ '/' ~ image.file )  | imagine_filter('slide')  }}" />

Permissions in media folder created by me.

drwxrwxrwx+  3 root     root  4096 Aug 15 19:05 media

1 Answers1

0

I found the problem.

In config the correct value of cache_prefix must contais traling slashe

liip_imagine:
    resolvers:
        default:
            web_path:
                web_root: "%kernel.root_dir%/../web"
                cache_prefix: "/media/cache"