We are done installing! Let’s configure things now. Let’s start by creating a upstream conf file for nginx:

nano /etc/nginx/conf.d/upstream.conf

Add the following and save:

upstream php {

server unix:/var/run/hhvm/hhvm.sock;

server unix:/var/run/php5-fpm.sock backup;

}

As you can see, PHP-FPM will be a backup in case HHVM fails.

Now let’s edit Nginx’s HHVM conf file:

nano /etc/nginx/hhvm.confg

Replace “fastcgi_pass 127.0.0.1:9000;” with “fastcgi_pass php;” . It should look like this:

location ~ \.(hh|php)$ {

fastcgi_keep_conn on;

fastcgi_pass php;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

Restart the services with:

service hhvm restart && service php5-fpm restart && service nginx restart

Test with:

curl -I localhost/test.php

Should be a 404 (As the actual test.php doesn’t exist) with these headers:

Server: nginx/1.8.0

X-Powered-By: HHVM/3.9.0

And that’s all! We have latest stable Nginx with latest HHVM in fastcgi with php-fpm fallback!