建立Symfony2的应用程序在亚马逊(傻瓜) [英] Setting up Symfony2 application on amazon (for dummies)

查看:191
本文介绍了建立Symfony2的应用程序在亚马逊(傻瓜)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想学习如何成功部署在亚马逊的云Symfony2的应用程序。什么是工作,我开始与空白的Ubuntu,安装灯服务器^,SVN ...其他一些好吃的东西和它的工作完美。

问题:所有资产和DB托管在一个实例,我知道这是不正确的做法。我查了许多网站,并没有找到真正的设置S2应用程序,只字preSS和一致好评任何简单的解决方案。

我的应用程序允许用户上传图片,然后使用 Liip显示它们/试想捆绑

我还检查<一href="https://github.com/Cybernox/AmazonWebServicesBundle/blob/master/Resources/doc/cdn.md">AmazonWebServices捆绑,我想我应该以某种方式使用两者;第一次显示,第二个用于将文件发送到S3桶。而且它也工作在我的本地Windows环境。

  1. 如何解决?是否有一些真正的傻瓜的解决方案呢?
  2. RDS需要读

      $ DBHOST = $ _ SERVER ['RDS_HOSTNAME'];
    $ dbport = $ _ SERVER ['RDS_PORT'];
    $ DBNAME = $ _ SERVER ['RDS_DB_N​​AME'];
     

    要能够访问MySQL。如何做到这一点使用parameters.yml什么时候?

解决方案

基建

虽然你可以使用AWS提供独立服务器,如果你想支持多个实例,负载均衡等,你要分开的事情了。在最基本的层面上,你很可能需要使用:

  • S3 - 持久性存储
  • RDS - MySQL数据库
  • 在EC2 - 阿帕奇/ Nginx的,PHP前端

您可以再扩大此有:

  • 的Cloudfront - 你的S3内容的本地化交付
  • 负载均衡器 - 确保您的EC2实例优化使用
  • 自动缩放 - 启动/停止新的实例
  • 路线53 - DNS
  • 在VPC - 重要的,因为它具有安全性高,单前面的SSL证书等结束

此外,而不是从头开始,你可以使用AMI的从市场上: HTTPS://aws.amazon。 COM /市场/

签出AWS入门指南,因为这经过所有的细节:的http://docs.aws.amazon.com/gettingstarted/latest/wah-linux/web-app-hosting-intro.html

使用上述,我建议将您的数据库RDS和简单地在您的EC2实例托管的Apache。你甚至可能会发现这是符合成本效益的过,你就可以利用小实例给出了更低的内存/ CPU的要求。

此外,随着时间的推移,你可以先来了解一下弹性魔豆和厨师(甚至放浪的本地开发框),弹性魔豆(的http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_PHP_symfony2.html)

那么,Symfony的

第一次了,环境

我假设你已经创建的生产和开发环境: HTTP:/ /symfony.com/doc/current/cookbook/configuration/environments.html 。当你能够改变当地的环境和生产环境之间的配置这一点很重要。

表象

结帐的https://github.com/liip/LiipImagineBundle/blob/master/Resources/doc/data-loader/stream.md它利用 https://github.com/KnpLabs/Gaufrette (或包:的 https://github.com/KnpLabs/KnpGaufretteBundle )。

有似乎是如何在这里配置的好文章:的https://florian.ec/articles/upload-files-to-amazon-s3-with-symfony2-and-gaufrette/

使用上述环境中,你可以配置生产读/写S3,而发展写入到/ tmp(例如)

数据库。

我要作你正在使用学说为你的数据库连接,并已按照有关如何设置了配置的Symfony文档的假设:的 http://symfony.com/doc/current/book/doctrine.html#configuring-the-database

所有你需要做的就是按照环境的逻辑,并设置DB串生产/当地相应。这应该是无缝的在后台,无需手动MySQL连接。

I am trying to learn how to successfully deploy Symfony2 application on amazon cloud. What worked is that I started with blank Ubuntu, installed lamp-server^, svn... few other goodies and it worked perfectly.

The problem: all assets and DB were hosted on that one instance and I know it is not the right thing to do. I checked numerous sites and didn't find any easy solution of setting real S2 application, only Wordpress and alike.

My application allows users to upload images and then display them using Liip/Imagine bundle

I also checked AmazonWebServices bundle and I guess I should somehow use both of them; first one for display, second one for sending files to S3 bucket. And it also must work in my local Windows enviroment.

  1. How to solve that? Is there some really idiot-proof solution for this?
  2. RDS requires to read

    $dbhost = $_SERVER['RDS_HOSTNAME'];
    $dbport = $_SERVER['RDS_PORT'];
    $dbname = $_SERVER['RDS_DB_NAME'];
    

    to be able to access mysql. How to do that when using parameters.yml?

解决方案

Infrastructure

Whilst as you can use AWS to provide standalone servers, if you wish to support multiple instances, load balancing etc, you'll want to separate things out. At the most basic level you'll likely want to be using:

  • S3 - persistent storage
  • RDS - MySQL database
  • EC2 - Apache / Nginx, PHP front end

You can then augment this with:

  • Cloudfront - localised delivery of your S3 content
  • Loadbalancer - ensure your EC2 instances are used optimally
  • Auto scaling - start / stop new instances
  • Route 53 - DNS
  • VPC - important as this offers security, single front ends for SSL certificates etc.

Also, rather than start from scratch you can use AMI's from the marketplace: https://aws.amazon.com/marketplace/

Checkout the AWS getting started guide as this goes through everything in detail: http://docs.aws.amazon.com/gettingstarted/latest/wah-linux/web-app-hosting-intro.html

Using the above, I'd suggest moving your database to RDS and simply hosting Apache on your EC2 instances. You might even find this is cost effective too as you'll be able to utilise small instances given the lower memory / CPU requirements.

Also, as time progresses, you can start to look at Elastic Beanstalk and Chef (maybe even vagrant for local dev boxes), Elastic Beanstalk (http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_PHP_symfony2.html)

So, Symfony

first up, environments

I'm assuming you've created production and development environments: http://symfony.com/doc/current/cookbook/configuration/environments.html. This is important as you are able to change configuration between local and production environments.

Imagery

Checkout https://github.com/liip/LiipImagineBundle/blob/master/Resources/doc/data-loader/stream.md which utilises https://github.com/KnpLabs/Gaufrette (or the bundle: https://github.com/KnpLabs/KnpGaufretteBundle).

There appears to be a good article on how to configure it here: https://florian.ec/articles/upload-files-to-amazon-s3-with-symfony2-and-gaufrette/

Using the above environments, you'd be able to configure production to read/write to s3, whereas developments write to /tmp (for example)

Database.

I'm going to make an assumption that you're using Doctrine as your DB connection and have followed the Symfony docs on how to set up the configuration: http://symfony.com/doc/current/book/doctrine.html#configuring-the-database.

All you'd need to do is follow the environment logic and set the db strings production / local accordingly. This should be seamless in the background and not require manual MySQL connections.

这篇关于建立Symfony2的应用程序在亚马逊(傻瓜)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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