1

I've had the same issue as described in this question, and the solution of replacing $document_root with it's absolute path worked until redirects added the absolute path to the URL, as in:

EXPECTED http://domain/pma/
REALITY  http://domain/var/www/pma/

I'm about to pull my hair out of frustration here. Please help me not become bald. (Although keeping the hair in line is a hassle in itself, but you get the idea)

$ less /etc/nginx/conf.d/default.conf
server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm index.php;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    include hhvm.conf;

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

$ less /etc/nginx/hhvm.conf
location ~ \.(hh|php)$ {
    fastcgi_keep_conn on;
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include        fastcgi_params;
}
Oxwivi
  • 2,232
  • 4
  • 23
  • 31
  • 1
    Could you post your nginx configs? – Mehdi Oct 28 '15 at 14:17
  • try restoring the original hhvm.conf (with `$document_root`), and inside your vhost file, move the root out of `location`, directly under `server`. – Mehdi Oct 28 '15 at 14:19
  • @mef I should've said it directly that it's purely default, virtually identical to the one in the linked question, but there you go. Now to try your suggestion. – Oxwivi Oct 28 '15 at 16:07
  • ok, I just copied the answer I gave to the related question you linked. – Mehdi Oct 28 '15 at 16:41

1 Answers1

1

The root directive is defined inside location, this causes your problem.

Defining the root directive directly at the level of serversets the proper value of variable $document_root, which will also get available inside hhvm.conf.

server {
    listen       80;
    server_name  localhost;

    root   /var/www;

    location / {
        index  index.php index.html index.htm;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    include hhvm.conf;
}

Then, no modification is needed in your hhvm.conf, although you may do some cleanup there too.

Mehdi
  • 160
  • 1
  • 6
  • Thanks for that link, I did intend to eventually look into `sock`. I did it exactly as the guide described but it ain't working. Any idea? I can create a new question about it... – Oxwivi Oct 28 '15 at 17:33
  • check file permissions: nginx must be able to write to the socket (if so, can be fixed with a command similar to: `usermod -a -G www-data nginx`, based on your system usernames) – Mehdi Oct 28 '15 at 18:30
  • According to `ps aux`, `nginx: master` is running as user `root`, and `nginx: worker` as `nginx`. In fact, my `php` files ownership are all non-`nginx` user or group, so I don't think that's the issue. – Oxwivi Oct 28 '15 at 18:45
  • nginx doesn't need to access the php files. It needs to have write access your php5-fpm or hhvm unix socket file. you may want to add nginx user to the group of owners of the socket file. – Mehdi Oct 28 '15 at 18:48
  • It works. I'm going to post a question about so that I can award you reps by accepting your answer. I'll delete all my comments here after that. Also, I once had a working LEMH but utterly failed to enable any debugging options (either showing it on page itself or something like `xdebug`)—would you happen to know of any resource regarding it? – Oxwivi Oct 29 '15 at 16:33
  • Here you go: http://unix.stackexchange.com/questions/239550/how-do-i-configure-unix-socket-in-nginx-hhvm – Oxwivi Oct 29 '15 at 16:40
  • ok, done. You didn't have to. Its not necessary to delete the comments I gues, it could help people facing both problems follow our tracks in solving them. About debugging setup, I'm afraid I can't help. – Mehdi Oct 29 '15 at 20:21