2017-01-19 1 views
0

phpbrew을 사용하여 PHP 7.1로 업그레이드하려고 시도했는데 어디서나 Apache보다 간단하다는 것을 알았 기 때문에 nginx를 사용하여 설치하도록 선택했습니다. , 내 소견에).Symfony2, phpbrew, nginx, php 7.1 및 파일을 찾을 수 없습니다.

nginx에서 Symfony2를 실행하려고 시도한 결과 this doc page이 나타났습니다.이 설정은 nginx에서 Sf2의 기본 구성을 제공합니다.

app_dev.php, 그리고 .php으로 끝나는 모든 파일을 제공하도록 php-fpm을 구성 할 수있었습니다. 그러나 다른 URL (예 : /home)으로 가면 nginx 설정이 중단되고 php-fpmFile not found 오류가 표시됩니다.

app_dev.php 또는 app.php 이후의 모든 것을 허용하도록 nginx 가상 호스트를 구성하려면 어떻게해야합니까 (apache2에서 modrewrite과 같이)? 참조

내 nginx를 파일 :

server { 
    listen 80 default_server; 
    listen [::]:80 default_server ipv6only=on; 

    root /usr/share/nginx/html; 
    index index.html index.htm; 

    server_name localhost; 

    location/{ 
     try_files $uri $uri/ =404; 
    } 

    location /my-app { 
     index web/app_dev.php; 
     try_files $uri /web/app.php$is_args$args; 
    } 

    location /dist { 
     root /usr/share/nginx/html; 
     index depp/index.php; 
     try_files $uri /depp/index.php$is_args$args; 
    } 

    location ~ \.php$ { 
     fastcgi_pass unix:/home/gabriel/.phpbrew/php/php-7.1.0/var/run/php-fpm.sock; 
     fastcgi_split_path_info ^(.+\.php)(/.*)$; 
     include fastcgi_params; 
     fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; 
     fastcgi_param DOCUMENT_ROOT $realpath_root; 
     fastcgi_param REQUEST_URI $uri?$args; 
    } 
} 

답변

0

당신은 들어오는 요청 모두를 잡아 프런트 컨트롤러로 전달하기 위해 재 작성 조건을 누락되었습니다.

# strip app.php/ prefix if it is present 
    rewrite ^/app\.php/?(.*)$ /$1 permanent; 

    location /my-app { 
    index app.php; 
    try_files $uri @rewriteapp; 
    } 

    location @rewriteapp { 
    rewrite ^(.*)$ /app.php/$1 last; 
    } 

# Symfony 2 app index 
    location ~ ^/app\.php(/|$) { 
    fastcgi_pass unix:/home/gabriel/.phpbrew/php/php-7.1.0/var/run/php-fpm.sock; 
    fastcgi_split_path_info ^(.+\.php)(/.*)$; 
    include fastcgi_params; 
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    } 

    # deny access to any other php files 
    location ~^.*\.php(/|$) { 
    deny all; 
    } 

당신은 현재의 구성은 어떤 .php 스크립트에 대한보다 일반적인 구성입니다 만 Symfony2 일반 프레임 워크는 포괄 전면 컨트롤러를 제공

같은 것을보십시오.