Advertisement

HOW TO: Run Joomla! on Google App Engine

General questions relating to Joomla! 3.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Locked
viezel
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sun Feb 27, 2011 12:08 pm

HOW TO: Run Joomla! on Google App Engine

Post by viezel » Thu Dec 05, 2013 7:49 am

Hi JCommunity!

Ive managed to get Joomla 3.2 running on Google App Engine (GAE).

How to get Joomla! running on Google App Engine

Before we start, please do this simple tutorial to understand the basics of GAE: https://developers.google.com/appengine ... troduction

1. Install Joomla elsewhere

We need to install Joomla Elsewhere and copy the installed joomla into a new folder called joomla (/root/joomla/) in your GAE root folder, since Google App Engine has no read/write access to the filesystem. The same goes for the MySQL - after succesful installation, make a dump and use it on a local mysql.

2. Create a app.yaml file:

Code: Select all

application: joomla-gae
version: 1
runtime: php
api_version: 1

handlers:
- url: /(.*\.(htm$|html$|css$|js$))
  static_files: joomla/\1
  upload: joomla/(.*\.(htm$|html$|css$|js$))
  application_readable: true
  secure: always

## Admin  
- url: /administrator(.+)
  script: joomla/administrator\1
  secure: always

## Asset folders
- url: /media
  static_dir: joomla/media
  application_readable: true
  
- url: /images
  static_dir: joomla/images
  application_readable: true

## Template folders
- url: /templates
  static_dir: joomla/templates
  application_readable: true
  
- url: /administrator/templates
  static_dir: joomla/administrator/templates
  application_readable: true

## SEO robots
- url: /robots.txt
  script: joomla/robots.txt 

## Site access
- url: /(.+)?/?
  script: joomla/index.php
  secure: always
3. Create a php.ini file in the same root folder and add the following lines:

Code: Select all

google_app_engine.enable_functions = "php_sapi_name, gc_enabled, libxml_disable_entity_loader"
allow_url_include = "1"
4. Edit configuration.php

- Disable SEF and SEF rewrite
- Disable mail (for now - on GAE we need to use their mail infrastructure)
- Update the mysql connection settings
- Cache Handler = 'memcache';

5. Edit /libraries/joomla/language/language.php

Add libxml_disable_entity_loader(false); to /libraries/joomla/language/language.php line 1354

Code: Select all

// Try to load the file
libxml_disable_entity_loader(false); // add this line
$xml = simplexml_load_file($path);
6. Override the filesystem based JLogger.

This part is quite a hack. Since joomla uses jImport to require the classes, its possible to define the class in the index.php file before the $app = JFactory::getApplication('site'). This way we override the default class with the below dummy class, that does not anything to the filesystem (which is not possible on GAE).

Code: Select all

// HACK: OVERRIDE - we do not want the filesystem based logger
class JLogLoggerFormattedtext extends JLogLogger
{
	public function __construct(array &$options){ parent::__construct($options); }
	public function __destruct(){}
	public function addEntry(JLogEntry $entry){}
	protected function generateFileHeader(){}
	protected function initFile(){}
	protected function parseFields(){}
}
7. You should have the following in your project folder

/root/app.yaml
/root/php.ini
/root/joomla/

8. Cloud SQL

We need to create a MySQL server and database in order to make joomla work.
You need to start by reading this: https://developers.google.com/appengine ... cloud-sql/

- Create a sql instance, and add your GAE app in the Authorized App Engine Application.
- By default, the user root with no password can access the Cloud SQL. You can use this for testing.

- Now you need to import the sql dump from the old joomla installation. This is done by using a Google Storage Bucket. Read the instructions here: https://developers.google.com/cloud-sql ... rt#migrate

You can use the below script to test if you have access to the Cloud SQL server from GAE.

Code: Select all

// test script
mysql_connect(":/cloudsql/instance:database", "root", "")  or die ("Could not connect to server");
mysql_select_db($db) or die ("Unable to select database!");
$result = mysql_query("SELECT name, element FROM josgae_extensions"); 
while(list($name, $element)  = mysql_fetch_row($result)) { echo $name." ".$element."<br/>"; }
mysql_close();
9. Deploy & enjoy

Code: Select all

appcfg.py update /rootfolder/

Thats it. It should work now.

Hope you all got it working by now!
Last edited by toivo on Tue Mar 27, 2018 4:54 pm, edited 2 times in total.
Reason: mod note: manual signature removed, please read the forum rules at https://forum.joomla.org/viewtopic.php?f=8&t=65

Advertisement
viezel
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sun Feb 27, 2011 12:08 pm

Re: HOW TO: Run Joomla! on Google App Engine

Post by viezel » Thu Dec 05, 2013 10:12 pm

Ive managed to make it work, so I updated the original post.
Hope it helps someone.

bndoshi
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Wed Feb 19, 2014 8:17 am

Re: HOW TO: Run Joomla! on Google App Engine

Post by bndoshi » Wed Feb 19, 2014 8:41 am

Thanks for the detailed info viezel,

Since App Engine does not allow read/write to filesystem, I am wondering how does the following work:
1. Joomla Updates
2. Logging and Cacheing
3. Image/Document upload from frontend or backend

Thanks
Bhavin

User avatar
IberoMedia
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 126
Joined: Mon Apr 12, 2010 3:25 am
Contact:

Re: HOW TO: Run Joomla! on Google App Engine

Post by IberoMedia » Fri Feb 21, 2014 11:01 am

viezel,

On your instructions you indicate to disable SEF. Does this means we'll have index.php?component=... as our urls?

Thank you

rich_au
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Fri May 10, 2013 1:56 pm

Re: HOW TO: Run Joomla! on Google App Engine

Post by rich_au » Wed Mar 12, 2014 10:30 pm

Viezel
thanks for your detailed instructions, I can't get this even close to working though. Even locally I am stuck with the following error.
Error displaying the error page: Application Instantiation Error
I also get unknown errors when importing my database from google storage to the cloud sql.

when you say;
- Update the mysql connection settings
do you mean that you have to be running this off google SQL? ie i have to include the google ip address in my configuration.php file?

thanks
Richard

User avatar
freedomoss
Joomla! Apprentice
Joomla! Apprentice
Posts: 12
Joined: Sat Sep 17, 2005 3:33 pm

Re: HOW TO: Run Joomla! on Google App Engine

Post by freedomoss » Sat May 10, 2014 4:58 am

hi viezel,

it seems it won't install using dev_appserver.py. it is better to run in my local dev before uploading to hosted GAE using appcfg.py update [application].

gavdials
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Thu Nov 20, 2014 4:54 pm

Re: HOW TO: Run Joomla! on Google App Engine

Post by gavdials » Thu Nov 20, 2014 5:35 pm

I wonder if anyone ever was able to use Joomla on GAE with this guide. I've followed it very carefully, but it's very short and incomplete. Keep getting error in browser: "Error displaying the error page: Application Instantiation Error: Could not connect to MySQL."

I've not found any better help around too.

I'm not an expert. So forgive me if I'm wrong.

I looked up the code trying to understand the issue. As far as I can see is that google App Engine SQL connection in this page: https://cloud.google.com/appengine/docs ... sql/?hl=cs
requires to enter the projejec ID, and the Instance name as for the mySqli connection object
this way:

Code: Select all

$sql = new mysqli(null,
  'root', // username
  '',     // password
  <database-name>,
  null,
  '/cloudsql/<your-project-id>:<your-instance-name>' // <- *in joomla no where is this entered*
  );
I've looked up in the code of Joomla and there's no where that the Socket argument for the MySql constructor ever used. It is actually set to NULL in the code. And in there's no $socket member object in configuration.php to be passed to the mysqli constructor.

I guess this is not usually used in other host that GAE, but it is obviously necessary here.
I think a patch to or good instructions for this will be very helpful.

Again, I'm no expert. pleas help as soon as possible. My GAE SQL quota is running. :-\
Thanks

davidascher
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 157
Joined: Tue Feb 28, 2006 3:23 pm

Re: HOW TO: Run Joomla! on Google App Engine

Post by davidascher » Tue Mar 27, 2018 2:15 pm

by now (March 2018) things have evolved considerably and there must be 3rd party tools as well as additional services from Google that make this task much easier. Right?

If anybody has a guide to moving an existing Joomla installation to either the Google or Amazon clouds, it would be a wonderful thing to share.

Unisoftdev
Joomla! Apprentice
Joomla! Apprentice
Posts: 49
Joined: Mon Feb 22, 2016 4:58 am
Location: London, UK
Contact:

Re: HOW TO: Run Joomla! on Google App Engine

Post by Unisoftdev » Sat Dec 15, 2018 8:21 am

It's nice to see the problem-solving sole, enthusiasm, and I think that there can be some projects with a special needs those can really suit, however, from the general perspective, App Engine isn't very suitable from the technological and also economical point of view. Perhaps, just as a balancer for PHP related processing tasks (running and paid just for the short periods instead of a server running 24/7).

bndoshi wrote: Wed Feb 19, 2014 8:41 am Since App Engine does not allow read/write to filesystem, I am wondering how does the following work:
1. Joomla Updates
2. Logging and Cacheing
3. Image/Document upload from frontend or backend
It's not included in App Engine packages, but you can use their storages for additional costs. The more promising usage, you can cluster it (there'll be a main/parent installation on a remote server as a source for child servers, waking up the App Engine instance connected to the same MySQL/Maria database on a remote server) then it's a banality. In this way, the instance on App Engine doesn't have to run 24/7 and can be comfortably managed from some else server which uses the instance as a slave for load balancing tasks, not a fully independent server.
You can connect. Grow your network, collaborate, and get one new follower : ))
https://www.linkedin.com/in/jurajvysvader
https://twitter.com/Unisoftdev1

Advertisement

Locked

Return to “General Questions/New to Joomla! 3.x”