亚马逊 AWS 上的虚拟主机(PHP + MySQL)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23362956/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 16:40:07  来源:igfitidea点击:

Web Hosting on Amazon AWS (PHP + MySQL)

phpamazon-web-servicesamazon-ec2amazon-s3

提问by BheemaSenan

I am totally confused on how to host a Dynamic website created using PHP and MySQLin Amazon Cloud.

我对如何在Amazon Cloud 中托管使用PHP 和 MySQL创建的动态网站感到非常困惑。

I went through Amazon S3and I hosted a static website there!

我浏览了Amazon S3,并在那里托管了一个静态网站!

Then I tried Amazon EC2and I learned some aspects about the concept of VPC. I thought that the dynamic websites are hosting in Amazon Cloud using EC2. I followed some steps and they taught me how to launch a website using Drupal(But, I didn't want that !! )

然后我尝试了Amazon EC2,并了解了 VPC 概念的一些方面。我认为动态网站使用 EC2 托管在 Amazon Cloud 中。我遵循了一些步骤,他们教我如何使用Drupal启动网站(但是,我不想那样!!)

No other tutorials on EC2 to deploy my web application was not found.

没有找到有关 EC2 的其他教程来部署我的 Web 应用程序。

Then I found AWS Elastic Beanstalk, I uploaded a simple PHP document and I can see that deployed successfully.

然后我找到了AWS Elastic Beanstalk,我上传了一个简单的 PHP 文档,我可以看到它部署成功。

But Still, I am not satisfied. Because, I don't know which is the correct way to deploy my PHP application.

但是,我仍然不满意。因为,我不知道哪种是部署我的 PHP 应用程序的正确方法。

So can anyone direct me on Deploying a PHP MySQL Application in AWS ?

那么任何人都可以指导我在 AWS 中部署 PHP MySQL 应用程序吗?

回答by col000r

Depends on your needs. Elastic Beanstalk might be a good option for many apps, but I chose EC2for my app's backend (using PHP, MySQLand S3for storage).

取决于您的需求。Elastic Beanstalk 可能是许多应用程序的不错选择,但我选择 EC2作为我应用程序的后端(使用PHPMySQLS3进行存储)。

Quick steps to get you up and running:

快速启动和运行的步骤:

  1. Log into the AWS Mangement Consoleand start a new EC instance(Windows server 2012 R2 Base > t2.microshould be good enough for a start!)

  2. At step "6. Configure Security Group", add Rules for at least HTTP, HTTPSand RDP(so you can connnect via Remote Desktop)

  3. Connect to your new instance via Remote Desktopand install a decent browser (Enable File Downloadsin IE's Security Settingsand download Chromeor Firefox)

  4. Open the Windows Firewalland add rules for the same ports you opened in the Security Group of your Instance in the AWS Management Console. (Right-click on “Inbound Rules”, then select “New Rule…”)

  5. Download and install XAMPP(I put it in C:\xampp)

  6. Open the XAMPP Control paneland install Apache and MySQL as services (so they will start automatically when your instance launches); make sure everything is started up.

  7. Now put your files in C:\xampp\htdocs\ and you're ready to go!

  1. 登录AWS 管理控制台并启动一个新的EC 实例Windows server 2012 R2 Base > t2.micro应该足够了!)

  2. 在步骤“6. 配置安全组”中,至少为HTTPHTTPSRDP添加规则(以便您可以通过远程桌面连接)

  3. 通过远程桌面连接到您的新实例并安装一个不错的浏览器(在 IE 的安全设置中启用文件下载并下载ChromeFirefox

  4. 打开Windows 防火墙并为您在 AWS 管理控制台中实例的安全组中打开的相同端口添加规则。(右键单击“入站规则”,然后选择“新建规则...”)

  5. 下载安装XAMPP(我放在C:\xampp)

  6. 打开XAMPP 控制面板并将 Apache 和 MySQL 安装为服务(这样它们会在您的实例启动时自动启动);确保一切都已启动。

  7. 现在将您的文件放在 C:\xampp\htdocs\ 中,您就可以开始了!

Bonus Steps:

奖励步骤:

  • Set up Filezilla FTP Server(and open the required ports in both the instance's security group and the Windows Firewall) so you can upload/download files without having to go through Remote Desktop.

  • Get an Elastic IPand assign it to your instance, so it's IP address will never change.

  • Get an SSL certificateso you can use HTTPS

  • 设置Filezilla FTP 服务器(并在实例的安全组和 Windows 防火墙中打开所需的端口),以便您无需通过远程桌面即可上传/下载文件。

  • 获取一个弹性 IP并将其分配给您的实例,因此它的 IP 地址永远不会改变。

  • 获取SSL 证书,以便您可以使用 HTTPS

回答by SebaGra

The answer depends on the load that you are expecting and the resources you have to handle all the administration tasks.

答案取决于您期望的负载以及处理所有管理任务所需的资源。

If you expect heavy or variable loads, there are many reasons why not to deploy a production PHP + MySQL application on a EC2.

如果您预计负载较重或可变负载,那么不在 EC2 上部署生产 PHP + MySQL 应用程序的原因有很多。

Hereare some of the benefits of deploying to Elastic Beanstalk instead of a manual configured EC2:

以下是部署到 Elastic Beanstalk 而不是手动配置的 EC2 的一些好处:

  • You get version control of each deployment.

  • You can scale up or down automatically if you need more/less instances to handle new load.

  • You get a load-balancer in front of your EC2s instances with a bunch of out-of-the-box "recommended" configurations.

  • 您可以获得每个部署的版本控制。

  • 如果您需要更多/更少的实例来处理新负载,您可以自动向上或向下扩展。

  • 您可以在 EC2s 实例前面获得一个负载均衡器,其中包含一系列开箱即用的“推荐”配置。

Regarding MySQL, if you go for an Amazon RDS instance you can handle replication, monitorization and automatic backups with pretty low effort. A lot of the configurations you would need to tweak are now available through parameter-groups.

关于 MySQL,如果您选择 Amazon RDS 实例,则可以轻松处理复制、监控和自动备份。您需要调整的许多配置现在都可以通过参数组获得。

On the other hand, if you want to have full control of everything that is going on on your server (that means you have time to monitor, backup and do maintenance tasks, which is not my case :), or if you do not plan to have much traffic, or if you want the less expensive option, you should go with a low cost EC2 instance.

另一方面,如果您想完全控制服务器上发生的一切(这意味着您有时间监控、备份和执行维护任务,这不是我的情况:),或者如果您不计划要获得大量流量,或者如果您想要更便宜的选项,您应该使用低成本的 EC2 实例。

In my experience, (after 2 years of working on AWS with 10 production applications, I'm kind of a regular AWS user) pretty much every customization or change I needed on both RDS and EBS I was able to tweak it and get it working, so I'm pretty satisfied with choosing the EBS+RDS option.

根据我的经验,(在 AWS 上使用 10 个生产应用程序工作了 2 年之后,我是一个普通的 AWS 用户)几乎我在 RDS 和 EBS 上需要的所有自定义或更改我都能够对其进行调整并使其正常工作,所以我对选择 EBS+RDS 选项非常满意。

回答by Aamir Sarwar

Below are two links i found which are helpful to Create and Update an Application with AWS Elastic Beanstalk

下面是我发现的两个链接,它们有助于使用 AWS Elastic Beanstalk 创建和更新应用程序

https://aws.amazon.com/getting-started/tutorials/launch-an-app/

https://aws.amazon.com/getting-started/tutorials/launch-an-app/

https://aws.amazon.com/getting-started/tutorials/update-an-app/

https://aws.amazon.com/getting-started/tutorials/update-an-app/