2017-08-06 13 views
1

私は(html/webhtml/pmaが追加ルートで、デフォルトである)複数のルートについて、次のnginxの設定を持っている:開かれ、デフォルト/html/web/index.phpで、nginxの複数のルート設定問題

server { 

     listen 443 http2 ssl; 
     listen [::]:443 http2 ssl; 

     server_name website.com; 
     server_tokens off; 

     root /usr/share/nginx/html/web; 
     index index.php; 

     location/{  
      try_files $uri /index.php?$args; 
     } 

     location ^~ /pma { 
      root /usr/share/nginx/html; 

      location ~ \.php$ { 
      try_files $uri =404; 
        fastcgi_split_path_info ^(.+\.php)(/.+)$; 
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; 
        fastcgi_index index.php; 
        include fastcgi_params; 
      } 

     } 


     location ~ \.php$ { 
      try_files $uri =404; 
      fastcgi_split_path_info ^(.+\.php)(/.+)$; 
      fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock; 
      fastcgi_index index.php; 
      include fastcgi_params; 
     } 
    } 

のでしかしwebsite.com/pmaはどこ/html/pma/pma開きますPHPMyAdminです。

問題がある:

PHPMyAdminの真偽の形態は、index.phpにリダイレクトします。したがって、資格情報を書き込むと、私は/html/web/index.phpにリダイレクトされます!しかし、/html/pma/index.phpする必要があります。 PHPMyAdminからのログアウトでさえ、/html/web/index.phpにリダイレクトされます!

誰かがより良い設定方法を提案できますか?

+0

私はPMAは使用しませんが、 'PmaAbsoluteUri'を'/pma/'を指すように設定しましたか? [このリンク](https://docs.phpmyadmin.net/en/latest/config.html#basic-settings)を参照してください。 –

+0

'index'を' location'sの外側に移動します。 http://nginx.org/en/docs/http/ngx_http_index_module.html#index – Deadooshka

+0

@Deadooshka助けてくれませんでした。質問で編集 – Leeloo

答えて

0

設定に2つのエラーがあります。

お客様は/index.phpまたは=404のいずれかで終了する必要があります。詳細については、this documentを参照してください。

ネストされたlocation ~ \.php$ブロックは決して照会されません。外部location ~ \.php$ブロックが優先されます。この問題は、周囲の接頭辞location^~修飾子を使用して解決できます。詳細はthis documentを参照してください。例:

location ^~ /pma { 
    ... 
    location ~ \.php$ { 
     ... 
    } 
} 
location ~ \.php$ { 
    ... 
} 
+0

ありがとう、私はあなたの答えをチェックします。あなたはどのようにtry_filesを書くことを提案しますか? – Leeloo

+0

'/ index.php'のパスが常に存在すると仮定すると、**最初の' 'try_files'文の' = 404'は冗長です。 'try_files $ uri /index.php?$ args'を使用してください。 '$ uri /'という言葉は、あなたの書き換えルールに対して働くので、私は確信していません。その目的は、ディレクトリが存在すれば末尾に '/'を追加することです。 –

+0

私はそれをまったく削除すべきですか? – Leeloo

関連する問題