0

My nginx web server has a lot of lines like this one in its error.log file:

2017/12/30 20:30:00 [error] 5620#5620: *21 connect() to unix:/var/run/hhvm/hhvm.sock failed 
(111: Connection refused) while connecting to upstream, client: xxx.xxx.xxx.xxx, 
server: beauchamp.me, request: "GET /test.php HTTP/1.1", upstream: 
"fastcgi://unix:/var/run/hhvm/hhvm.sock:", host: "www.xxxxxxx.com"

and I am unable to figure out why. hhvm seems to be failing all the time, so my server reverts to using FPM to run PHP pages.

hhvm version: HipHop VM 3.23.2 (rel) 
nginx version: nginx/1.12.2 
apache2 version: version: Apache/2.4.10 (Debian)   (used for FPM fallback) 
Linux version: Debian 8 (Jessie)

And here is my PHP config for nginx:

location ~ \.(hh|php)$ {
    fastcgi_keep_conn on;
    proxy_intercept_errors on;
    error_page 502 = @fpm;

    # try_files $uri /index.php;
    include fastcgi_params;
    fastcgi_pass unix:/var/run/hhvm/hhvm.sock;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_index index.php;
}

location @fpm {
  # try_files $uri /index.php;
  include fastcgi_params;
  fastcgi_pass unix:/var/run/php5-fpm.sock;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  fastcgi_index index.php;
}

and the permissions on the hhvm.sock file:

root@Debian-82-jessie-64-LAMP /var/log/nginx # ls -als /var/run/hhvm/hhvm.sock
0 srwxrw---- 1 www-data www-data 0 Dec 30 18:43 /var/run/hhvm/hhvm.sock

By the way, I rather use Unix sockets than TCP sockets.

UPDATE:

Here is my hhvm server.ini file content:

; php options

pid = /var/run/hhvm/pid

; hhvm specific 

; hhvm.server.port = 9000
hhvm.server.file_socket=/var/run/hhvm/hhvm.sock
hhvm.server.type = fastcgi
hhvm.server.default_document = index.php
hhvm.log.use_log_file = true
hhvm.log.file = /var/log/hhvm/error.log
hhvm.repo.central.path = /var/cache/hhvm/hhvm.hhbc
  • I found HHVM to be unreliable when I tried it about a year ago. It went to fallback quite often. I eventually gave up on it entirely. I suggest you use PHP7, performance is relatively similar. – Tim Dec 30 '17 at 21:44
  • @Tim Thanks Tim for your input! So when using nginx and PHP7, we don't need hhvm anymore? Does WordPress work well on PHP7 as far as you know? – Jean-François Beauchamp Dec 30 '17 at 21:48
  • Yes Wordpress works well on PHP7. HHVM is an alternative PHP interpreter written by Facebook. You have to test it carefully to ensure your themes and plugins work on PHP7. Most will, but the theme I use, an old version of Photocrati, won't work on PHP7. No doubt their new theme does but I haven't gotten around to changing. I also found HHVM much more difficult to update on Amazon Linux, but that's mostly a problem with AL. – Tim Dec 30 '17 at 22:21

1 Answers1

0

You need to do two things:

  1. Configure hhvm to listen on the same socket you specified in the nginx configuration.
  2. Restart hhvm.
Michael Hampton
  • 244,070
  • 43
  • 506
  • 972