Support » Plugin: Smush Image Compression and Optimization » [Plugin: WP] Wrong Folder

  • I moved my server to nginx (not sure if this has anything to do with it) but I am unable to use smush it.

    When I go to smush it, it says unable to find file.

    It is looking here:


    But the path really should be:


    I tried using /wp-content/uploads and wp-content/uploads in the media path to files. I also set the full server path to be

    Nothing seems to work, it always seems to want to add /var/www/vhosts/ to anything I put in there.

    It used to work great, just install the plugin and forget about it. It just worked.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Any ideas on this?

    It seems like only older posts have this problem, new uploads smush perfectly fine. I have confirmed the media exists and the path is in the same root folder of all the other ones.

    Please post your entire Nginx configuration (without exposing anything important) to check what may have gone with it.

    server {
    listen 8080;
    server_name *;
    root /srv/www/;

    access_log /srv/www/;
    error_log /srv/www/;

    include wordpress.conf;
    include browsercache.conf;
    include drop.conf;
    include php.conf;

    location / {
    index index.php;

    if (-f $request_filename) {

    set $pgcache “”;

    if ($request_method = GET) { set $pgcache “${pgcache}D”; }

    if ($args = “”) { set $pgcache “${pgcache}I”; }

    if ($http_cookie !~ (comment_author_|wordpress|wordpress_logged_in|wp-postpass_)) {
    set $pgcache “${pgcache}S”;
    if (-f $document_root/wp-content/w3tc/pgcache/$request_uri/_index.html) {
    set $pgcache “${pgcache}K”;
    if ($pgcache = “DISK”) {
    rewrite ^ /wp-content/w3tc/pgcache/$request_uri/_index.html break;

    if (!-e $request_filename) { rewrite ^ /index.php last; }

    location /search {
    limit_req zone=wpsearch burst=3 nodelay;
    try_files $uri /index.php;

    # Add trailing slash to */wp-admin requests.
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;

    # Prohibit php files from executing in wp-uploads
    location ~* ^/wp-content/uploads/.*.php$ {
    return 403;

    # enforce www (exclude certain subdomains)
    if ($host !~* ^(www|subdomain))
    rewrite ^/(.*)$ $scheme://www.$host/$1 permanent;

    fastcgi_intercept_errors off;


    # browser cache
    location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
    expires max;
    add_header Pragma public;
    add_header Cache-Control “public, must-revalidate, proxy-revalidate”;


    location = /robots.txt { access_log off; log_not_found off; }
    location = /favicon.ico { access_log off; log_not_found off; }
    location ~ /\. { access_log off; log_not_found off; deny all; }
    location ~ ~$ { access_log off; log_not_found off; deny all; }


    location ~ \.php {
    client_max_body_size 25M;
    try_files $uri =404;
    limit_conn phplimit 5;
    fastcgi_index index.php;

    fastcgi_param QUERY_STRING $query_string;
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param CONTENT_TYPE $content_type;
    fastcgi_param CONTENT_LENGTH $content_length;

    fastcgi_param SCRIPT_FILENAME $request_filename;
    fastcgi_param SCRIPT_NAME $fastcgi_script_name;
    fastcgi_param REQUEST_URI $request_uri;
    fastcgi_param DOCUMENT_URI $document_uri;
    fastcgi_param DOCUMENT_ROOT $document_root;
    fastcgi_param SERVER_PROTOCOL $server_protocol;

    fastcgi_param GATEWAY_INTERFACE CGI/1.1;
    fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

    fastcgi_param REMOTE_ADDR $remote_addr;
    fastcgi_param REMOTE_PORT $remote_port;
    fastcgi_param SERVER_ADDR $server_addr;
    fastcgi_param SERVER_PORT $server_port;
    fastcgi_param SERVER_NAME $server_name;

    fastcgi_param HTTPS $https;

    # PHP only, required if PHP was built with –enable-force-cgi-redirect
    fastcgi_param REDIRECT_STATUS 200;

    fastcgi_pass unix:/var/run/php5-fpm.sock;

    If the error is due to Nginx, there are a couple of ways to troubleshoot…

    1. Try the following line in your php.conf…

    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    in place of…

    fastcgi_param SCRIPT_NAME $fastcgi_script_name;

    2. Check, if your php5-fpm environment has any kind of chroot.

    If both didn’t fix this issue, it is probably not due to Nginx, php5-fpm stack.

    I hope this helps.

    1) Tried it, didn’t solve the problem.

    Errror changed from:




    2) No chroot at all.

    The thing is, many of them work fine and smush without problems, the older stuff though throws this error which looks like it is confusing the path by taking the real path and some made one up (perhaps a default) and combining them into one ridiculous path.

    Hello vampired,

    I was just reading my own answer, and I was meant to ask to replace this line…

    fastcgi_param SCRIPT_FILENAME $request_filename;

    Somehow I copied the next line and pasted in my answer.

    If this doesn’t help either, I’d recommend switching to CW Image Optimizer that requires additional tools in the server, but works without any issues for me. I tried WP after a long time and it does throw a 404 error, but the path to the file was correctly shown by this plugin, in my case.

    Thought something looked weird but I tried it anyway.

    I made the new change, still same problem. It is weird, most of the images work fine, the first 91 pages of images out of 100 smush without problems. The last 9 pages give me this odd path issue where it is appending what looks like a default path to the regular path.

    I tried CW Image Optimizer, and for some reason I couldn’t get it to work with the tools or something.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Plugin: WP] Wrong Folder’ is closed to new replies.