2017-08-16 95 views
0

我使用Symfony 3.2與LiipImagineBundle 1.8.0和Nginx與生產中的php7 fpm。在desenv中,webserver是php內置的服務器。在desenv工作正常和緩存目錄在Web文件夾中創建,但在生產不,並且Symfony返回404圖像。任何想法可能是什麼?這是我的配置:Symfony 3.2與LiipImagineBundle不創建文件夾媒體/緩存

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的配置

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路由

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

嫩枝過濾器的使用

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

權限在媒體文件夾我創建。

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

OS的什麼(Ubuntu的)? –

+0

@ImanaliMamadiev是的,Ubuntu 16.04在Digital Ocean vm。 –

+0

asset('bundles/app/uploads /'〜image.id〜'/'〜image.file)| imagine_filter('slide')它在html源代碼中的外觀如何? –

回答

0

我發現了這個問題。

在配置cache_prefix的正確值必須contais traling slashe

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