1

I'm running Drupal 8.5.3 on Centos7 with Nginx + PHP7 + PHP 7 FPM After successfully running Drupal installation, i want add a article but image thumbnai return 404 error. The image upload to sites/default/files folder but image style folder can not create. My drupal staus and Error 404 image style after upload image for article

This is my nginx config

server {
        listen 80;

        # access_log off;
        access_log /home/drupal8.mds.com.vn/logs/access.log;
        # error_log off;
        error_log /home/drupal8.mds.com.vn/logs/error.log;

        root /home/drupal8.mds.com.vn/public_html;
        index index.php index.html index.htm;
        server_name drupal8.mds.com.vn;

        # Custom configuration
        include /home/drupal8.mds.com.vn/public_html/*.conf;

        location / {
                #try_files $uri $uri/ /index.php?$args;
                try_files $uri /index.php?$query_string;
        }

        location ~ '\.php$|^/update.php' {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                #fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
                #fastcgi_split_path_info ^(.+\.php)(/.+)$;
                include /etc/nginx/fastcgi_params;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_connect_timeout 300;
                fastcgi_send_timeout 300;
                fastcgi_read_timeout 300;
                fastcgi_buffer_size 32k;
                fastcgi_buffers 8 16k;
                fastcgi_busy_buffers_size 32k;
                fastcgi_temp_file_write_size 32k;
                fastcgi_intercept_errors on;
                fastcgi_param SCRIPT_FILENAME home/drupal8.mds.com.vn/public_html$fastcgi_script_name;
    }
        location ~ /\.(?!well-known).* {
                deny all;
                access_log off;
                log_not_found off;
        }

        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }

        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }
       location ~* \.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|is$
                gzip_static off;
                add_header Pragma public;
                add_header Cache-Control "public, must-revalidate, proxy-revalidate";
                access_log off;
                expires 30d;
                break;
        }

        location ~* \.(txt|js|css)$ {
                add_header Pragma public;
                add_header Cache-Control "public, must-revalidate, proxy-revalidate";
                access_log off;
                expires 30d;
                break;
        }

     location ~ \..*/.*\.php$ {
        return 403;
    }

    location ~ ^/sites/.*/private/ {
        return 403;
    }
    location ~* ^/.well-known/ {
        allow all;
    }

    location ~ (^|/)\. {
        return 403;
    }

    location @rewrite {
        rewrite ^/(.*)$ /index.php?q=$1;
    }

    location ~ /vendor/.*\.php$ {
        deny all;
        return 404;
    }
     location ~ ^/sites/.*/files/styles/ { # For Drupal >= 7
        try_files $uri @rewrite;
    }

    location ~ ^(/[a-z\-]+)?/system/files/ { # For Drupal >= 7
        try_files $uri /index.php?$query_string;
    }
    location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
        try_files $uri @rewrite;
        expires max;
        log_not_found off;
    }

}

For drupal 7 i have same issue but i can hack core in modules/image function image_style_url($style_name, $path){

  //Create derivated image if not exist ductm add
  if(!file_exists($file_url) && !file_exists($uri)){
    if(file_exists($path)){
      $currentStyle = image_style_load($style_name);
      image_style_create_derivative($currentStyle, $path, $uri);
    }
  }

  return $file_url;

permission nginx user sites/default/files/styles

ductm
  • 11
  • 4

1 Answers1

0

As best i know for figure out this issue you should check below parameters :

Walking through | :

Check the folder also sub-folder permissions , make sure upload folder have enough permission 0755 .

Check the below directories for find out more what's happening when you reach 404 not found page in Logs :

/var/log/nginx/*

/var/logs/nginx/* 
Nathanael
  • 17
  • 6
  • thanks for your answer! yes my upload folder have enough permission.and in error log file of website: failed (2: No such file or directory) – ductm May 20 '18 at 00:38
  • You are welcome .! try with create which directory has been missed , you will found them in error_log so far as you stated above here ... – Nathanael May 20 '18 at 17:25
  • I created folder ../styles/thumbnail/public/2018-05/ and set permission 0755 then try to add new image for article. image can not upload to this folder :( – ductm May 21 '18 at 07:52