简体   繁体   English

在AWS Elastic Beanstalk上部署Laravel 4应用

[英]Deploying a Laravel 4 app on AWS Elastic Beanstalk

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. 我以前从未部署过,所以请尽可能详细地介绍。

To answer your question regarding the L4 app configuration, you will surely find these posts helpful: 要回答有关L4应用程序配置的问题,您一定会发现这些帖子很有帮助:

L4 cloud deployment problems L4云部署问题
Laravel and Elastic Beanstalk Laravel和Elastic Beanstalk

AWS Environment config AWS环境配置
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. 根据您对“某种/ app / config / elsatic”问题的疑问-Laravel能够根据运行环境来“加载”不同的配置。例如,您可以设置包含配置文件的不同子文件夹用于测试服务器和生产服务器。 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. 这样,您可以安全地在两台服务器之间复制文件,而不必在每次同步文件时更改数据库credentail或basepath。 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. 因此,在您链接的文章中,建议为AWS环境创建一个子文件夹,以便您可以拥有一组自定义配置,如果您的应用程序在AWS上运行,这些配置将被激活。

how to deploy a Laravel 4 app on AWS 如何在AWS上部署Laravel 4应用
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 感谢/支持/ 赞扬以下步骤,请从Laravel论坛转到codenamegary


Install the AWS Command Line Tool on your machine 在您的机器上安装AWS Command Line Tool
http://aws.amazon.com/code/6752709412171743 http://aws.amazon.com/code/6752709412171743
- Requires ruby and a couple of other things -需要红宝石和其他一些东西

EC2 - Setup a Security Group EC2-设置安全组
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-network-security.html
- Under EC2 create a new security group -在EC2下创建一个新的安全组
- Naming conventions are whatever you want by typically I try to use something like... -命名约定通常是您想要的,我通常尝试使用类似...
"app-environment-eb" “ 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 -例如,对于生产环境中名为“ Blog”的应用程序,在弹性beantalk的生产环境中,我将其称为“ blog-production-eb”,即博客应用程序
- On the group permit all HTTP / HTTPS and whatever else you might need -在组上允许所有HTTP / HTTPS以及您可能需要的其他任何内容

RDS - Setup an RDS security Group (for MySQL) RDS-设置RDS安全组(适用于MySQL)
http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.RDSSecurityGroups.html http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.RDSSecurityGroups.html
- Under RDS create a new security group -在RDS下创建一个新的安全组
- Again, naming conventions are whatever you want but I try to follow something like... -同样,命名约定是您想要的,但是我尝试遵循类似...
"app-environment-rds" “ 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 -例如,对于生产环境中名为“ Blog”的应用程序,在RDS的生产环境中,我将其称为“ blog-production-rds”,即博客应用程序
- Permit the EC2 security group on this RDS Security Group -允许该RDS安全组上的EC2安全组
- You may also want to permit your own public IP on the group so you can access the DB directly from your machine -您可能还希望在组中允许使用自己的公共IP,以便可以直接从计算机访问数据库
- Alternatively, setup a VPC and a gateway (whole other ball of wax) to get remote access -或者,设置VPC和网关(其他蜡球)以进行远程访问
- Create a new RDS instance and attach it to the new RDS Security Group -创建一个新的RDS实例并将其附加到新的RDS安全组

EB - Create an EB App and Environment EB-创建EB应用程序和环境
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.html http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.html
- Under Elastic Beanstalk setup an App, Amazon 64-bit PHP nodes (or whatever) -在Elastic Beanstalk下设置一个应用程序,Amazon 64位PHP节点(或其他)
- Setup an environment (call it whatever you like) -设置环境(随心所欲)
- Set the environment container's document root to /public -将环境容器的文档根目录设置为/ 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) -将环境容器的安全组设置为刚创建的EC2安全组的名称-配置应用数据库连接以指向您创建的RDS实例(主机名,用户名,密码等)

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM