Install HHVM and NGINX on debian

Facebook recently released hhvm with fast-cgi support. This post will show you how you can set this up yourself.

Install hhvm

$ echo deb wheezy main | tee /etc/apt/sources.list.d/hhvm.list
$ apt-get update
$ apt-get install hhvm-fastcgi

Start hhvm-fastcgi at boot

$ update-rc.d hhvm-fastcgi defaults

Install nginx

$ echo deb wheezy nginx | tee /etc/apt/sources.list.d/nginx.list
$ wget
$ apt-key add nginx_signing.key && rm nginx_signing.key
$ apt-get update
$ apt-get install nginx

Configure nginx

upstream hhvm {

server {
    listen 80;

    server_name _;
    root /var/www/;

    error_log /var/log/nginx/site.error.log;
    access_log /var/log/nginx/site.access.log;

    rewrite ^/index\.php/?(.*)$ /$1 permanent;

    location / {
        index index.php app.php;
        try_files $uri @rewriteapp;

    location @rewriteapp {
        rewrite ^(.*)$ /index.php/$1 last;

    # pass the PHP scripts to FastCGI server from upstream phpfcgi
    location ~ \.php(/|$) {
        fastcgi_pass hhvm;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param  HTTPS off;

Fork me on GitHub