I have set up apache 2.4 with HHVM 3.1.0 (nightly) on ubuntu 13.10 For some reason the server serves the hhvm files (.php) correctly, but when I try to load a .html/.css or any other static file it initiates a download instead of showing

I asked this question on stackoverflow but it was put on hold because it is server related: Original Post

My HHVM server.ini looks like this:

hhvm.server.port = 9000
hhvm.server.type = fastcgi
hhvm.server.default_document = index.php
hhvm.server.source_root = /var/www

hhvm.enable_static_content_from_disk = true

And apache2.conf contains the following proxypassmatch:

ProxyPassMatch ^/(.*.php(/.*)?)$ fcgi://$1

Any advice?

  • Anyone? I want to get this working for my Bachelor Thesis – Marc Went Apr 10 '14 at 12:27

The ProxyPassMatch directive is for routing only certain traffic (i.e. requests for php files) to the FastCGI server (i.e. HHVM). Use the ProxyPass directive instead:

ProxyPass / fcgi://

According to the documentation, that should route all requests to the FastCGI server.

Edit: okay, in response to your comment, ProxyPassMatch is the directive you want to use then.

Instead of going back and forth with you on how you have everything set up, I'll just explain how I set it up on Ubuntu 12.04 and maybe you can figure out what you're missing.

First of all, I am using the old .hdf config format even though I'm running HHVM v3.1.0-dev because I can't seem to get the access log working in the new .ini format. I tried hhvm.log.access.file = /var/log/hhvm/access.log but it didn't work. That's an important log for troubleshooting, so I'm going to stick with .hdf for now.

Here's my upstart script:

description "HipHop VM server"

start on filesystem or runlevel [2345]
stop on runlevel [!2345]

respawn limit 10 5
umask 002

pre-start script
    mkdir -p -m0755 /var/run/hhvm
    chown apachetwo:threews /var/run/hhvm
end script

# Location of executable
env SERVER=/usr/local/sbin/hhvm

exec $SERVER --mode daemon -c /etc/hhvm/test.hdf --user apachetwo

Whenever I want to stop and start HHVM, I use sudo stop hhvm and sudo start hhvm.

Here's my /etc/hhvm/server.hdf file:

PidFile = /var/run/hhvm/pid

Server {
  Type = fastcgi
  Port = 9000
  SourceRoot = /var/www/html/
  DefaultDocument = index.php

Log {
  Level = Verbose
  AlwaysLogUnhandledExceptions = true
  RuntimeErrorReportingLevel = 8191
  UseLogFile = true
  UseSyslog = false
  File = /var/log/hhvm/error.log
  Access {
    * {
      File = /var/log/hhvm/access.log
      Format = %h %l %u % t \”%r\” %>s %b

Repo {
  Central {
    Path = /var/log/hhvm/.hhvm.hhbc

  TypedResults = false

Theoretically, an equivalent config file in the new .ini format would look something like this:

; php options
pid = /var/run/hhvm/pid

; hhvm specific
hhvm.server.type = fastcgi
hhvm.server.port = 9000
hhvm.server.source_root = /var/www/html
hhvm.server.default_document = index.php

hhvm.log.level = Verbose
hhvm.log.always_log_unhandled_exceptions = true
hhvm.log.runtime_error_reporting_level = 8191
hhvm.log.use_log_file = true
hhvm.log.use_syslog = false
hhvm.log.file = /var/log/hhvm/error.log
hhvm.log.access.file = /var/log/hhvm/access.log
hhvm.log.access.format = %h %l %u % t \”%r\” %>s %b

hhvm.repo.central.path = /var/log/hhvm/.hhvm.hhbc
hhvm.mysql.typed_results = false

And, here's an example VirtualHost file based on one of my sites that's configured to proxy requests for PHP scripts to HHVM. This happens to be for a Laravel 4.2.x site with clean URLs via mod_rewrite. If your site is also configured for clean URLs, be sure that you have [PT] at the end of the RewriteRule line so that mod_rewrite will pass the request through to mod_proxy after it's done with it. Initially, I was using [L] (perhaps in error) and couldn't figure out why mod_proxy wasn't passing the request to HHVM.

<VirtualHost *:80>

    ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://$1

    DirectorySlash On
    DirectoryIndex index.php

    ServerAdmin admin@site.com
    ServerName www.site.com
    DocumentRoot /var/www/site.com/htdocs/public/

    AllowEncodedSlashes On

    # Don't display the ServerAdmin email address on server generated pages
    ServerSignature Off

    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !^(index\.php|/images|/includes|/cache|/mpd|/packages|/queues|/samples|/robots\.txt|/sitemap\.xml)
    RewriteRule ^(.*)$ /index.php$1 [PT]

    <Directory /var/www/site.com/htdocs>
        Require all granted
        Options +FollowSymLinks
        AllowOverride None

    <Directory /var/www/site.com/htdocs/public>
        Require all granted
        Options +FollowSymLinks
        AllowOverride None

    ErrorLog /var/log/apache2/www.site.com.error.log

    LogLevel alert rewrite:trace6 proxy:trace6

    CustomLog /var/log/apache2/www.site.com.access.log combined


I think those are the main three configuration files that you'll need to focus on. The ProxyPassMatch directive should instruct Apache to proxy requests for PHP files to HHVM. Requests for other file types should be served by Apache as they would be normally. If you can comment out the ProxyPassMatch directive, restart Apache and everything works as it should, then I would be surprised. I'm guessing your Apache is to blame for serving up CSS, JS and HTML files as downloads.

  • But I want only the php to be run through FastCGI, static pages like HTML, CSS and JS don't need to be run through FCGI but can be served directly. But don't know how to set this up. – Marc Went Apr 13 '14 at 19:46
  • Oh, okay. In that case, the ProxyPassMatch directive you're using looks fine as long as /var/www/ is the path to the document root of your virtual host file. To further assist you, I would need to see your entire VirtualHost block. – dcarrith Apr 14 '14 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.