Sunday, September 02, 2012

Installing ownCloud on OpenShift

ownCloud is an open source solution that allows you to have your own on-premise Dropbox clone. It comes complete with a server side and clients that can be used to sync files across clients. The latest version introduced some new features including:


  • versioning of files
  • server side encryption
  • drag and drop upload
  • theming
  • ownCloud Application APIs
  • migration and backup
  • tasks management
Now its also possible to run it on Red Hat's OpenShift using a quickstart that I recently created - owncloud-openshift-quickstart 

As I've learned in the past, files aren't persisted in the OPENSHIFT_REPO_DIR in between commits so files are stored in the OPENSHIFT_DATA_DIR location to persist the files in between commits.  Also, since there is a limited amount of disk space per Openshift application instance, I've configured this example to use a mysql backend, but sqlite and postgres are also possible.  

A mostly undocumented feature (with the exception of the mail list archives) that is essential in automating the install, I used the AUTOCONFIG option in ownCloud.  To do this do the following:
  • create an autoconfig.php file in the php/config/ directory
  • add the following to it to use the OpenShift environment variables for configuration:



     
<?php
define("DIRECTORY",$_SERVER['OPENSHIFT_DATA_DIR'] );
define("DBNAME",$_SERVER['OPENSHIFT_APP_NAME'] );
define("DBUSER",$_SERVER['OPENSHIFT_DB_USERNAME'] );
define("DBPASS",$_SERVER['OPENSHIFT_DB_PASSWORD'] );
define("DBHOST",$_SERVER['OPENSHIFT_DB_HOST'] . ':' . $_SERVER['OPENSHIFT_DB_PORT'] );
$AUTOCONFIG = array(
  'installed' => false,
  'dbtype' => 'mysql',
  'dbtableprefix' => 'oc_',
  'adminlogin' => 'admin',
  'adminpass' => 'OpenShiftAdmin',
  'directory' => DIRECTORY,
  'dbname' => DBNAME,
  'dbuser' => DBUSER,
  'dbpass' => DBPASS,
  'dbhost' => DBHOST
);
?>
Then make sure to call the index.php to trigger the import of the autoconfiguration of ownCloud. To do this, I add the following code to the post_deploy action-hook:
  • php $OPENSHIFT_REPO_DIR/php/index.php
This is in the early stages and I haven't done anything with the Sync Clients. So feel free to fork away and submit those pull requests.


Post a Comment