2
私は基本的なハローワールドGETエンドポイントで非常に基本的なスリムなアプリを作りました。スリムエンドポイントはPHP独自のサーバーで動作しますが、nginxでは動作しません
<?php
require 'vendor/autoload.php';
$app = new Slim\App();
$app->get('/hello/{name}', function ($request, $response, $args) {
$response->write("Hello, " . $args['name']);
return $response;
});
$app->run();
/hello/worldエンドポイントは、PHPの組み込みサーバーで実行すると想定されるように動作します。 しかし、nginxではありません。 404が見つかりません。
マイnginx_vhost(の/ etc/nginxの/サイト利用可能/ nginx_vhost)ファイルには、次のようになります。
私は間違っているつもりですserver {
listen 80;
server_name localhost;
root /var/www/;
index index.php index.html;
# Important for VirtualBox
sendfile off;
location/{
try_files $uri $uri/ =404;
}
location ~* \.php {
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_cache off;
fastcgi_index index.php;
}
}
?