支付宝沙箱设置

tech2023-11-18  81

支付宝沙箱设置

This is the final article in a three part series focused on setting up EC2 as a sandbox for application developers. I assume you have an AWS account with Amazon; if you don’t, please read Part 1 to learn how easy it is to sign up. I also assume you have configured your development environment and installed an AMI; if you haven’t, please read Part 2. In this installment, we’ll learn how to install Apache, MySQL and PHP in our running AMI, and then clone the AMI to make our own.

这是一个由三部分组成的系列文章的最后一篇,该系列文章重点介绍如何将EC2设置为应用程序开发人员的沙箱。 我假设您在亚马逊拥有一个AWS账户; 如果您不这样做,请阅读第1部分,以了解注册的难易程度。 我还假设您已经配置了开发环境并安装了AMI。 如果还没有,请阅读第2部分 。 在本期中,我们将学习如何在运行的AMI中安装Apache,MySQL和PHP,然后克隆AMI以创建自己的AMI。

设置LAMP堆栈 (Setting up the LAMP Stack)

Now we’re ready to get our LAMP stack set up. As it is outside the scope of this article and because there are many perspectives on best practice, we won’t get into setting up a multi-tiered ecosystem. Instead we will install MySQL, Apache, and PHP in our instance, knowing that when we write our application we’ll be sure to structure the code such that we can change our data source easily.

现在我们准备好设置我们的LAMP堆栈。 由于它不在本文讨论范围之内,并且由于对最佳实践的看法不尽相同,因此我们将不会建立多层生态系统。 相反,我们将在实例中安装MySQL,Apache和PHP,因为知道在编写应用程序时,我们将确保对代码进行结构化,以便我们可以轻松更改数据源。

First, make sure we can do anything we want on this box by launching an interactive shell with administrator privileges.

首先,通过启动具有管理员权限的交互式外壳程序,确保我们可以在此框中执行任何操作。

ubuntu@ip-10-112-58-53:~$ sudo -i

Next, install MySQL via apt-get. We will be prompted to choose and verify a root password for MySQL along the way.

接下来,通过apt-get安装MySQL。 在此过程中,系统将提示我们选择并验证MySQL的根密码。

root@ip-10-112-58-53:~# apt-get install mysql-server mysql-client

Then install Apache via apt-get.

然后通过apt-get安装Apache。

root@ip-10-112-58-53:~# apt-get install apache2

Of course we also want to install PHP and the corresponding Apache module.

当然,我们还想安装PHP和相应的Apache模块。

root@ip-10-112-58-53:~# apt-get install php5 libapache2-mod-php5

Finally, we need to install at least the php5-mysql package. I like to install a few more… use apt-cache search php5 to find the packages you want.

最后,我们至少需要安装php5-mysql软件包。 我想再安装一些…使用apt-cache search php5查找所需的软件包。

root@ip-10-112-58-53:~# apt-cache search php5 root@ip-10-112-58-53:~# apt-get install php5-mysql php-pear php5-cgi php5-cli php5-common php5-curl php5-gd php5-gmp php5-ldap php5-odbc php5-pgsql php5-snmp php5-sqlite php5-xmlrpc php5-xsl php5-imagick

Restart Apache after all the new packages are installed.

安装所有新软件包后,重新启动Apache。

root@ip-10-112-58-53:~# service apache2 restart * Restarting web server apache2 ... waiting ...done.

After we’re done, we should do a sanity check to make sure everything is configured correctly. Create a file called phpinfo.php in the web root with the following contents:

完成后,我们应该进行完整性检查,以确保所有配置均正确。 在Web根目录中创建一个名为phpinfo.php的文件,内容如下:

<?php phpinfo();

Now is the moment of truth. Take the Public DNS entry we used before, paste it into a web browser and visit the file you just created. Hopefully we’ll to see the output of phpinfo().

现在是关键时刻。 取得我们之前使用的Public DNS条目,将其粘贴到Web浏览器中,然后访问刚刚创建的文件。 希望我们能看到phpinfo()的输出。

已付股息 (Dividends Paid)

We’re not done just yet! We’ve worked hard to build a solid baseline LAMP stack, so let’s create our own AMI so we can start an identical instance to the one we’ve just configured. To do so, we use ec2-create-image.

我们还没有完成! 我们一直在努力构建可靠的基线LAMP堆栈,因此让我们创建自己的AMI,以便可以启动与刚刚配置的实例相同的实例。 为此,我们使用ec2-create-image 。

MacBook-Pro:.ec2 john2$ ec2-create-image i-c795bfa6 -n lamp-starter IMAGE ami-43b5752a

Click on AMIs in the IMAGES section of the EC2 Management Console and we should see our image.

单击EC2管理控制台的IMAGES部分中的AMI,我们应该看到我们的图像。

Now that we’ve successfully gone from zero to cloud, let’s have a little fun and pretend we’ve built a multi-tiered web application that has gone live and is tremendously successful. Assuming we’ve architected the application appropriately, and ignoring the necessary load balancing setup, we could launch 10 new web servers with a few key presses.

现在我们已经成功地从零迁移到了云,让我们玩得开心一点,并假装我们已经构建了一个多层的Web应用程序,该应用程序已经投入使用并且取得了巨大的成功。 假设我们已经适当地构建了应用程序,并且忽略了必需的负载平衡设置,那么只需按几次键就可以启动10个新的Web服务器。

MacBook-Pro:.ec2 john2$ ec2-run-instances -k john2.kp --instance-type m1.large -n 10 ami-43b5752a RESERVATION r-4f433b20 582155754520 default INSTANCE i-2daa9f4c ami-43b5752a pending john2.kp 0 m1.large 2011-08-22T04:49:45+0000 us-east-1a aki-427d952b monitoring-disabled ebs paravirtual xen sg-f5a0899c default INSTANCE i-2faa9f4e ami-43b5752a pending john2.kp 1 m1.large 2011-08-22T04:49:45+0000 us-east-1a aki-427d952b monitoring-disabled ebs paravirtual xen sg-f5a0899c default INSTANCE i-31aa9f50 ami-43b5752a pending john2.kp 2 m1.large 2011-08-22T04:49:45+0000 us-east-1a aki-427d952b monitoring-disabled ebs paravirtual xen sg-f5a0899c default INSTANCE i-33aa9f52 ami-43b5752a pending john2.kp 3 m1.large 2011-08-22T04:49:45+0000 us-east-1a aki-427d952b monitoring-disabled ebs paravirtual xen sg-f5a0899c default INSTANCE i-35aa9f54 ami-43b5752a pending john2.kp 4 m1.large 2011-08-22T04:49:45+0000 us-east-1a aki-427d952b monitoring-disabled ebs paravirtual xen sg-f5a0899c default INSTANCE i-37aa9f56 ami-43b5752a pending john2.kp 5 m1.large 2011-08-22T04:49:45+0000 us-east-1a aki-427d952b monitoring-disabled ebs paravirtual xen sg-f5a0899c default INSTANCE i-3baa9f5a ami-43b5752a pending john2.kp 6 m1.large 2011-08-22T04:49:45+0000 us-east-1a aki-427d952b monitoring-disabled ebs paravirtual xen sg-f5a0899c default INSTANCE i-3daa9f5c ami-43b5752a pending john2.kp 7 m1.large 2011-08-22T04:49:45+0000 us-east-1a aki-427d952b monitoring-disabled ebs paravirtual xen sg-f5a0899c default INSTANCE i-3faa9f5e ami-43b5752a pending john2.kp 8 m1.large 2011-08-22T04:49:45+0000 us-east-1a aki-427d952b monitoring-disabled ebs paravirtual xen sg-f5a0899c default INSTANCE i-01aa9f60 ami-43b5752a pending john2.kp 9 m1.large 2011-08-22T04:49:45+0000 us-east-1a aki-427d952b monitoring-disabled ebs paravirtual xen sg-f5a0899c default

You’ll see this action reflected in your console, and you’ll understand why Amazon asked for your credit card information up front.

您会在控制台中看到此操作,并且会明白为什么Amazon会先要求您提供信用卡信息。

This concludes our three part series on setting up a development sandbox with Amazon EC2. We started with our head in the clouds and ended with an AMI in the cloud. Amazon is a surprisingly cheap sandbox so long as you are mindful of your usage. Turn instances off when they’re not in use and be sure to familiarize yourself with their pricing.

至此,我们分为三部分,介绍了如何使用Amazon EC2设置开发沙箱。 我们从云端开始,最后到云端的AMI。 只要您注意使用情况,亚马逊是一个非常便宜的沙盒。 在不使用实例时将其关闭,并确保熟悉其定价 。

Image via Lightspring / Shutterstock

图片来自Lightspring / Shutterstock

翻译自: https://www.sitepoint.com/from-zero-to-cloud-setting-up-an-ec2-sandbox-part-3-2/

支付宝沙箱设置

最新回复(0)