[英]How to deploy my PHP application to Google App Engine?
I have always developed PHP locally on my machine, then uploaded to a web server via FTP. 我一直在计算机上本地开发PHP,然后通过FTP上传到Web服务器。 I can't seem to wrap my head around how to get my code onto Google App Engine.
我似乎无法全神贯注于如何将代码导入Google App Engine。 I went through the "hello world" PHP example.
我介绍了“ hello world” PHP示例。 Following their instructions, it seems to work fine in the end, but I am at a loss as to how to apply those steps to my own app.
按照他们的指示,它似乎最终效果很好,但是我对如何将这些步骤应用于自己的应用程序感到困惑。 I simply don't understand what is happening through the deploy process using Google Cloud SDK.
我只是不了解使用Google Cloud SDK进行的部署过程中发生了什么。
Can anyone offer a simple step by step example that explains how this seemingly simple task can be accomplished? 谁能提供一个简单的分步示例来说明如何完成看似简单的任务?
Is there a way to use good ole' FTP? 有没有办法使用优质的FTP?
Thank you. 谢谢。
App Engine is different than what you're used to with web hosting providers. App Engine与您使用网络托管提供商所使用的不同。 When you deploy an your application to App Engine you aren't pushing files to a remote folder on a server.
将应用程序部署到App Engine时,并不是将文件推送到服务器上的远程文件夹。 You're effectively packaging them into a container that App Engine can use that container to serve possibly many instances of your app so that it can handle automatically scaling your app up and down and many other aspects.
您正在将它们有效地包装到一个容器中,App Engine可以使用该容器来服务您的应用程序的许多实例,以便它可以自动处理应用程序的上下缩放以及许多其他方面。
Your application is configured via the app.yaml
file where you register things like your URL handlers and how those map to individual PHP files. 通过
app.yaml
文件配置应用程序,在其中注册URL处理程序之类的内容,以及它们如何映射到单个PHP文件。
You will also use gcloud app deploy
to deploy your app rather than a tool like FTP. 您还将使用
gcloud app deploy
而不是FTP之类的工具来部署您的应用。 One nice thing about this, is that you can deploy multiple versions of your site simultaneously. 一件好事是,您可以同时部署网站的多个版本。 You can do pretty cool stuff with that like rolling back your site to a previous version if the latest version is "bad" or you can do traffic splitting to send some percentage of users to one version and the rest to another version.
您可以做一些很酷的事情,例如,如果最新版本为“不良”,则将站点回滚到以前的版本,或者可以进行流量拆分,以将一定比例的用户发送到一个版本,将其余用户发送到另一个版本。 You can use that functionality to A/B test aspects of your application to maybe see which version performs better with users.
您可以使用该功能对应用程序的各个方面进行A / B测试,以查看哪个版本的用户效果更好。
Overall, App Engine does require a bit of a shift in thinking from your standard hosting set up, but its a lot more powerful with less of an administrative burden on you. 总体而言,App Engine确实需要从标准托管设置中转变思路,但是它的功能要强大得多,而您的管理负担却更少。 And for small sites it has a free tier instead of spending money with a standard hosting provider.
对于小型网站,它具有免费套餐,而不是与标准托管服务提供商一起花钱。
If you have already created your .php files then start the google cloud shell, open the text editor, create a new folder inside the root directory and upload your .php files into that folder. 如果您已经创建了.php文件,请启动google cloud shell,打开文本编辑器,在根目录下创建一个新文件夹,然后将.php文件上传到该文件夹中。 After uploading your .php files follow the steps:
上传您的.php文件后,请按照以下步骤操作:
After the deployment you can view your web app by using the command: gcloud app browse 部署后,您可以使用以下命令查看您的Web应用程序:gcloud app browser
Paste this code in your app.yaml file 将此代码粘贴到您的app.yaml文件中
runtime: php55 api_version: 1 运行时:php55 api_version:1
handlers: 处理程序:
- url: /(.+\.(ico|jpg|png|gif))$
static_files: \1
upload: (.+\.(ico|jpg|png|gif))$
application_readable: true
- url: /(.+\.(htm|html|css|js))$
static_files: \1
upload: (.+\.(htm|html|css|js))$
application_readable: true
- url: /(.+\.php)$
script: \1
- url: /.*
script: index.php
and that's how you deploy your PHP web application in Google App Engine. 这就是您在Google App Engine中部署PHP Web应用程序的方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.