php slim nginx,php - slim+nginx访问报500错

用slim官方的例子创建一个最简单的slim应用,服务器用的是nginx报错了。php版本是5.6.30

......1", upstream: "fastcgi://127.0.0.1:9000", host: "test.laonianji.net"

2017/02/08 16:14:14 [error] 26338#0: *6 FastCGI sent in stderr: "PHP message: PHP Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in /data/www/test_laonianji_net/src/vendor/slim/slim/Slim/Container.php on line 149" while reading response header from upstream, client......

nginx的配置文件用的是官方的,路径和域名自己修改成正确的了

server {

listen 80;

server_name mydomain;

index index.php;

error_log /data/log/nginx/access/mydomain.error.log;

access_log /data/log/nginx/access/mydomain.acess.log;

root /mypath/src/public;

location / {

try_files $uri $uri/ /index.php$is_args$args;

}

location ~ \.php {

try_files $uri =404;

fastcgi_split_path_info ^(.+\.php)(/.+)$;

include fastcgi_params;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

fastcgi_param SCRIPT_NAME $fastcgi_script_name;

fastcgi_index index.php;

fastcgi_pass 127.0.0.1:9000;

}

}

index.php也是官方的代码。

use \Psr\Http\Message\ServerRequestInterface as Request;

use \Psr\Http\Message\ResponseInterface as Response;

require '../vendor/autoload.php';

$app = new \Slim\App;

$app->get('/hello/{name}', function (Request $request, Response $response) {

$name = $request->getAttribute('name');

$response->getBody()->write("Hello, $name");

return $response;

});

$app->run();

~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值