php - slim+nginx access error 500
PHPz
PHPz 2017-05-16 13:15:02
0
2
692

Use the slim official example to create the simplest slim application. The server uses nginx and reports an error. The php version is 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......

The nginx configuration file is official, and the path and domain name have been modified to be correct

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 is also the official code.

<?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();
~    
PHPz
PHPz

学习是最好的投资!

reply all(2)
PHPzhong

What’s going on with that ~ at the end of the index.php file?

According to the error message, it is a syntax error in the php file.

洪涛

If there is a syntax error in the php file, check the error.log of php
or turn on display_errors in php.ini to output the error

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!