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そこも掃除をしています。

おすすめ記事