Lumen 部署到阿里云服务器自动下载 index.php

我先是安装了lumen5.6,建了模型,写了一个简单路由:

use App\Models\User;
$app->get('/user', function() use ($app) {
    return response()->json(User::all());
});

挂在localhost:3000上

php -S localhost:3000 -t public

能访问到api:

[{"id":1,"nickname":"marie","tel":"12345","finish":3},{"id":2,"nickname":"dreamer","tel":"54321","finish":0}]

我的阿里云服务器是LNMP环境,我把lumen项目改名为html放到/var/www/下,还把nginx的配置文件里加了index.php

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index index.php index.html index.htm index.nginx-debian.html;

    server_name _;

    location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ =404;
    }
    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

最后访问“我的ip/public”,结果网页直接把public下的index.php文件给下载了。
我还不大明白lumen的部署,希望得到大家的帮助,感谢大家的解答!

《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 1

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!