在 AWS Elastic Beanstalk 上部署 Laravel 4 应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18040739/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Deploying a Laravel 4 app on AWS Elastic Beanstalk
提问by Josh
I've developed an application in Laravel 4 - works perfectly on my local machine with the usual/typical laravel setup (nothing unusual going on here).
我在 Laravel 4 中开发了一个应用程序 - 在我的本地机器上使用通常/典型的 Laravel 设置完美运行(这里没有异常)。
I'm now wanting to deploy the app to AWS Elastic Beanstalk (probably on a typical linux 64 bit server with php 5.4 installed)
我现在想将该应用程序部署到 AWS Elastic Beanstalk(可能在安装了 php 5.4 的典型 linux 64 位服务器上)
My question is this: do I need to make any changes to files to make the application ready for deployment?
我的问题是:我是否需要对文件进行任何更改才能使应用程序做好部署准备?
For example, are there any config files that I need to create etc? (I read about some sort of app/config/elastic file here: http:://darrennolan.com/2013/02/02/php-aws-elastic-beanstalk-rds-laravel-4-with-migrations-on-updates/)
例如,是否有任何我需要创建的配置文件等?(我在这里阅读了某种 app/config/elastic 文件:http:://darrennolan.com/2013/02/02/php-aws-elastic-beanstalk-rds-laravel-4-with-migrations-on-更新/)
I've never deployed before so please go into as much detail as you can.
我以前从未部署过,所以请尽可能详细地介绍。
回答by Gadoma
To answer your question regarding the L4 app configuration, you will surely find these posts helpful:
L4 cloud deployment problems
Laravel and Elastic Beanstalk
AWS Environment config
As per your question about the "some sort of /app/config/elsatic" thing - Laravel is able to "load" different config, based on the environment it is run in. You can set up different subfolders containing config files, for example for a testing server and production server. That way, you can safely copy files between two servers and dont have to change for example database credentails or basepath every time you sync the files. So here in the article you linked, it's suggested to create a subfolder for the AWS environment so you can have a custom set of configs which will activate if you app is run on AWS.
要回答有关 L4 应用程序配置的问题,您肯定会发现这些帖子很有帮助:
L4 云部署问题
Laravel 和 Elastic Beanstalk
AWS 环境配置
根据您关于“某种 /app/config/elsatic” 事情的问题 - Laravel 是能够根据运行环境“加载”不同的配置。您可以设置包含配置文件的不同子文件夹,例如用于测试服务器和生产服务器。这样,您可以安全地在两台服务器之间复制文件,而不必在每次同步文件时更改例如数据库凭据或基本路径。所以在你链接的文章中,它'
how to deploy a Laravel 4 app on AWS
Here you have a short instruction . The instruction I came across (but didnt have time to test it yet) is below, but still read the above posts first. Thanks/props/kudos for the below steps go to codenamegary from the Laravel forum
Install the AWS Command Line Tool on your machine
http://aws.amazon.com/code/6752709412171743
- Requires ruby and a couple of other things
EC2 - Setup a Security Group
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html
- Under EC2 create a new security group
- Naming conventions are whatever you want by typically I try to use something like...
"app-environment-eb"
- For example, for an app called "Blog" in the production environment I'd call it "blog-production-eb" meaning blog app, in production environment on elastic beanstalk
- On the group permit all HTTP / HTTPS and whatever else you might need
RDS - Setup an RDS security Group (for MySQL)
http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.RDSSecurityGroups.html
- Under RDS create a new security group
- Again, naming conventions are whatever you want but I try to follow something like...
"app-environment-rds"
- For example, for an app called "Blog" in the production environment I'd call it "blog-production-rds" meaning blog app, in production environment on RDS
- Permit the EC2 security group on this RDS Security Group
- You may also want to permit your own public IP on the group so you can access the DB directly from your machine
- Alternatively, setup a VPC and a gateway (whole other ball of wax) to get remote access
- Create a new RDS instance and attach it to the new RDS Security Group
如何在 AWS 上部署 Laravel 4 应用程序
这里有一个简短的说明。我遇到的说明(但还没有时间测试)如下,但还是先阅读上面的帖子。感谢/props/ kudos执行以下步骤从 Laravel 论坛转到codenamegary
在您的机器上安装 AWS 命令行工具
http://aws.amazon.com/code/6752709412171743
- 需要 ruby 和其他一些东西
EC2 - 设置一个安全组
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html
- 在 EC2 下创建一个新的安全组
- 命名约定是你想要的,通常我尝试使用一些东西像...
“应用环境-eb”
- 例如,对于在生产环境中名为“Blog”的应用程序,我将其称为“blog-production-eb”,意思是博客应用程序,在弹性 beantalk 的生产环境中
- 在组中允许所有 HTTP / HTTPS 以及其他任何内容可能需要
RDS - 设置一个 RDS 安全组(用于 MySQL)
http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.RDSSecurityGroups.html
- 在 RDS 下创建一个新的安全组
- 同样,命名约定是无论你想要什么,但我尝试遵循类似...
“app-environment-rds”
- 例如,对于生产环境中名为“Blog”的应用程序,我将其称为“blog-production-rds”,意思是博客应用程序,在 RDS 的生产环境中
- 在此 RDS 安全组上允许 EC2 安全组
- 您可能还希望在组上允许您自己的公共 IP,以便您可以直接从您的机器访问数据库
- 或者,设置一个 VPC 和一个网关(整个其他的蜡球)以获得远程访问
- 创建一个新的 RDS 实例并将其附加到新的 RDS 安全组
EB - Create an EB App and Environment
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.html
- Under Elastic Beanstalk setup an App, Amazon 64-bit PHP nodes (or whatever)
- Setup an environment (call it whatever you like)
- Set the environment container's document root to /public
- Set the environment container's security group to the name of the EC2 security group you just created
- Configure your app DB connection to point at the RDS instance you created (hostname, username, password, etc)
EB - 创建一个 EB 应用程序和环境
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.html
- 在 Elastic Beanstalk 下设置一个应用程序,亚马逊 64 位 PHP 节点(或其他)
-设置环境(随意命名)
- 将环境容器的文档根目录
设置为 /public - 将环境容器的安全组设置为您刚刚创建的 EC2 安全组的名称 - 将您的应用程序数据库连接配置为指向 RDS 实例您创建的(主机名、用户名、密码等)
回答by LF.
Additionally, I would recommend checking out Chris Fidao's TrustedProxy package, so you can get proper IP addresses when calling Request::getClientIp(): http://fideloper.com/laravel-4-trusted-proxies
此外,我建议查看 Chris Fidao 的 TrustedProxy 包,以便在调用 Request::getClientIp() 时获得正确的 IP 地址:http: //fideloper.com/laravel-4-trusted-proxies
(Be sure to set proxy addresses using CIDR notation.)
(请务必使用CIDR 表示法设置代理地址。)
Another helpful source of information applicable to putting Laravel behind Amazon's load balancers: http://fideloper.com/web-app-load-balancing
另一个有用的信息来源适用于将 Laravel 置于亚马逊负载均衡器的后面:http://fideloper.com/web-app-load-balancing