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的部署,希望得到大家的帮助,感谢大家的解答!
部署《Laravel 6 中文文档》