nginx/HHVM 404, $document_root를 절대 경로로 바꾸는 문제가 수정되었지만 리디렉션은 URL에 경로를 추가합니다.

nginx/HHVM 404, $document_root를 절대 경로로 바꾸는 문제가 수정되었지만 리디렉션은 URL에 경로를 추가합니다.

설명된 것과 동일한 문제가 발생했습니다.이 문제$document_root이를 절대 경로로 바꾸는 솔루션은 다음과 같이 리디렉션이 URL에 절대 경로를 추가할 때까지 작동합니다.

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

나는 답답한 마음에 머리카락을 잡아당기려고 했다. 대머리가 되지 않도록 도와주세요. (머리 정리 자체가 귀찮긴 하지만 요점은 알겠습니다)

$ 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;
}

답변1

지시어 root가 내부적으로 정의되어 있어 location문제가 발생합니다.

root레벨에서 지시문을 직접 정의하면 hhvm.conf에서도 사용할 수 있는 server변수의 올바른 값이 설정됩니다 .$document_root

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;
}

그러면 귀하의 콘텐츠를 수정할 필요가 없습니다 hhvm.conf.거기도 청소 좀 하고 있어.

관련 정보