php - 无法将 Laravel 应用程序部署到 EC2

标签 php apache amazon-web-services amazon-ec2 laravel-5

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

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

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

最佳答案

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

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

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

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 中将调试选项设置为 true

yourproject/config/app.php

'debug' => true,

还要确保您有一个默认的 .env 文件,用于指定项目根目录中的环境。

yourproject/.env

//should have this
APP_ENV = dev

此外,如果您正在使用 session 等,请确保您有一个生成的 key 使用此命令并且没有将 config/app.php 设置为

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

yourproject/config/app.php    

php artisan key:generate

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.

关于php - 无法将 Laravel 应用程序部署到 EC2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32927715/

相关文章:

apache - 在 Apache、Ubuntu 上安装后 phpmyadmin "Not Found"

c# - 是否有一个存储库可以抽象出 Azure、S3 等?

mysql - 在 CentOS7 上使用 Debian 基础运行 MySQL docker 镜像

amazon-web-services - 将文件夹上传到 AWS CodeCommit 存储库

php - 我的 CSRF 保护方法安全吗?

php - Codeigniter 2 多重连接和where语句

apache - htaccess 文件规则

java - spring mvc - 将静态内容与 jBoss 分离(Apache httpd 前期)

PHP网站源代码

php - php中的简单授权/登录功能