2017-08-15 4 views
1

私はサブディレクトリを扱っています。私は "babylon/webmail"を私のrainloopウェブメールクライアントに行きたいと思う。

location ^~ /webmail { 
    root /srv/rainloop/public_html; 
    try_files $uri $uri/ /webmail/index.php?$query_string; 
    access_log /srv/rainloop/logs/access.log; 
    error_log /srv/rainloop/logs/error.log; 
    index index.php; 
    access_log /var/log/nginx/scripts.log scripts; 

    location ~ \.php$ { 
     #fastcgi_index index.php; 
     #fastcgi_split_path_info ^(.+\.php)(.*)$; 
     #fastcgi_keep_conn on; 
     #include /etc/nginx/fastcgi_params; 
     #fastcgi_pass unix:/var/run/php5-fpm.sock; 
     #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 

     #try_files $uri =404; 
     include fastcgi_params; 
     fastcgi_pass unix:/var/run/php5-fpm.sock; 
     fastcgi_index index.php; 
     #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
     fastcgi_param SCRIPT_FILENAME /srv/rainloop/public_html/index.php; 
     #include fastcgi_params; 
    } 

    location ~ /\.ht { 
     deny all; 
    } 

    location ^~ /webmail/data { 
     deny all; 
    } 
} 

しかし、この

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 

はまったく動作しません。/srv/rainloop/public_html/ウェブメール /index.php;このファイルは、ディレクトリ構造内に存在しますが、しません:

fastcgi_param SCRIPT_FILENAME /srv/rainloop/public_html/index.php; 

/srv/rainloop/public_html/index.php PS:ハードコーディングした後、私はすべてのエラーを得ることはありませんが、ページが空白ですいくつかのレインループコードのソースコードがあります。

答えて

1

rootの値をURIに連結してファイルへのパスを計算します。 URIには/webmail/index.phpが含まれています。そうでない場合は、locationブロックと一致しません。

rootの代わりにaliasを使用するのは、ファイルへのパスを計算するときに、接頭辞locationの値を削除するためです。詳細は、this documentを参照してください。

location ^~ /webmail { 
    alias /srv/rainloop/public_html; 
    if (!-e $request_filename) { rewrite^/webmail/index.php last; } 

    ... 

    location ~ \.php$ { 
     if (!-f $request_filename) { return 404; } 
     include fastcgi_params; 
     fastcgi_param SCRIPT_FILENAME $request_filename; 
     fastcgi_pass unix:/var/run/php5-fpm.sock; 
} 

避けthis long term issueのために、同じブロックにtry_filesaliasを使用して、そしてifの使用にthis cautionを参照してください。 SCRIPT_FILENAME値には$request_filenameを使用してください。

関連する問題