Reputation: 19
I have always developed PHP locally on my machine, then uploaded to a web server via FTP. I can't seem to wrap my head around how to get my code onto Google App Engine. I went through the "hello world" PHP example. 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.
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?
Thank you.
Upvotes: 0
Views: 892
Reputation: 11
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. After uploading your .php files follow the steps:
After the deployment you can view your web app by using the command: gcloud app browse
Paste this code in your app.yaml file
runtime: 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.
Upvotes: 1
Reputation: 6841
App Engine is different than what you're used to with web hosting providers. When you deploy an your application to App Engine you aren't pushing files to a remote folder on a server. 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.
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.
You will also use gcloud app deploy
to deploy your app rather than a tool like 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.
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. And for small sites it has a free tier instead of spending money with a standard hosting provider.
Upvotes: 2