HHVM is installed and running as a web server (via Proxygen).
- it listens on port 80
- both the default document and 404 document are
- it serves out of
/var/www/public, however the bulk of your code should not be in the public webroot - adding a
public/subdirectory to your project and installing your project to
/var/wwwis the most common approach, described below. More information is available in the documentation.
- additional ini settings can be specified by replacing
$ cd mysite # with a randomly assigned port... $ docker run --name=my_container -v $(pwd):/var/www -d -P hhvm/hhvm-proxygen:latest $ docker port my_container 80 # to find out what port was allocated # ... or, on port 12345 $ docker run --name=my_container -v $(pwd):/var/www -d -p 12345:80 hhvm/hhvm-proxygen:latest
I recommend building your own Docker image derived from this by specifying a new Dockerfile:
FROM hhvm/hhvm-proxygen:latest RUN apt-get update -y && apt-get install -y curl # Install composer RUN mkdir /opt/composer RUN curl -sS https://getcomposer.org/installer | hhvm --php -- --install-dir=/opt/composer # Install the app RUN rm -rf /var/www ADD . /var/www RUN cd /var/www && hhvm /opt/composer/composer.phar install # Reconfigure HHVM ADD hhvm.prod.ini /etc/hhvm/site.ini EXPOSE 80
Deploy the image with your preferred hosting solution; this has been tested with AWS Elastic Beanstalk - simply
eb config; eb init; eb create; eb deploy (see http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-getting-started.html)
Warning: If you are using AWS Elastic Beanstalk to build and deploy the images, it will build your images on the same instances used for serving the site. This may lead to memory issues.
Disabling The Typechecker
HHVM automatically runs the typechecker - this is useful in development, but assuming you have it running in your development workflow and in your CI system, there is not much additional benefit to running it in production, and the increased memory usage can be costly in production. To disable it, add the following to
Errors are written to
stderr, so can be accessed with
docker logs my-container, or
docker logs -f my_container to keep watching.
- specific versions of HHVM are tagged, eg
latestpoints at the latest stable release
- additional tags will be added for future LTS releases of HHVM with Proxygen support, eg
Most popular projects have
index.php in the top level of their source tree, so should be deployed to
/var/www/public - unfortunately, this is generally considered bad practice nowadays because having the root of your webapp publicly accessible makes it very easy to accidentally make things public that you do not mean to - for example, configuration files with database credentials, or your .git directory.
If you are working on a new project, consider a structure like:
myapp/composer.json myapp/composer.lock myapp/vendor/ myapp/public/index.php myapp/src/ # if you don't like PSR-4 myapp/mynamespace/mysubnamespace/ # if you do like PSR-4 `
/var/www instead of
If you agree in principle but dislike the name, you can override the
hhvm.server.source_root path in
/etc/hhvm/site.ini in your container.
For more details, see the documentation.