Tuesday, September 11, 2012

Proxy Error 502, Wordpress, and OpenShift

I host the DC JBoss Users Group wordpress site (http://www.dcjbug.com) out on Openshift. This Site serves as an aggregation portal for out meetup events, jboss.org page and other interesting JBoss content.

Occasionally run into 502 Proxy Errors. After some research, I discovered that in my case it is because I routinely exceed my Disk Quota.

 I have added the WordPress Database Backup plugin and use that to periodically back up my wordpress database. However, its clearly the culprit here as the output quickly chews up free disk space.

To recover from this, remove the old backups from the server. I should add a cron job to do this, but for now, here are the manual steps that I follow:

  • ssh into my blog app on openshift ssh 
  • navigate to the wp-content directory 
    • cd app-root/runtime/repo/php/wp-content/backup-#### 

  • remove old backups 
    •  rm blog_wp_201208* 
  • logout 
  • restart the application on OpenShift 
    • rhc app restart -a blog -l {your_openshift_login}

 And magically the DC JBUG Blog is back online.

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:

$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.