OpenShift notes

THIS IS FOR ARCHIVAL PURPOSES. THIS IS OUT-OF-DATE

backup OpenShift

openshift getenv(USER) from OpenShift php
ssh to {user}@{app-domain} gear snapshot  > file

Run gear app

OpenShift migration further notes

Encrypt a file using a supplied password :

$ openssl enc -aes-256-cbc -salt -in file.txt -out file.txt.enc -k PASS

Decrypt a file using a supplied password :

$ openssl enc -aes-256-cbc -d -in file.txt.enc -out file.txt -k PASS

Add script to tar plugin, then rhc a SSH key into account, ssh to account and tar x data...

  1. get target directory
  2. clean-up target directory
  3. extract new contents

Probably can use deploy as an example...

  • need to list images that have been uploaded to S3.
  • need to convert imgsrc references...

? wordpress filters vs hooks ?

Sample stuff:

Skeleton

Mangle data when saving

post types ... perhaps we add an S3 flag to the post type: Attachment

WordPress

Standard Customizations:

  1. Appearance
  2. Set theme
  3. Site Identity
  4. Header & Background iamge
  5. Menus: Set-up top bar?
  6. Settings
  7. General Settings
    1. Membership: Not anyone can register
    2. Timezone UTC
    3. Date/Time Format
  8. Reading
    1. For each article in the feed: Show full text
  9. Discussion
    1. Users must be registered to comment. Not fill out name+email
    2. Comments author must have previously approved comment
  10. Permalinks
    1. Month and name

Plugins

  • Front Page Category
  • Customizer, Front Page Categories, select what to show
  • Collapsing category list
  • Customizer, Widgets, Categories, customize...
  • bbPress
  • NO anonymous posting
  • WP Social Login
  • Bouncer
  • Allow Username change
  • Rich Revies
  • Integrate user accounts

OpenShift Recipe

The official deploy tool dpl does not seem to work with secondary branches.

Pre-requisistes

  1. Install git
  2. Install RHC command line
  3. yum install epel-release
  4. yum install rubygem-rhc
  5. Install Travis command line
  6. yum install epel-release
  7. yum install ruby-devel rubygem-ffi (maybe others)
  8. gem install travis -v 1.8.2 --no-rdoc --no-ri
  9. A github, travis-ci and opens

Preparing Repo

This section can be skipped if we already have a github repo.

  1. Fork wordpress-example
  2. Create any additional branches as needed.
  3. Configure travis-ci by creating a basic .travis.yml
  4. language: php
  5. php:
    • '5.4'
  6. script: true
  7. Since travis setup openshift doesn't work, we need to use the DIY deploy script. So make a copy of it. And configure:
  8. env:
  9. _ global:
  10. __ OPENSHIFT_USER=$username
  11. __ OPENSHIFT_SECRET=$secret
    1. Obviously the secret should be encrypted using:
      • travis encrypt OPENSHIFT_SECRET=$secret [--add env.global]
  12. script:
    • sh deploy.sh
  13. diydeploy:
    • deploy $branch:$openshift_app ... initially empty...

Deploying Repo to OpenShift App

  1. Create a new Application from the Openshift console.
  2. Use (WordPress 4)
  3. Just leave initial repo to the default
  4. Decide on scaling options.
  5. DO NOT GO THROUGH SITE INSTALL YET!
  6. Add the $branch:$openshift_app to the .travis.yml, and push so travis-ci will deploy.
  7. Tweak configuration:
  8. force https through .htaccess.
  9. Enable MULTISITE (if needed)
  10. Enable custom domain
  11. Create Domain Name (on DNS) and add custom domain in OpenShift
  12. Add Certificate to OpenShift (self-signed or maybe CloudFlare)
    • openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 3650 -nodes
  13. Wait for DNS to propagate
  14. Log-on to the site and go through installation.
  15. Verify that URLs use https:
    • Dashboard -> Settings -> General
    • Verify in Permalinks that https is used.

Fork syncing

   - Clone repo
   - Configure a remote fork
     1. git remote -v
     2. git remote add upstream https://github.com/openshift/wordpress-example.git
   - Syncing a fork
     1. git fetch upstream
     2. git checkout master
     3. git merge upstream/master




      //define('DOMAIN_CURRENT_SITE', 'dev.iliu.net');
      if ($_SERVER['SERVER_NAME'] != 'dev.iliu.net') {
         define('DOMAIN_CURRENT_SITE', 'iliu.net');
      } else {
         define('DOMAIN_CURRENT_SITE', 'dev.iliu.net');
      }

openshift mailgun

Success! You're signed up and we just created your sandbox server sandboxf9dbaaa2f22a49a693955138381837e7.mailgun.org

Include the Autoloader (see "Libraries" for install instructions)

require 'vendor/autoload.php';
use Mailgun\Mailgun;

# Instantiate the client.
$mgClient = new Mailgun('key-xxxxxxxxxxxxxxxxxxxxxxxxx');
$domain = "sandboxf9dbaaa2f22a49a693955138381837e7.mailgun.org";

# Make the call to the client.
$result = $mgClient->sendMessage("$domain",
                  array('from'    => 'Mailgun Sandbox <[email protected]>',
                        'to'      => 'Alejandro Liu <[email protected]>',
                        'subject' => 'Hello Alejandro Liu',
                        'text'    => 'Congratulations Alejandro Liu, you just sent an email with Mailgun!  You are truly awesome!  You can see a record of this email in your logs: https://mailgun.com/cp/log .  You can send up to 300 emails/day from this sandbox server.  Next, you should add your own domain so you can send 10,000 emails/month for free.'));