2017-01-19 3 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以降のすべてを(apache2の場合はmodrewriteと同じように)書き換えることができるように、nginx仮想ホストを設定するにはどうすればよいですか?

参照のための私の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のおよび一般的なフレームワークは、唯一のキャッチすべてのフロントコントローラを提供しています。

関連する問題