HHVM is an open-source virtual machine designed for executing programs written in Hackand PHP. HHVM uses a just-in-time (JIT) compilation approach to achieve superior performance while maintaining the development flexibility that PHP provides.
HHVM runs much of the world’s existing PHP. Developers and hosts are adopting HHVM.Rather than directly interpret or compile PHP code directly to C++, HHVM compiles Hack and PHP into an intermediate bytecode. This bytecode is then translated into x64 machine code dynamically at runtime by a just-in-time (JIT) compiler. This compilation process allows for all sorts of optimizations that cannot be made in a statically compiled binary, thus enabling higher performance of your Hack and PHP programs.
If you already have Nginx and php-fpm running you could easily install hhvm and repoint so that all php pages are executed on hhvm delivering faster content.
Below are the steps to install and configure hhvm to work with nginx.
- apt-key adv –recv-keys –keyserver hkp://keyserver.ubuntu.com:80 0x5a16e7281be7a449
- add-apt-repository “deb http://dl.hhvm.com/ubuntu $(lsb_release -sc) main”
- apt-get update
- apt-get install hhvm
- update-rc.d hhvm defaults
- vi /etc/hhvm/server.ini
- remove line hhvm.server.port
- add below
- service hhvm restart
- vi /etc/nginx/hhvm.conf
- make sure fastcgi line looks like below
1fastcgi_pass <span class="highlight">unix:/var/run/hhvm/hhvm.sock</span>;
- service nginx restart
- Run php –version and check the output, it should return HHVM.
- Now make separate config file in /etc/nginx/sites-available and symlink to /etc/nginx/sites-enabled to make your site up and running.
- Remember to comment out lines as shown below and include hhvm.conf in your virtual host files.