HHVM, Nginx and Ubuntu

Home » Linux » HHVM, Nginx and Ubuntu
November 11, 2015 Linux, PHP No Comments

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.

  1. apt-key adv –recv-keys –keyserver hkp://keyserver.ubuntu.com:80 0x5a16e7281be7a449
  2. add-apt-repository “deb http://dl.hhvm.com/ubuntu $(lsb_release -sc) main”
  3. apt-get update
  4. apt-get install hhvm
  5. update-rc.d hhvm defaults
  6. /usr/share/hhvm/install_fastcgi.sh
  7. vi /etc/hhvm/server.ini
  8. remove line hhvm.server.port
  9. add below
  10. service hhvm restart
  11. vi /etc/nginx/hhvm.conf
  12. make sure fastcgi line looks like below
  13. service nginx restart
  14. Run php –version and check the output, it should return HHVM.
  15. Now make separate config file in /etc/nginx/sites-available and symlink to /etc/nginx/sites-enabled to make your site up and running.
  16. Remember to comment out lines as shown below and include hhvm.conf in your virtual host files.NGinx config