Silex + Nginx 1.8 - 404路线

时间:2015-05-08 19:56:44

标签: php nginx silex

我已将Nginx版本更新为1.8。我也用php5-fpm。在Nginx更新之前一切都很好(从版本1.2.1开始)。

 Note:

 [...]

 For historical reasons, the calls created by ‘lapply’ are
 unevaluated, and code has been written (e.g., ‘bquote’) that
 relies on this.  This means that the recorded call is always of
 the form ‘FUN(X[[i]], ...)’, with ‘i’ replaced by the current
 (integer or double) index.  This is not normally a problem, but it
 can be if ‘FUN’ uses ‘sys.call’ or ‘match.call’ or if it is a
 primitive function that makes use of the call.  This means that it
 is often safer to call primitive functions with a wrapper, so that
 e.g. ‘lapply(ll, function(x) is.numeric(x))’ is required to ensure
 that method dispatch for ‘is.numeric’ occurs correctly.

/ etc / nginx / fastcgi_params文件:

/etc/nginx/sites-enabled/gazeta.ovh file:
server {
  listen 80;
  root /var/www/gazeta.ovh/web;
  index index.php;

  server_name gazeta.ovh;

  charset utf-8;

  location = / {
    try_files @site @site;
  }

  location / {
    try_files $uri $uri/ @site;
  }

  location ~ \.php$ {
    return 404;
  }

  location @site {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
  }
}

我有2条路线:

fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;
fastcgi_param  HTTPS              $https if_not_empty;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;

路线/工作正常。但是当我尝试获取/测试路由时,我从nginx得到404错误:

$app->get('/', function() use ($app) { return 'route 1' });
$app->get('/test', function() use ($app) { return 'route 2' });

Nginx访问日志显示404错误" GET / test HTTP / 1.1" 404 162" - " "卷曲/ 7.35.0"

但是,尝试访问gazeta.ovh/index.php/test有效。

我应该改变什么才能让它发挥作用?我尝试过添加SCRIPT_FILENAME参数,但没有成功。我试过了:

<html>
<head><title>404 Not Found</title></head>
<body bgcolor="white">
<center><h1>404 Not Found</h1></center>
<hr><center>nginx</center>
</body>
</html>

任何帮助表示赞赏:)

编辑:

好的,通过将域配置更改为:

来修复它
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;

0 个答案:

没有答案