4
votes

I am having issues with getting the PGSQL extension working in HHVM 3.1.0, on Ubuntu Trusty 14.04 (LTS), with NGINX.

#hhvm --version
HipHop VM 3.1.0 (rel)
Compiler: tags/HHVM-3.1.0-0-g71ecbd8fb5e94b2a008387a2b5e9a8df5c6f5c7b
Repo schema: 88ae0db264d72ec2e2eb22ab25d717214aee568b

Following the instructions here, https://github.com/PocketRent/hhvm-pgsql I edit my /etc/hhvm/php.ini file, and add the following:

DynamicExtensionPath = /data/config/etc/hhvm/extensions/
DynamicExtensions {
    * = pgsql.so
}

but I get an error when starting HHVM :

 # service hhvm restart
 * Restarting HHVM FastCGI Daemon hhvm
 syntax error, unexpected JUNK, expecting $end or TC_SECTION or TC_LABEL or END_OF_LINE in /etc/hhvm/php.ini on line 13\n
 syntax error, unexpected JUNK, expecting $end or TC_SECTION or TC_LABEL or END_OF_LINE in /etc/hhvm/php.ini on line 13\n

My php.ini looks like this

; php options

; hhvm specific
hhvm.log.level = Warning
hhvm.log.always_log_unhandled_exceptions = true
hhvm.log.runtime_error_reporting_level = 8191
hhvm.mysql.typed_results = false


; hhvm.dynamicextensions.pgsql = /data/config/etc/hhvm/extensions/pgsql.so

DynamicExtensionPath = /data/config/etc/hhvm/extensions/
DynamicExtensions {
    * = pgsql.so
}

You can see I have also tried the following based on the info I have seen about moving from hdf to an ini file:

hhvm.dynamic_extensions.pgsql = /data/config/etc/hhvm/extensions/pgsql.so

which does not throw any errors on startup, but does not render true when running PHP code

if (extension_loaded('pgsql')) {

The pgsql.so comes from the pre-built binary here https://github.com/PocketRent/hhvm-pgsql/tree/releases/3.1.0/ubuntu/trusty, to ensure it matches the Ubunntu / HHVM version I am using.

Can anyone help out here and tell me what is going on?

Thanks!

2

2 Answers

6
votes

You cannot currently load extensions into HHVM using the INI format (hhvm.dynamic_extensions.pgsql or extension). You have to use the Hdf format for this.

The easiest way to do this so that it works from both the web and the CLI is to create /etc/hhvm/config.hdf and add:

DynamicExtensionPath = /data/config/etc/hhvm/extensions
DynamicExtensions {
    * = pgsql.so
}

Then, edit /etc/default/hhvm and uncomment the ADDITIONAL_ARGS line and change it to ADDITIONAL_ARGS="-c /etc/hhvm/config.hdf". Restart HHVM and it should then be picked up.

The CLI automatically tries to load this file, so you don't need to do anything extra there (unless you're passing in a -c option, then you'll need to pass in the config.hdf file too)

2
votes

As per the updated documentation (https://github.com/PocketRent/hhvm-pgsql), you can simply add a couple of lines to hhvm's PHP.INI in the latest versions of hhvm.

hhvm.dynamic_extension_path = /path/to/hhvm/extensions
hhvm.dynamic_extensions[pgsql] = pgsql.so