2017-10-10 7 views
1

私はdavical(php)Webカレンダーを実行するのに問題があります。 nginxエラーログには、errolログはありません。 \ locationの下のカレンダーはいつでも動作します。しかし、私はカレンダーの下にカレンダーを持っています。/usr/share/nginxの/ HTML /デフォルトNginx - /(ルート)の場所の下にない場合、Cant fin index.php

カレンダーindex.phpのパス:は、/ usr/share/nginxの/ HTML /カレンダー/ davical/htdocsにインデックス\それはある404

デフォルトのサーバーのルートを返します。 PHP

OS:CentOSに7

server { 
    listen 80 default_server; 
    server_name my_domain_name; 
    return 301 https://$server_name$request_uri; 
} 

HTTPS

server { 
    listen 443 ssl http2; 
    server_name my_domain_name; 

    fastcgi_buffers 8 16k; 
    fastcgi_buffer_size 32k; 
    fastcgi_connect_timeout 300; 
    fastcgi_send_timeout 300; 
    fastcgi_read_timeout 300; 

    ssl on; 
    ssl_certificate "/etc/pki/tls/certs/nginx/certificate.pem"; 
    ssl_certificate_key "/etc/pki/tls/certs/nginx/privatekey.pem"; 
    ssl_session_cache shared:SSL:10m; 
    ssl_session_timeout 10m; 
    ssl_session_tickets off; 
    ssl_dhparam "/etc/pki/tls/certs/nginx/dhparam.pem"; 
    ssl_prefer_server_ciphers on; 
    ssl_protocols TLSv1.1 TLSv1.2; 
    ssl_ciphers HIGH:!aNULL:!MD5; 
    resolver 8.8.8.8 8.8.4.4; 
    ssl_stapling on; 
    ssl_stapling_verify on; 
    ssl_trusted_certificate "/etc/pki/tls/certs/nginx/certificate.pem"; 
    add_header Strict-Transport-Security "max-age=31536000;includeSubdomains; preload"; 

    root /usr/share/nginx/html/default; 
    index index.php index.html index.htm; 
    include /etc/nginx/default.d/php-fpm.conf; 

    location /calendar { 
      alias /usr/share/nginx/html/calendar/davical/htdocs; 
    } 

    error_page 404 /404.html; 
     location = /40x.html { 
    } 

    error_page 500 502 503 504 /50x.html; 
     location = /50x.html { 
    } 
} 

のphp-fpm.conf

location ~ \.php$ { 
    try_files $uri =404; 
    fastcgi_param HTTPS on; 
    fastcgi_pass 127.0.0.1:9000; 
    fastcgi_index index.php; 
    fastcgi_param SCRIPT_FILENAME 
    $document_root$fastcgi_script_name; 
    include  fastcgi_params; 
} 

答えて

0

既存のlocation ~ \.php$ブロックは、/usr/share/nginx/html/defaultのルートを提供します。 /calendar URIの下にPHPファイルを処理するには、ネストされたlocationが必要です。

カレンダーアプリはサブフォルダ内で動作するように設計され、これはあなたのために働くことと仮定すると:

location ^~ /calendar { 
    alias /usr/share/nginx/html/calendar/davical/htdocs; 
    index index.php; 

    if (!-e $request_filename) { 
     rewrite^/calendar/index.php last; 
    } 

    location ~ \.php$ { 
     if (!-f $request_filename) { return 404; } 

     include  fastcgi_params; 
     fastcgi_pass 127.0.0.1:9000; 
     fastcgi_param SCRIPT_FILENAME $request_filename; 
    } 
} 

が優先さを取ってから、他のlocation ~ \.php$ブロックを防ぐために^~修飾子を使用します(詳細についてthis documentを参照してください)。 aliasで動作するので、$request_filenameを使用してください。 aliasthis issue参照)でtry_filesを使用しないでください。

関連する問題