Php – Apache2.4 and HHVM as FastCGI – Different settings per VHost

apache-2.4PHPvirtualhost

I just managed to set up a Apache 2.4 server using HHVM in FastCGI mode using that ProxyPassmatch directive. The problem is, I can now set a differen root path for each host but I can not set any other configuration parameters per VHost, like include_path, error_log or other classic PHP settings…

VHost File:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName host1.local
    DocumentRoot /var/www/host1/root

    ErrorLog ${APACHE_LOG_DIR}/host1_error.log
    CustomLog ${APACHE_LOG_DIR}/host1_access.log combined

    ProxyPassMatch (.php)$ fcgi://127.0.0.1:9000/var/www/host1/root

    # php_value include_path ".:/var/www/host1/includes"
    # php_value error_log "/var/www/host1/log/php_error.log"

    <Directory /var/www/host1/root>
        AllowOverride All
    </Directory>
</VirtualHost>

There are some reports that I can set up virtual hosts in HHVM too, but since Fast-CGI this seems to be deprecated. And even then, I would have to provide VHost settings in a seperate file in addition to my Apache VHost file.

So… How can I provide HHVM with different configurations per VHost?


Update Seems I discuvered a Bug (or missing feature) of HHVM while using the FcgidInitialEnv (or fastcgi_param on Nginx) approach described in the answer.

https://github.com/facebook/hhvm/issues/3730

Best Answer

You can pass parameters through the PHP_VALUE environment variable.

In Apache, you would use the FcgidInitialEnv directive (which is applicable to virtual hosts) to define all parameters in a single line.

FcgidInitialEnv PHP_VALUE "include_path=.:/var/www/host1/includes \n error_log=/var/www/host1/log/php_error.log"
Related Topic