hhvm is a virtual machine for executing programs in PHP (and HACK). It provides great performance with the flexibility of PHP, it uses a just-in-time (JIT) compiler which applies several optimizations that can boost our applications. You really will notice the difference.
It can be configured as a CGI server (as PHP-FPM), but we have one freat drawback in my opinion: it’s not (in march 2014) as stable as I’d like. I have encoutered some bugs that make me doubt if I would use it in production. Also it’s not pure PHP so many things won’t work (Facebook is doing a great job to support lots of common frameworks, but still in progress)
But, for testing purposes it’s ok, so let’s install it. It’s better to go here for installation instructions in many distributions. Then install hhvm-fastcgi package which will make hhvm run as a FastCGI daemon.
Then, edit you VirtualHost file (using the example here as base, and putting in bold changes):
<VirtualHost *:80> ServerAdmin firstname.lastname@example.org ServerName totaki.com ServerAlias www.totaki.com DocumentRoot /home/cloud/www/totaki.com/www <Directory /> Options FollowSymLinks AllowOverride All </Directory> <IfModule mod_fastcgi.c> AddHandler hhvm-fcgi .php Action hhvm-fcgi /hhvm-fcgi Alias /hhvm-fcgi /usr/bin/hhvm FastCgiExternalServer /usr/bin/hhvm -host 127.0.0.1:9000 -pass-header Authorization -pass-header Content-type </IfModule> <Directory /home/cloud/www/totaki.com/www/> Options FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> ErrorLog "/home/cloud/www/totaki.com/logs/error.log" LogLevel warn CustomLog "/home/cloud/www/totaki.com/logs/access.log" combined </VirtualHost>
And that’s it, restart Apache and your next page will be loaded by hhvm. With this configuration, you can easily switch between hhvm and PHP-FPM, so if hhvm gives you any problem, you can disable it.