2017-02-08 12 views
0

только что установил стек LEMP на CentOS 7, который включает в себя PHP 7 .. Я загрузил проект Symfony 3, и моя проблема в том, что когда я пытаюсь получить доступ к маршрутам, он говорит только о ошибке внутреннего сервера , например: когда я перенаправлен на /login на fos_user_bundle, есть внутренняя ошибка сервера. Я смотрел на журналы ошибок, и они ищут так: 2017/02/08 11:51:35 [error] 488#0: *1 rewrite or internal redirection cycle while internally redirecting to "/index.html", client: <ip address>, server: mydomain.ge, request: "GET /foldername/web/app_dev.php/login HTTP/1.1", host: "mydomain.ge" nGinx выбрасывает ошибку внутреннего сервера при отправке маршрутов

server { 
    listen 80; 

    root /var/www/html; 
    index index.php index.html index.htm; 
    server_name mydomain.ge <server ip address>; 

    location/{ 
     try_files $uri $uri/ /index.html; 
    } 

    error_page 404 /404.html; 
    error_page 500 502 503 504 /50x.html; 
    location = /50x.html { 
     root /usr/share/nginx/www; 
    } 

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

и мой конфигурационный файл (example.conf) выглядит следующим образом выше.

Любые идеи?

+0

Если не было найдено ни один из файлов, внутренний редирект Ури, указанным в последнем параметре производится. http://nginx.org/en/docs/http/ngx_http_core_module.html#try_files –

ответ

0

Если вы хотите, чтобы /login обрабатывался index.php, вам необходимо добавить index.php в файлы try.

try_files $uri $uri/ /index.php; 
0

решаемые Я посмотрел официальную документацию Symfony и обнаружили конфигурацию по умолчанию для фреймворка приложений на Nginx, я скопировал и вставил в мой example.conf вместо старых настроек, это сработало! так, теперь мой example.conf выглядит следующим образом

server { 
    server_name mydomain.ge www.mydomain.ge <server ip>; 
    root /var/www/html/projectname/web/app_dev.php; 

    location/{ 
     # try to serve file directly, fallback to app.php 
     try_files $uri /app.php$is_args$args; 
    } 
    # DEV 
    # This rule should only be placed on your development environment 
    # In production, don't include this and don't deploy app_dev.php or config.php 
    location ~ ^/(app_dev|config)\.php(/|$) { 
     fastcgi_pass 127.0.0.1:9000; 
     fastcgi_split_path_info ^(.+\.php)(/.*)$; 
     include fastcgi_params; 
     # When you are using symlinks to link the document root to the 
     # current version of your application, you should pass the real 
     # application path instead of the path to the symlink to PHP 
     # FPM. 
     # Otherwise, PHP's OPcache may not properly detect changes to 
     # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126 
     # for more information). 
     fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; 
     fastcgi_param DOCUMENT_ROOT $realpath_root; 
    } 
    # PROD 
    location ~ ^/app\.php(/|$) { 
     fastcgi_pass 127.0.0.1:9000; 
     fastcgi_split_path_info ^(.+\.php)(/.*)$; 
     include fastcgi_params; 
     # When you are using symlinks to link the document root to the 
     # current version of your application, you should pass the real 
     # application path instead of the path to the symlink to PHP 
     # FPM. 
     # Otherwise, PHP's OPcache may not properly detect changes to 
     # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126 
     # for more information). 
     fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; 
     fastcgi_param DOCUMENT_ROOT $realpath_root; 
     # Prevents URIs that include the front controller. This will 404: 
     # http://domain.tld/app.php/some-path 
     # Remove the internal directive to allow URIs like this 
     internal; 
    } 

    # return 404 for all other php files not matching the front controller 
    # this prevents access to other php files you don't want to be accessible. 
    location ~ \.php$ { 
     return 404; 
    } 

    error_log /var/log/nginx/projectname_error.log; 
    access_log /var/log/nginx/projectname_access.log; 
} 

 Смежные вопросы

  • Нет связанных вопросов^_^