AWS Elastic Beanstalk - 如何在同一个ec2实例中运行php和nodejs

时间:2022-05-02 23:21:35

I'm using Elastic Beanstalk to deploy a root app (node.js) and also want to run php code that node.js app needs to call in the same ec2 instance.

我正在使用Elastic Beanstalk来部署根应用程序(node.js),并且还想运行node.js app需要在同一个ec2实例中调用的php代码。

When I connect to the instance it says:

当我连接到实例时,它说:

This EC2 instance is managed by AWS Elastic Beanstalk. Changes made via SSH WILL BE LOST if the instance is replaced by auto-scaling. [...]

此EC2实例由AWS Elastic Beanstalk管理。如果实例被自动缩放替换,则通过SSH进行的更改将丢失。 [...]

It means that when I add php sources in /var/www/ folder (connected via ssh), it will be removed if the instance changes.

这意味着当我在/ var / www /文件夹中添加php源代码(通过ssh连接)时,如果实例发生更改,它将被删除。

how could I run in the same instance node.js and php ?

我怎么能在同一个实例node.js和php中运行?

2 个解决方案

#1


You can explore the multi container option based on ECS to run more than one container per beanstalk environment.

您可以探索基于ECS的多容器选项,以便在每个beanstalk环境中运行多个容器。

Documentation:

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_ecs.html

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_v2config.html

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_ecstutorial.html

Is there a particular reason you want both apps to run on the same instance?

您是否希望两个应用程序在同一个实例上运行?

#2


maybe something like this:

也许是这样的:

**

create an ".ebextensions/nodeinstall.config" file

创建一个“.ebextensions / nodeinstall.config”文件

**

commands:
    node_install:
    cwd: /tmp

    command: 'yum install -y nodejs --enablerepo=epel'

I ran into a similar situation a while back and this worked for me.

我不久前遇到了类似的情况,这对我有用。

source: http://qpleple.com

#1


You can explore the multi container option based on ECS to run more than one container per beanstalk environment.

您可以探索基于ECS的多容器选项,以便在每个beanstalk环境中运行多个容器。

Documentation:

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_ecs.html

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_v2config.html

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_ecstutorial.html

Is there a particular reason you want both apps to run on the same instance?

您是否希望两个应用程序在同一个实例上运行?

#2


maybe something like this:

也许是这样的:

**

create an ".ebextensions/nodeinstall.config" file

创建一个“.ebextensions / nodeinstall.config”文件

**

commands:
    node_install:
    cwd: /tmp

    command: 'yum install -y nodejs --enablerepo=epel'

I ran into a similar situation a while back and this worked for me.

我不久前遇到了类似的情况,这对我有用。

source: http://qpleple.com