Run PHP in Google Cloud Storage Bucket - php

I can't get run PHP in Google Cloud Storage. Every time it downloads the page instead of run.
I saw in Documentation Troubleshooting, if page get's downloadet change Meta Type to text/HTML
Instead of run PHP it looks like, if you see a PHP site in XAMPP with inactivate server.
Do I have to install client libaries on Google Cloud to get PHP run, or Appache?
What can I do to get PHP run?

Google Cloud Storage does not provide compute services. Cloud Storage only supports static web sites.
PHP requires compute services provided by services such as App Engine, Compute Engine, etc. Also, you cannot install Apache on Cloud Storage. Typically PHP is "hosted" by a web server such as Apache or Nginx.
Google offers a number of services to host a website. You can continue to store your static assets (images, JavaScript, css, etc.) on Cloud Storage.
Google Cloud web hosting services

Related

Can I write/read Google Cloud Storage from my website which is not a Google App Engine?

Can I write (and read) files using PHP in my google cloud storage when Im not using a Google App Engine?
In other words, may I have my website running on another web hosting and use google cloud to store (and read in future) my JSON files only? the JSON files need to be written on runtime and by users.
you can store any files using any programming language like PHP to any cloud storage like google cloud storage or amazon s3, dropbox...etc
Checkout this documentation:
https://github.com/GoogleCloudPlatform/google-cloud-php#google-cloud-storage-ga

PHP via Amazon S3 for Android App

I have developed an Android app which does a GET/PUT operations with a test web server for fetching and storing data in JSON format. For PUT using a PHP script on webserver via parameters in url. Now to scale the solution, i am exploring AWS solutions. How to achieve PHP script based logic handling on webserver with AWS S3 or any other cloud based storage which can perform this php based logic handling.
I would recommend to use AWS Lambda- It doesn't need servers to be hosted and maintained, which is a big headache. With AWS Lambda, in few minutes you can get your web application running. Your PHP scripts can be hosted as service and AWS will take care of its scalability and availability.
https://www.youtube.com/watch?v=eOBq__h4OJ4
https://aws.amazon.com/serverless/build-a-web-app/
https://aws.amazon.com/blogs/compute/scripting-languages-for-aws-lambda-running-php-ruby-and-go/
AWS S3 you can use for storing your static files like images, css, javascript etc...

PHP stream wrapper for Google Cloud Storage

I am in a process of setting up Prestashop installation in a cluster of 3 GCE instances, managed by Kubernetes. I use Cloud SQL as DB and all seems to be running well, except, of course the images part, since prestashop in each pod uploads and shows images to/from it's local filesystem.
In App Engine I cloud use stream_context_set_default() and that would allow me to use "gs://mybucket" as a regular path. Is there a way to do that in Compute Engine? If it is possible, making Prestashop use Cloud Storage bucket can be done in 2 lines of code.
There is a StreamWrapper for Amazon S3 service that does exactly what I need: http://hiousi.tumblr.com/post/94824087894/prestashop-images-hosted-on-amazon-s3
But I would like to use Cloud Storage.
The source code for the stream wrapper can be downloaded at https://github.com/GoogleCloudPlatform/appengine-php-sdk/tree/master/google/appengine/ext/cloud_storage_streams.
It has a couple of dependencies on other GAE APIs such as App Identity & Urlfetch. They may need to be stubbed out or replaced by equivalent services on GCE.
i have created a PHP StreamWrapper for Google Compute Engine, if you're still interested. Here is the link to my adapted version.
https://github.com/jimyaghi/GCECloudStorageStreamWrapper
Sorry it's not more friendly, but it's a good useful bit of work. i'm using it and it works great.

Deploying Azure Cloud Service on a Schedule

I want to host an Azure Website and I need to run a PHP script on the site every hour. Usually I would do something like this using cron jobs. Is Azure WebJobs via Azure Scheduler the only option to accomplish this?
Using PHP or a REST API via PHP cURL, how do I create and deploy an Azure cloud service worker role to run some back-end PHP software independent of the website?
How would pricing work for the cloud service? Would I only be paying while it is deployed, or would I be paying when it is created also? E.g. Could I create the service via Azure portal and deploy via PHP to get same pricing with less coding?
How do I stop a cloud service once it is done processing?
You can use the Azure WebJobs under the website as you pointed out. You can also use the Azure scheduler direct and have it fire a call to another website or even an external system somewhere to kick something off. There is also a scheduler in the Azure Marketplace you could look at. Another option is the Azure Automation, which allows you to run a script separate from a web site or other deployment, though is PowerShell.
You can create deployments using the Azure Management REST API. Here is some documentation on how to use the API from PHP. As for running this independent from the website, you'd either need to run this from an external system, or from a VM running within Azure.
You pay for the Cloud Service from time it starts its deployment until the deployment is deleted. You pay only when something is deployed to the Cloud Service. If you create a cloud service via the portal or script, but don't deploy anything, then you aren't charged anything. When you deploy something into the cloud service you will be charged for as long as the deployment is there.
Based on this question I'm assuming you mean the cloud service is some sort of back end processing. You could have the cloud service use the management api to shut itself down, but that would require that the management certificate be deployed with the cloud service, which some people don't like to do for security reasons. Other folks would have the worker roles push messages to an external system, or another service running in Azure, to say that they are done and it would then reach out and shut them down. There are really several options here depending on if you want it all managed in the cloud or have resources elsewhere that would perform the shutdown. The link to the management APIs above will give you "how to" shut them down, but the decision on what does that is really pretty open.

Cloud Apps vs Web Apps

I have 2 questions:
First, what's the difference between a web application and a cloud application? Are there any differences at all? If I'm developing a web application (a site with many interactive features), can I call it a cloud application?
Second, if there's a difference between a cloud and web application, what languages can cloud applications be developed in? Would a scripting language like PHP be useful for that?
Thanks.
UPDATE: I have watched the video in one of the answers, but I am still a little confused. Taking Google Docs as a example, all I see is a user interface that can be created with html and JS, along with a server script, and the data is stored in a database, which is basically the same thing a web application does. Or is it different?
Thanks
Web applications can run on "the cloud". The cloud is basically a collection of dynamic computational resources (cpu, ram, storage etc) that can be used by web applications.
This allows apps running on the cloud to scale well because they are allocated resources dynamically.
You can use public clouds such as Amazon's EC2 - or build your own private clouds.
A web app running on a cloud isn't exactly a "cloud app" - but the app is simply hosted on a cloud.
I find the first half of this video explains it very well (if a little annoying).
Also see this quesiton which has some good answers.
A web application is an just an application deployed on a web server.
The user accesses this application knowing that it is accessing a remote application and this application has a specific purpose.I.e. implements a specific functionality.
When you start talking about the cloud, you have a different concept alltogether.
The idea is that you want to access a service that you have no idea where the service actually is being deployed.
The main benefit is that a company can save resources.
For example a company can have e.g. their own CRM and have to pay money for servers, for IT personel etc. or just access a service in a "cloud" where the company providing the cloud is responsible for the servers etc.
So to answer your question, to build the cloud you use web applications as "modules" to provide the cloud.
But a web application by itself (separate of this context) can not be considered as cloud application (unless it runs as part of the cloud).
Anything that runs locally can run in a "cloud". Cloud computing is the inevitable movement of traditional applications/processes to a dedicated provider. Analogous to the Walmart syndrome, where little mom and pop shops have fallen by the wayside.
The difference between a cloud and web application is where it sits.
Web and cloud apps both are distributed applications having server and client parts. They store data on a server side, but can have local data cache for offline cases.
Web applications performed/run by browsers. Normally, they are written on HTMP/CSS/JavaScript. Adobe had another vision of client parts. They proposed special Flex language for Abobe Flash as client run-time environment (prior it has been killed this year).
Cloud apps are very similar to web apps, but their client parts are native applications specially developed to run on selected target platforms (OS X, Win, iOS, etc.)

Categories