BimBam
By:
BimBam

Make nginx use PHP-FPM instead of HHVM for specific script

August 2, 2015 2.2k views
WordPress

I am loving HHVM but there is issue with one WP plugin(justified image grid) which uses TIMTHUMB to resize images and this one doesn't seem to play with HHVM.

I am using fallback like this:

http://i.imgur.com/wn3UklV.png

But it doesn't work.

Is it possible to make an exception and make timthumb.php file use only PHP-FPM?

3 Answers

Edit the upstream directive of hhvm and set PHP FPM as a backup server:

upstream hhvm {
    server 127.0.0.1:8000;
    server unix:/run/php5-fpm.sock backup;
}

It works but I think that now it's using PHP for everything. Before it looked like this

upstream hhvm {
        server unix:/var/run/hhvm/hhvm.sock;
}

upstream php {
        server unix:/var/run/php5-fpm.sock;
}
  • It should be like this:

    upstream hhvm {
        server unix:/var/run/hhvm/hhvm.sock;
        server unix:/var/run/php5-fpm.sock backup;
    }
    

i think u can get necessary help by following this: https://bjornjohansen.no/hhvm-with-fallback-to-php

[and it might be best way to use fallback]

  • location ~ .(hh|php)$ {
    fastcgiintercepterrors on;
    error_page 502 = @fallback;

    try_files $uri =404;
    
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    
    fastcgi_keep_conn on;
    
    include         fastcgi_params;
    fastcgi_index   index.php;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param   SERVER_NAME $host;
    fastcgi_pass    127.0.0.1:9000;
    

    }

    location @fallback {

    try_files $uri =404;
    
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    
    include         fastcgi_params;
    fastcgi_index   index.php;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param   SERVER_NAME $host;
    fastcgi_pass    unix:/var/run/php5-fpm.sock;
    

    }

Have another answer? Share your knowledge.