0

I want to setup a virtualhost running HHVM to try out the new "Facebook Hack" language. I followed the instructions here on Apache 2.2: https://github.com/facebook/hhvm/wiki/FastCGI

currently hhvm is running like this:

hhvm -m s -vServer.Type=fastcgi -vServer.Port=9001

And my virtualhost config is:

<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.com

    DocumentRoot /home/tijmen/sites/example.com

    php_value engine off

    #<IfModule fastcgi_module>
        Alias /hhvm.fastcgi /home/tijmen/sites/example.com/hhvm.fastcgi
        FastCGIExternalServer /home/tijmen/sites/example.com/hhvm.fastcgi -host 127.0.0.1:9001
        <Directory "/home/tijmen/sites/example.com/">
            <Files "hhvm.fastcgi">
                Order deny,allow
            </Files>
        </Directory>

        RemoveHandler .php

        AddHandler hhvm-hack-extension .hh
        AddHandler hhvm-php-extension .php

        Action hhvm-hack-extension /hhvm.fastcgi virtual
        Action hhvm-php-extension /hhvm.fastcgi virtual
    #</IfModule>

    ErrorLog /home/tijmen/sites/log/example.com-error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel debug

    CustomLog /home/tijmen/sites/log/example.com.log combined


</VirtualHost>

The directory /home/tijmen/sites/example.com is set to chmod 777 to make sure it's writable. Will make it's more secure once this works.

However example.com/index.hh (which exists in /home/tijmen/sites/example.com/index.hh) returns a 404. Nowhere in the logs I can find out what is wrong.

Next to getting this thing running I would like to know what this hhvm.fastcgi file is. Do I have to create it manually? Is it even a physical file? Perhaps even a directory?

I've also asked my question here but the issue is closed: https://github.com/facebook/hhvm/issues/2137

timing
  • 111
  • 1
  • 5

2 Answers2

1

In my case I had to change RemoveHandler .php into:

<FilesMatch "\.ph(p3?|tml)$">                                                                                                                                            
    SetHandler None                                                                                                                                                      
</FilesMatch>                                                                                                                                                            
<FilesMatch "\.phps$">                                                                                                                                                   
    SetHandler None                                                                                                                                                      
</FilesMatch>
timing
  • 111
  • 1
  • 5
0

I'm having this problem as well; I am also using -host instead of -socket (I can't find where hhvm is creating its sock files)...

Regarding your question about "/hhvm.fastcgi": it's the alias's name; think of it like a variable. You can rename it to whatever you'd like. In your case, it's just saving you from having to use "/home/tijmen/sites/example.com/hhvm.fastcgi" multiple times. Source: https://httpd.apache.org/docs/2.2/mod/mod_actions.html#page-header


(2014-03-23) UPDATE:

I think there's a bug in HHVM. I'll need to test more before I submit it, but I got the application to serve *.php files without the 404.

I'm not happy about the workaround, but here it is:

Edit the run-as-user variable in /etc/init.d/hhvm-fastcgi to run as root. Line 30:

# RUN_AS_USER="www-data"
RUN_AS_USER="root"

For reference, here is the bottom of my site's conf:

<IfModule mod_fastcgi.c>
    RemoveHandler application/x-httpd-php
    # FastCGIExternalServer /apache-data/hack/.virtual -socket /apache-data/hack/hhvm.sock -pass-header Authorization -idle-timeout 300
    FastCGIExternalServer /apache-data/hack/.virtual -host 127.0.0.1:9000 -pass-header Authorization -idle-timeout 300

    AddHandler hhvm-hack-extension .hh
    AddHandler hhvm-php-extension .php

    Action hhvm-hack-extension /hhvm_fastcgi virtual
    Action hhvm-php-extension /hhvm_fastcgi virtual

    Alias /hhvm_fastcgi /apache-data/hack/.virtual
</IfModule>

A little information regarding directory structure:

/apache-data/hack - The application's directory. (Inaccessible to the web..)

/apache-data/hack/www - The web root. (Where index.php / index.hh are..)

index.php Contents

<?php
    echo "<!DOCTYPE html><html><head></head><body>";
    echo "Hello World!<br />";
    if (defined('HHVM_VERSION')) echo "Running on HHVM version ". HHVM_VERSION;
    else echo "HHVM is offline.";
    echo "</body></html>";
?>

(2014-03-23) Update 2:

To have the HHVM parse *.hh you must edit the /etc/hhvm/server.hdf file and tell it to do so.

Append to /etc/hhvm/server.hdf:

PhpFile {
    Extensions {
        hphp = application/x-hhvm-php
        hh = application/x-hhvm-php
    }   
}
  • I understand it's an Alias of the path to this hhvm.fastcgi file, but still what is it? The file does not exist, I did not create it. No process seems to create it. So why bother pointing to it? – timing Mar 23 '14 at 02:18
  • @timing: It's not a file--consider it like a variable whose scope is inside the *.conf. Note that had the Action not had the "virtual" modifier appended to the end of it, then Action would required that it physically existed. – Josh Green Mar 23 '14 at 03:26