Web Development with HHVM and Hack: Getting Set Up With Windows

Mike Abelar
4 min readMar 4, 2020

--

In this tutorial, we will install HHVM on a Windows machine.

HHVM on Windows

Currently, according to the official documentation, there is no easy way to install HHVM on Windows. However, there is support for installing HHVM on Linux. We are going to use Windows Subsystem for Linux (WSL), which allows us to run Linux applications directly with Windows, to install HHVM for Linux on top of the Windows machine. We will later see in this tutorial how we can develop on a Windows machine and run HHVM in WSL.

WSL 2

To successfully install HHVM on WSL, we are going to need to use WSL version 2. Installing HHVM on WSL version 1 will not work. WSL 2 provides a full Linux kernel, which is required for HHVM to work. WSL 1 works by translating Linux system calls to Windows system calls, which is insufficient for HHVM.

Getting The Right Windows Version

To install WSL 2, you first need Windows 10. Next, you will need a specific version of Windows 10: Windows version build 18917 or higher. You can check your Windows version in the command prompt by running:

ver

For me, I get:

Microsoft Windows [Version 10.0.19569.1000]

This means that my Windows version is build 19569, which is higher than 18917.

If your version is not high enough, first try checking for a Windows update by going to Settings > Update & Security > Windows Update.

If, after updating does not get your version past 18917, then you will need to join the Windows Insider Program. The Windows Insider Program allows you access to more recent and experimental builds of Windows that are not yet available to the public. To join the Windows Insider Program, follow the instructions at this link. Once you join the Windows Insider Program, check for updates on your Windows machine and download them. After these updates, your Windows version should be above 18917.

Installing WSL 2

To install WSL 2, we will follow the first two steps from the official Windows Tutorial for installing WSL:

Open PowerShell as Administrator and run:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Restart your computer when prompted.

We will then follow the first two steps from the official WSL 2 Installation tutorial:

Open PowerShell as Administrator and run:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Followed by:

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Then, restart your computer.

Next, open the command prompt and enter the following command:

wsl --set-default-version 2

Next, we will install a Linux distribution. Go to the Microsoft Store on your Windows machine and search for “Ubuntu”. Pick any Ubuntu version you like. I use the app titled just “Ubuntu” (not “Ubuntu 18.04 LTS” for example). Download the app. It should look like this:

Next, open the Ubuntu app you just installed. It will take a few minutes for the Ubuntu app to initialize. Once it does, you will be asked to provide a username and a password. Once you enter that information, go to your command prompt (not Ubuntu app) and verify you are using WSL version 2:

wsl -l -v

For me, it outputs:

Ubuntu Stopped 2

You should verify that the number at the end is 2. Don’t worry about the word “Stopped”. Once you have that, you are now ready to install HHVM for Linux.

Installing HHVM on Ubuntu

Now that we have a Ubuntu app on our Windows machine, we can install HHVM for the Ubuntu app. To do so, we will follow the official Linux installation tutorial for Ubuntu. We will download the latest stable release.

To do so, open your Ubuntu app and type:

sudo apt-get update

Then

sudo apt-get install software-properties-common apt-transport-https

Then

sudo add-apt-repository https://dl.hhvm.com/ubuntu

Then

sudo apt-get update

And Finally:

sudo apt-get install hhvm

After you run these commands, verify that your HHVM works by typing:

hhvm

You should get the following output:

Nothing to do. Either pass a hack file to run, or use -m server.

Success! You have installed HHVM on Windows!

Developing With Windows

Now that you have HHVM installed, here is how you can develop web applications with HHVM:

In your Ubuntu app, type:

cd /mnt/c

This will bring you to your C drive on Windows (may need to change c to match the drive you currently use on Windows). Then, you can navigate to any folder on your Windows machine in the Ubuntu app by using cd. The Ubuntu app can interact with any Windows folder. Therefore, on the Ubuntu app, you can then create files using the touch command, for example.

To develop a Hack project on your Windows machine, you can create a folder for your Hack project. You can use your favorite IDE or text editor to work on this project. Then, when you are ready to run the Hack project, go to the Ubuntu app and run your HHVM commands.

--

--