Laravel Elastic BeanStalk 上的 404 [英] 404 on Laravel Elastic BeanStalk

查看:76
本文介绍了Laravel Elastic BeanStalk 上的 404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 Laravel 7 应用程序部署到 Elastic BeanStalk,但在路由方面遇到了一些问题.

I am trying to deploy a Laravel 7 application to Elastic BeanStalk but having some problem with the routing.

我已按照以下视频中的教程进行操作,并上传了包含所有本地文件的 zip 存档.在将 root 设置为/public 后,我还修复了权限问题.目前,唯一可见的页面是主页,而其他页面如/login、/register 和其他页面向我显示 404

I have followed the tutorial from the video below and upload the zip archive with all my local files. I have also fixed the permission issue after having set the root to /public. Currently, the only page visible is the homepage whereas al the other pages like /login, /register and the other show me a 404

这里是来自 eb 的日志:

here is the log of the from eb:

2020/05/01 14:19:30 [error] 4091#0: *4 open() "/var/www/html/public/login" failed (2: No such file or directory),客户端:82.4.194.3,服务器:,请求:GET/login HTTP/1.1"

2020/05/01 14:19:30 [error] 4091#0: *4 open() "/var/www/html/public/login" failed (2: No such file or directory), client: 82.4.194.3, server: , request: "GET /login HTTP/1.1"

https://www.youtube.com/watch?v=ISVaMijczKc

推荐答案

我想您使用的是带有 Linux 版本 2 的 Beanstalk PHP 平台;此版本使用 Nginx(而之前版本使用 Apache).

I suppose you are using Beanstalk PHP platform with Linux in version 2; this version uses Nginx (whereas the previous version uses Apache).

您可以在官方文档中查看更多详细信息:https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html#platforms-supported.PHP

You can see more details in the official documentation: https://docs.aws.amazon.com/elasticbeanstalk/latest/platforms/platforms-supported.html#platforms-supported.PHP

在这种情况下,您必须按照 Laravel 文档中的说明配置 Nginx 以进行重定向:https://laravel.com/docs/7.x/deployment#nginx

In that case, you have to configure Nginx for redirection as described in the Laravel documentation: https://laravel.com/docs/7.x/deployment#nginx

只需创建文件 .platform/nginx/conf.d/elasticbeanstalk/laravel.conf(在项目的根目录下):

Just create the file .platform/nginx/conf.d/elasticbeanstalk/laravel.conf (at the root of your project):

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

您可以根据需要随意添加其他配置.

Feel free to add other configuration for your need.

您可以在此处找到有关扩展平台的更多详细信息:https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html

You will find more details about extending the platform here: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html

这篇关于Laravel Elastic BeanStalk 上的 404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆