Getting Started

If you are new to HHVM, this getting started guide should help get you up an running quickly. Of course, as this is meant to be a getting started, not every detail will be provided here. The main HHVM user guide will be your resource for full information.


The infrastructure you need to run code with HHVM is pretty simple:

  • HHVM itself
  • Some Hack or PHP code

For this setup, although various flavors of Debian and Ubuntu are supported with official packages, the most recent Ubuntu LTS and the most recent Ubuntu stable release are likely to be the best supported and easiest to install.

Install HHVM

Refer to our directions on installing a prebuilt package.

It is of course possible to build HHVM from source, but this is much more complicated and time consuming. For this reason, building from source isn't recommended until you get a basic install working and have a better feel for what you're doing.


After installing HHVM, change to the directory where your code lives, and start up HHVM:

hhvm -m server -p 8080

-m represents the mode and here indicates that HHVM is running in HTTP server mode.

-p configures the TCP port that HHVM uses to listen to HTTP requests. The default port is 80, the standard HTTP port. However, that port requires root access, so for this example, we will use port 8080.

Once you have HHVM running, write a simple "Hello World" program named hello.php:

echo "Hello World!";

Save this hello.php in the same directory that you ran the hhvm command from above. Then, load http://localhost:8080/hello.php in your browser and verify you see "Hello World!" appear.

Configure HHVM

The out-of-the-box HHVM configuration won't need tweaking by most new users. Notably, the JIT compiler that gives HHVM its speed is on by default. If you want to take a look at the configuration used, it's at /etc/hhvm/php.ini.

Running HHVM automatically at boot as a service (instead of just on the command line as above) unfortunately does require some configuration. See the proxygen documentation for details.

Running Hack files

HHVM runs both PHP and Hack. Hack is Facebook's language that extends the syntax of PHP to offer type-checking as well as numerous additional language features. We created a simple Hack program above when testing HHVM.

To test and run a Hack file, make sure you are running the hh_client typechecker otherwise you'll be missing out on a lot of your type errors in your Hack code. The simplest way to make a PHP program a Hack program is to simply change the prologue of the file to <?hh to indicate it's Hack. Then you can immediately start benefiting from these features.

Learning Hack and PHP

Learning to program in PHP or Hack is beyond the scope of this guide. The best resource for doing so is the official Hack documentation and we highly recommend the O'Reilly book on HHVM and Hack, written by an engineer on the HHVM team at Facebook. Hack has an online interactive tutorial as well.

For PHP, PHP's documentation contains an introduction to PHP, and there are numerous tutorials online.