Running Textpattern on OpenShift

Yes, it is possible to run Textpattern on Red Hat’s OpenShift platform, this weblog is running there right now.

  1. Sign up for an OpenShift account and install the command line tools
  2. Create an application: rhc app create txpblog php-5.4 mysql-5.5 cron-1.4
  3. cd into txpblog
  4. Unpack your version of textpattern and place the textpattern directory, other directories, and php files into the base directory of the project
  5. commit the change to git
  6. push to OpenShfit with a git push
  7. visit txpblog-domain.rhcloud.com/textpattern/setup.php in your browser to do the setup (you’ll need the mysql username, password, and database name from the output of rhc app show to pass the setup test to get to step 2)
  8. edit the config.php file, but use OpenShift env variables for the mysql connection information and the root directory as shown below
  9. commit and push the change to your OpenShift repo
  10. continue with the setup and when it says to remove setup.php (in step 4), remove it from your local git repo (git rm -r textpattern/setup) and then commit and push the change to the OpenShift repo

Here’s what a config.php file running on OpenShift will look like using the environment variables:

<?php
$txpcfg['db'] = 'txpblog';
$txpcfg['user'] = getenv('OPENSHIFT_MYSQL_DB_USERNAME');
$txpcfg['pass'] = getenv('OPENSHIFT_MYSQL_DB_PASSWORD');
$txpcfg['host'] = getenv('OPENSHIFT_MYSQL_DB_HOST');
$txpcfg['table_prefix'] = '';
$txpcfg['txpath'] = getenv('OPENSHIFT_HOMEDIR') . '/app-root/runtime/repo/php/textpattern';
$txpcfg['dbcharset'] = 'utf8';
?>

Using the environment variables makes it easier to use the same config file if you want to use the same git repo to be both your staging site for changes and for your production site running on a different gear.

Friday August 14, 2015   ·   Permalink