is it possible install Grav on Google App Engine? How?
I don’t think it’s possible to install with Google-App-Engine because of the restriction on writing to the file system. This is obviously a major issue for a file-based CMS such as Grav:
https://cloud.google.com/appengine/kb/java?csw=1#writefile
However, it should be possible to deploy a Vagrant box to Google-Compute-Engine as this is supported by PuPHPet:
I wrote up a blog post the other day about developing with Vagrant, and you could easily upload the puphpet/config.yml
file into puphpet.com and fill in your Compute Engine information.
http://getgrav.org/blog/grav-development-with-vagrant
I have never tried this though, so let me know how it goes!
Reading a little further, it does seem like you can read/write files to Google Cloud Storage with the use of stream wrappers:
https://cloud.google.com/appengine/docs/php/googlestorage/
However, this is currently not tested at all, so not sure if it works or not
You will however, have to mimic the .htaccess
functionality in your app.yaml
https://cloud.google.com/appengine/docs/php/config/appconfig
Oh one other newer option: Google-Container-Engine lets you run docker containers. This could be a great solution for Grav. Again not tried this either.
Is it okay to continue on this old thread? For anybody still looking for an answer: Google now has this Cloud Launcher thing. I tried with the click to deploy LAMP stack and it works great. Figuring out the access rights was a bit of a nightmare for me (to connect via sftp and then to give the rights back to the Apache server) but that’s because I’m a complete newbie.
Which cloud launcher thing? URL?
Well, literally Google Cloud Launcher
One year later…
I would love to run Grav on Google App Engine, but although I can read the code to some extent and even make local changes I’m not a real programmer and I would definitely need guidance to pull it off.
What seems to be needed is basically the following.
-
Route all writable paths to a Google Storage bucket. Every GAE app has a default 5G bucket named after the project ID. Since it’s shared by all GAE apps running on the same project (called services in App Engine lingo), a good default root path could be
gs://project-id.appspot.com/grav
. I changed all Grav’s directories to read-only under local dev Apache server, and it complained about not being able to write to:cache, logs, images, assets, user/data, backup, tmp
. Maybe it’s possible to make some of those read only? Or route them differently? Maybetmp
could be set usingsys_get_temp_dir()
, which returns the local GAE tmp. App Engine supportsmemcache
so maybe cache could be routed there? Logs could maybe go directly to GAE syslog service so they can be seen on Google Console? There is a catch though: Google Storage buckets don’t support everything (see https://cloud.google.com/appengine/docs/standard/php/googlestorage/advanced#php_filesystem_functions_support_on_google_cloud_storage). -
Port the
.htaccess
rules to routing in theapp.yaml
file as mentioned above. Or maybe use/modify themod_rewrite.php
provided by Google https://cloud.google.com/appengine/docs/standard/php/config/mod_rewrite. -
Debug issues. For example, I just tested Grav changing
CACHE_DIR
insystem/define.php
to a Google bucket (gs://<my_project_id>.appspot.com/grav/cache/
) and got the same error and stack trace either locally or deploying the app. It seems to be caused byfopen
being limited to['r', 'rb', 'rt’]
and['w', 'wb', ‘wt’]
(see lines 46 and 47 in https://github.com/GoogleCloudPlatform/appengine-php-sdk/blob/master/google/appengine/ext/cloud_storage_streams/CloudStorageStreamWrapper.php).
Warning: fopen(php://stdout): failed to open stream: Unknown stream type php://stdout. in /<path>/grav/vendor/symfony/var-dumper/Dumper/AbstractDumper.php on line 65
Fatal error: Uncaught exception 'RuntimeException' with message 'Opening file for writing failed on error fopen(gs://<project_id.appspot.com/grav/cache/compiled/files/39f55e78947e5291883179f639afb4fc.yaml.php): failed to open stream: "\google\appengine\ext\cloud_storage_streams\CloudStorageStreamWrapper ::stream_open” call failed' in /<path>/grav/vendor/rockettheme/toolbox/File/src/File.php:202
Stack trace:
#0 /<path>/grav/vendor/rockettheme/toolbox/File/src/File.php(316): RocketTheme\Toolbox\File\File->lock()
#1 /<path>/grav/vendor/rockettheme/toolbox/File/src/PhpFile.php(31): RocketTheme\Toolbox\File\File->save(Array)
#2 /<path>/grav/system/src/Grav/Common/File/CompiledFile.php(67): RocketTheme\Toolbox\File\PhpFile->save(Array)
#3 /<path>/grav/system/src/Grav/Common/Config/Setup.php(178): Grav\Common\File\CompiledYamlFile->content()
#4 /<path>/grav/system/src/Grav/C in /<path>/grav/system/src/Grav/Common/File/CompiledFile.php on line 83
But if I edit vendor/rockettheme/toolbox/File/src/File.php
(just to test, I know vendor code should not be edit) line 198 and change cb+
to the supported mode wb
I get an error when parsing user/config/site.yaml
:
Warning: fopen(php://stdout): failed to open stream: Unknown stream type php://stdout. in /<path>/grav/vendor/symfony/var-dumper/Dumper/AbstractDumper.php on line 65
Fatal error: Uncaught exception 'Symfony\Component\Yaml\Exception\ParseException' with message 'Unable to parse at line 3 (near " name: Marco L Abreu").' in /<path>/grav/vendor/symfony/yaml/Parser.php:256
Stack trace:
#0 /<path>/grav/vendor/symfony/yaml/Yaml.php(65): Symfony\Component\Yaml\Parser-parse('title: Grav
aut...', false, false, false)
#1 /<path>/grav/vendor/rockettheme/toolbox/File/src/YamlFile.php(82): Symfony\Component\Yaml\Yaml::parse('title: Grav
aut...’)
#2 /<path>/grav/system/src/Grav/Common/File/CompiledFile.php(57): RocketTheme\Toolbox\File\YamlFile->decode('title: Grav
aut...’)
#3 /<path>/grav/system/src/Grav/Common/Config/CompiledConfig.php(99): Grav\Common\File\CompiledYamlFile->content()
#4 /<path>/grav/system/src/Grav/Common/Config/CompiledBase.php(160): Grav\Common\Config\CompiledConfig->loadFile('site', '<path>...’)
#5 /Users/<user> in /<path>/grav/system/src/Grav/Common/File/CompiledFile.php on line 83
Fatal error: Access to undeclared static property: google\appengine\runtime\ApiProxy::$apiProxy in /<path>/google-cloud-sdk/platform/google_appengine/php/sdk/google/appe ngine/runtime/ApiProxy.php on line 36
ApiProxy.php code is here: https://github.com/GoogleCloudPlatform/appengine-php-sdk/blob/master/google/appengine/runtime/ApiProxy.php
Running Grav using a vanilla install and the dev web server from Google Cloud SDK, also throws an error saying something like: a session could not be created because another session already exists. Well, baby steps, right?
In any case, I think GAE it’s a great backend for Grav users and developers. First, up to a certain amount of processing and traffic, it’s free. It kills all instances if there’s nothing going on, like Heroku, but boots back in milliseconds to respond to traffic. And it can scale to millions of access per minute in that same amount of time (that will cost something :). I also like the maintenance free backend, letting Google handle configuration, security, etc.
There are other apps already ‘ported’, like CakePHP, Symfony CMF and Wordpress, code available on Github:
In the case of CakePHP, it’s also possible to deploy from a vanilla Composer installed instance using version 3.3.16 following (sort of, some things changed the place from 2.0 to 3.3) this guide: http://dev-mcconnell.blogspot.lu.
So, is there anyone interested in getting this going?