HOW TO: Run Joomla! on Google App Engine

General questions relating to Joomla! 3.x. Please consider the availability of third-party templates and extensions when deciding which Joomla version to use.

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.
viezel
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sun Feb 27, 2011 12:08 pm

HOW TO: Run Joomla! on Google App Engine

Postby 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/docs/php/gettingstarted/introduction

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/docs/php/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/docs/import-export#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!

Mads Møller
Napp ApS
http://www.napp.dk
Last edited by viezel on Thu Dec 05, 2013 10:14 pm, edited 1 time in total.

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

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

Postby viezel » Thu Dec 05, 2013 10:12 pm

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

jwaititu
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Mon Jun 07, 2010 6:29 am

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

Postby jwaititu » Sun Jan 26, 2014 10:18 am

How do i make the domain point to google servers. I have done all you had suggested, but I am wondering the IP address is will use to point A records to Google App Engine for my customer domain http://premiumwritingservice.com

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

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

Postby 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: 121
Joined: Mon Apr 12, 2010 3:25 am
Contact:

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

Postby 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
http://websonalized.com Small Business Web Design

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

Postby 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

Postby 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

Postby 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/php/cloud-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


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

Who is online

Users browsing this forum: fizznotch and 19 guests