Wednesday, March 15, 2017

How can I process images with php on nginx?

i create thumbnails with laravel and php. With the routing i create the following url:

https://example.org/image/thumbnail/7f5a0b6055cf9da7f5ab7f6f41c14265.jpg

But nginx shows me this error:

404 Not Found

nginx/1.11.9

I think that nginx don't process the .jpg files with php. He only look in the directory and try to find the 7f5a0b6055cf9da7f5ab7f6f41c14265.jpg.

How can I configure nginx to process .jpg files with php?

Sadly, I'am new to nginx. I worked only with apache.

Here is my nginx configuration:

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    include snippets/ssl-params.conf;

    ssl_certificate /etc/letsencrypt/live/example.org/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.org/privkey.pem;

    root /var/www/example.org/public_html/public;

    index index.html index.htm index.php;

    server_name example.org www.example.org;

    access_log  /var/www/example.org/logs/ssl-access.log;
    error_log  /var/www/example.org/logs/ssl-error.log error;

    location ~*  \.(jpg|jpeg|png|gif|ico|css|js|svg)$ {
         expires 365d;
    }

    location ~ \.php$ {
         include snippets/fastcgi-php.conf;
         fastcgi_pass unix:/run/php/php7.0-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }

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

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



via poldixd

Advertisement