【发布时间】:2016-07-27 00:31:26
【问题描述】:
我用一个基本的 hello world GET 端点制作了一个非常基本的超薄应用。
<?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();
当我使用 PHP 的内置服务器运行 /hello/world 端点时,它的工作方式与预期一样。 但不是 nginx。我得到一个 404 未找到。
我的 nginx_vhost (/etc/nginx/sites-available/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;
}
}
我哪里错了?
【问题讨论】:
标签: php nginx slim restful-url