使用Nginx的Slim Framework配置

问题描述 投票:0回答:1

一段时间以来,我一直在尝试使用Nginx在ubuntu 18.04服务器上设置苗条的框架,但我不断收到类似502 Bad Gateway的各种错误>

要安装Nginx,我已遵循本指南https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-18-04

要使用Slim创建应用程序,我已遵循本指南http://www.slimframework.com/docs/v3/tutorial/first-app.html(但即使使用php -S localhost:8080并打开8080端口也无法运行该应用程序)

我的项目目录为/var/www/project/src/public/index.php

index.php是

<?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, array $args) {
    $name = $args['name'];
    $response->getBody()->write("Hello, $name");

    return $response;
});
$app->run();

我基本上已经在src文件夹中安装了作曲器

对于php,我有php7.2

我的nginx conf文件是/etc/nginx/sites-available/example.com

并且包含

server {
        listen 80;
        listen [::]:80 default_server ipv6only=on;

        root /var/www/project/src/public/;
        index index.html index.htm index.php index.nginx-debian.html;

        server_name example.com1 www.example.com1;

        error_log /var/log/nginx/site.error.log;
        access_log /var/log/nginx/site.access.log;

        location ~ \.php$ {
                fastcgi_connect_timeout 5s;
                fastcgi_read_timeout 10s;
                fastcgi_pass unix:/var/run/php7.2-fpm.sock;
                #fastcgi_split_path_info ^(.+\.php)(/.*)$;
                fastcgi_index index.php;
                include fastcgi_params;
                #fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_na$
         }

        location / {
                try_files $uri $uri/ /index.php?$query_string;
                #try_files $uri $uri/ =404;
        }
}

但是我得到了502 Bad Gateway,有人可以告诉我我的配置有什么问题吗?

谢谢

一段时间以来,我一直在尝试使用Nginx在ubuntu 18.04服务器上设置苗条框架,但我不断收到诸如502 Bad Gateway的各种错误。要安装Nginx,我已经遵循了本指南https:// ...

ubuntu nginx slim
1个回答
0
投票
  1. Slim 3已被弃用。 Slim 4现在退出。
  2. Composer不应安装在生产服务器上,而只能安装在开发计算机上。
© www.soinside.com 2019 - 2024. All rights reserved.