Skip to content

Running HipHop VM

Paul Tarjan edited this page May 29, 2013 · 17 revisions

Hello World

First, create hello.php:

echo -e "<?php\necho 'Hello from Hiphop';" > hello.php

Next, run hhvm as a server (if you installed from source it is in hphp/hhvm/hhvm):

sudo hhvm -m server ./

And it is that easy:

curl localhost/hello.php

Set port number

If you want to set a port number, add -p option as below.

hhvm -m server -p 8000 ./

Pre-compiling

To get some more performance (10% - 25%) out of your scripts, you can pre-compile them. First, create an .hhbc file:

hhvm --hphp -thhbc -l0 -k1 -o some_dir file1.php file2.php

Now you will have a pre-compiled database in some_dir/hhvm.hhbc. This is similar to a java .jar or a python .par. It is a stand-alone version of your scripts. To run that program (where file1.php contains the code to execute first):

hhvm -vRepo.Authoritative=true -vRepo.Central.Path=some_dir/hhvm.hhbc file1.php

Note: If you get Unable to find/load systemlib.php, make sure you are pointing at the hhvm.hhbc file, and not the directory.

More options

For more complicated setups, you'll want to create a config.hdf file. See the documentation for possible options. Then run it like:

hphp/hhvm/hhvm -m server -c config.hdf
Clone this wiki locally