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的部署,希望得到大家的帮助,感谢大家的解答!

《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
讨论数量: 1

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