无法将Laravel应用部署到EC2 [英] Failing to deploy a Laravel app to EC2

查看:77
本文介绍了无法将Laravel应用部署到EC2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Laravel项目都在本地主机上运行. 我将其部署到EC2,但没有任何反应. 我在开发人员控制台中看到的只是内部错误(500).

I have my Laravel project all working on my localhost. I deployed it to EC2, but nothing comes up. All I see in the dev console is internal error (500).

我想念什么?部署到AWS之前我需要更改什么?这是网址: http://ec2-52-88-99-75 .us-west-2.compute.amazonaws.com

What am I missing? What do I need to change before deploying to AWS? Here is the URL: http://ec2-52-88-99-75.us-west-2.compute.amazonaws.com

这是httpd.conf文件: http://collabedit.com/sdcxm

Here is the httpd.conf file: http://collabedit.com/sdcxm

推荐答案

在安装Laravel之后,您可能需要配置一些权限. 存储和引导/高速缓存目录中的目录 应该是您的Web服务器可写的. - http://laravel.com/docs/master#configuration

After installing Laravel, you may need to configure some permissions. Directories within the storage and the bootstrap/cache directories should be writable by your web server. - http://laravel.com/docs/master#configuration

Laravel的"Storage"文件夹和"bootstrap/cache"文件夹需要命令行用户(运行composer update等的用户)和默认的Web服务器用户(www-data)进行访问(如果您使用的是ubuntu)在您的EC2实例上.

Laravel "Storage" folder and the "bootstrap/cache" folder needs access from both the command line user (the one that runs composer update etc) and the default web server user (www-data) in case you are using ubuntu on your EC2 instance.

以下三个命令将确保它们都具有执行此操作的权限.在项目的根目录下运行它们

The following three commands will ensure that both of them have the rights to do that. Run them at the root of your project

HTTPDUSER=`ps aux | grep -E '[a]pache|[h]ttpd|[_]www|[w]ww-data|[n]ginx' | grep -v root | head -1 | cut -d\  -f1`

sudo setfacl -R -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX storage bootstrap/cache

sudo setfacl -dR -m u:"$HTTPDUSER":rwX -m u:`whoami`:rwX storage bootstrap/cache

这应该开始向您显示可以调试的特定错误.还要确保在app.php中将debug选项设置为true

This should start displaying you specific errors that you can debug. Also make sure that you have the debug option set as true in app.php

yourproject/config/app.php

'debug' => true,

还要确保您有一个默认的.env文件,该文件在项目根目录下指定了环境.

Also make sure you have a default .env file that specifies the environment at the project root.

yourproject/.env

//should have this
APP_ENV = dev

此外,如果您正在使用会话等,请确保已通过以下方式生成了密钥: 使用此命令,并且没有将config/app.php设置为

Also if you are using sessions etc make sure you have a generated a key by using this command and doesn't have config/app.php set as

'key'=> env('APP_KEY','SomeRandomString'),

'key' => env('APP_KEY', 'SomeRandomString'),

yourproject/config/app.php    

php artisan key:generate

新Amazon EC2实例的一个常见陷阱是分配一个安全组 到没有允许端口80和443作为入站端口的实例. 请检查您的EC2实例的安全组,如果尚未允许,请在该组中允许这些端口.

One common pitfall for new Amazon EC2 instances is to assign a security group to your instance that doesn't have port 80 and 443 allowed as inbound. Please check your EC2 instance's security group and allow those ports in the group if not already.

这篇关于无法将Laravel应用部署到EC2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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