How to Rub Joomla CMS 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:
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:
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:
// 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:
// 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:
// 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:
appcfg.py update /rootfolder/
 
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Changing .htaccess for Joomla 3.0 to use PHP version 5.3.x

Joomla 3.0 require PHP version 5.3 and above to run. All our servers support (i.e. are capable of...

How to make a Joomla 3.0 SEF (Search Engine Friendly)

Search Engine Optimization competition is getting tougher everyday and therefore it is important...