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://127.0.0.1:9000/var/www/$1
Any advice?
Best Answer
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:
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:
Whenever I want to stop and start HHVM, I use
sudo stop hhvm
andsudo start hhvm
.Here's my /etc/hhvm/server.hdf file:
Theoretically, an equivalent config file in the new
.ini
format would look something like this: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 theRewriteRule
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.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.