drupal and open shift (and php)
DESCRIPTION
Steven presents with Openshift at DrupalCon PragueTRANSCRIPT
![Page 1: Drupal and Open shift (and php)](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f75edb4c9052a518b4708/html5/thumbnails/1.jpg)
DRUPAL AND OPENSHIFT (AND PHP)DRUPAL AND OPENSHIFT (AND PHP)
![Page 2: Drupal and Open shift (and php)](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f75edb4c9052a518b4708/html5/thumbnails/2.jpg)
DOBRÉ ODPOLEDNE!DOBRÉ ODPOLEDNE!GUTEN TAG!GUTEN TAG!
![Page 3: Drupal and Open shift (and php)](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f75edb4c9052a518b4708/html5/thumbnails/3.jpg)
STEVEN MERRILLSTEVEN MERRILLDIRECTOR OF ENGINEERING, PHASE2DIRECTOR OF ENGINEERING, PHASE2
![Page 4: Drupal and Open shift (and php)](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f75edb4c9052a518b4708/html5/thumbnails/4.jpg)
DRUPAL 8 QUICKSTARTDRUPAL 8 QUICKSTART
OPENSHIFT ONLINEOPENSHIFT ONLINE
![Page 5: Drupal and Open shift (and php)](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f75edb4c9052a518b4708/html5/thumbnails/5.jpg)
BUT FIRST,BUT FIRST,
![Page 6: Drupal and Open shift (and php)](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f75edb4c9052a518b4708/html5/thumbnails/6.jpg)
DRUPAL 8DRUPAL 8Needs PHP 5.3.5OpenShift Online runs RHEL 6.4RHEL 6.4 has PHP 5.3.3
![Page 7: Drupal and Open shift (and php)](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f75edb4c9052a518b4708/html5/thumbnails/7.jpg)
BUILDING A CARTRIDGEBUILDING A CARTRIDGEIf it runs on RHEL or Fedora, it will run on OpenShiftIUS provides PHP 5.3 and PHP 5.4 cartridges for RHELLet's make a cartridge from those RPMS
![Page 8: Drupal and Open shift (and php)](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f75edb4c9052a518b4708/html5/thumbnails/8.jpg)
RPMS TO CARTRIDGERPMS TO CARTRIDGEDownload themUse rpm2cpio to grab the binaries and files
is my script todo this from IUS reposAdd in the appropriate manifest and hooksHere are some examples of scripts from the PHP 5.4cartridge
https://github.com/smerrill/php-the-ripper
![Page 9: Drupal and Open shift (and php)](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f75edb4c9052a518b4708/html5/thumbnails/9.jpg)
RUNNING A VENDORED PHPRUNNING A VENDORED PHPThe toughest part: the path will change every timephp and php-fpm must be in $PATHPoint to php.ini with $PHPRCPoint to other .ini files with $PHP_INI_SCAN_DIRPHP and HTTP libraries live in $LD_LIBRARY_PATH
![Page 10: Drupal and Open shift (and php)](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f75edb4c9052a518b4708/html5/thumbnails/10.jpg)
CARTRIDGE SCRIPTSCARTRIDGE SCRIPTSBIN/SETUPBIN/SETUP
The setup script is responsible for creating
and/or configuring the files that were copied
from the cartridge repository into the gear’s
directory. Setup must also be reentrant and will
be called on every incompatible upgrade. Any
logic you want to occur only once should be
added to install.
![Page 11: Drupal and Open shift (and php)](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f75edb4c9052a518b4708/html5/thumbnails/11.jpg)
bin/setup
#!/bin/bash -eu
case "$1" in -v|--version) version="$2"esac
# Set the version if it is unset.[ -z "$version" ] && version=5.4.16
# Copy the version specific files up to php directoryshopt -s dotglob
mkdir -p $OPENSHIFT_PHP_DIR/configuration/etc/cp -Hr $OPENSHIFT_PHP_DIR/versions/shared/configuration/etc/* \ $OPENSHIFT_PHP_DIR/configuration/etc/
# Create additional directories required by PHPmkdir -p $OPENSHIFT_PHP_DIR/phplib/pear/{docs,ext,php,cache,cfg,data,download,temp,tests,www}mkdir -p $OPENSHIFT_PHP_DIR/{logs,run,tmp,sessions}
![Page 12: Drupal and Open shift (and php)](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f75edb4c9052a518b4708/html5/thumbnails/12.jpg)
CARTRIDGE SCRIPTSCARTRIDGE SCRIPTSBIN/INSTALLBIN/INSTALL
The install script is responsible for creating
and/or configuring the files that were copied
from the cartridge repository into the gear’s
directory. install will only be called on the
initial install of a cartridge.
![Page 13: Drupal and Open shift (and php)](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f75edb4c9052a518b4708/html5/thumbnails/13.jpg)
bin/install
#!/bin/bash -eu
case "$1" in -v|--version) version="$2"esac
# Set the version if it is unset.[ -z "$version" ] && version=5.4.16
echo "$version" > "$OPENSHIFT_PHP_DIR/env/OPENSHIFT_PHP_VERSION"
ln -s /usr/lib64/httpd/modules $OPENSHIFT_PHP_DIR/modulesln -s /etc/httpd/conf/magic $OPENSHIFT_PHP_DIR/conf/magic
![Page 14: Drupal and Open shift (and php)](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f75edb4c9052a518b4708/html5/thumbnails/14.jpg)
bin/install, continued# PEAR setuprm -f $OPENSHIFT_HOMEDIR/.pearrcpear config-create "$OPENSHIFT_PHP_DIR"/phplib/pear/ \ "$OPENSHIFT_HOMEDIR"/.pearrcpear -c "$OPENSHIFT_HOMEDIR"/.pearrc config-set php_ini \ "$OPENSHIFT_PHP_DIR"/configuration/etc/php.inipear -c "$OPENSHIFT_HOMEDIR"/.pearrc config-set auto_discover 1
# @TODO: Make the version a variable?pear -c "$OPENSHIFT_HOMEDIR"/.pearrc config-set php_bin \ "$OPENSHIFT_PHP_DIR"/usr/php/5.4.16-1/usr/bin/phppear -c "$OPENSHIFT_HOMEDIR"/.pearrc config-set bin_dir \"$OPENSHIFT_PHP_DIR"/usr/php/5.4.16-1/usr/binpear -c "$OPENSHIFT_HOMEDIR"/.pearrc upgrade --force pear
![Page 15: Drupal and Open shift (and php)](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f75edb4c9052a518b4708/html5/thumbnails/15.jpg)
SETTING ENVIRONMENTAL VARIABLESSETTING ENVIRONMENTAL VARIABLESCartridges can set environmental variables$OPENSHIFT_$CARTRIDGE_PATH_ELEMENT adds items to $PATHFor PHP, this will be $OPENSHIFT_PHP_PATH_ELEMENTProcessed as .erb templates
![Page 16: Drupal and Open shift (and php)](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f75edb4c9052a518b4708/html5/thumbnails/16.jpg)
env/OPENSHIFT_PHP_PATH_ELEMENT.erb
<%= ENV['OPENSHIFT_PHP_DIR'] %>usr/php/5.4.16-1/usr/bin
![Page 17: Drupal and Open shift (and php)](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f75edb4c9052a518b4708/html5/thumbnails/17.jpg)
env/LD_LIBRARY_PATH.erb
<%= ENV['OPENSHIFT_PHP_DIR'] %>usr/php/5.4.16-1/usr/lib64
![Page 18: Drupal and Open shift (and php)](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f75edb4c9052a518b4708/html5/thumbnails/18.jpg)
WEB CARTRIDGESWEB CARTRIDGESCartridges that accepts HTTP requestsEvery application has one and only one web cartridgeBind to the application to a specified port and hostIn our PHP 5.4 cartridge, PHP-FPM starts and Apache binds
![Page 19: Drupal and Open shift (and php)](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f75edb4c9052a518b4708/html5/thumbnails/19.jpg)
CARTRIDGE SCRIPTSCARTRIDGE SCRIPTSBIN/CONTROLBIN/CONTROL
update-configuration, pre-build, build, deploypost-deploy, start, stop, statusreload, restart, threaddump,
tidy, pre-snapshot, post-snapshotpre-restore, post-restore
The control script allows OpenShift or user to
control the state of the cartridge.
![Page 20: Drupal and Open shift (and php)](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f75edb4c9052a518b4708/html5/thumbnails/20.jpg)
bin/control
case "$1" in start) apache start && fpm start ;; stop) stop ;; restart) apache restart && fpm restart ;; reload|graceful) apache graceful "Restarting gracefully" ;; status) status ;; configtest) configtest ;; tidy) tidy ;; build) build ;; deploy) exit 0 ;; # Nothing to deploy on template PHP cartridge *) exit 0esac
exit $?
![Page 21: Drupal and Open shift (and php)](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f75edb4c9052a518b4708/html5/thumbnails/21.jpg)
bin/control, continuedfunction apache() { client_message "$2 Apache server" [ "$1" != "stop" ] && update_httpd_passenv $HTTPD_CFG_FILE /usr/sbin/httpd -C "Include $HTTPD_CFG_DIR/*.conf" -f $HTTPD_CFG_FILE -k $1 return $?}
![Page 22: Drupal and Open shift (and php)](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f75edb4c9052a518b4708/html5/thumbnails/22.jpg)
bin/control, continuedfunction fpm() { case "$1" in start) client_message "Starting PHP-FPM" if [ -f "$FPM_PID_FILE" ]; then client_message "PHP-FPM is already running." return 0 fi LD_LIBRARY_PATH=$OPENSHIFT_PHP_DIR/usr/php/5.4.16-1/usr/lib64 \ PHP_INI_SCAN_DIR=$OPENSHIFT_PHP_DIR/usr/php/5.4.16-1/etc/php.d \ PHPRC=$OPENSHIFT_PHP_DIR/configuration/etc/php.ini \ $OPENSHIFT_PHP_DIR/usr/php/5.4.16-1/usr/sbin/php-fpm \ --fpm-config $OPENSHIFT_PHP_DIR/configuration/etc/php-fpm.conf \ --pid $FPM_PID_FILE return $? ;;
![Page 23: Drupal and Open shift (and php)](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f75edb4c9052a518b4708/html5/thumbnails/23.jpg)
bin/control, continued stop) client_message "Stopping PHP-FPM" if [ -f "$FPM_PID_FILE" ]; then fpm_pid=`cat "$FPM_PID_FILE" 2> /dev/null` kill $fpm_pid return_status=$? rm -f $FPM_PID_FILE return $return_status fi ;; restart) fpm stop && fpm start ;; esac}
![Page 24: Drupal and Open shift (and php)](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f75edb4c9052a518b4708/html5/thumbnails/24.jpg)
RUNNING YOURRUNNING YOURCARTRIDGES ON OPENSHIFTCARTRIDGES ON OPENSHIFT
The OpenShift CDK (Catridge Development Kit)
Example: The cartridge reflector"Reflects" a cartridge from GitHub and adds the downloadlink to the GitHub zipballcartreflect-claytondev.rhcloud.com/reflect?github=Example:
https://github.com/smarterclayton/openshift-cdk-carthttp://rediscart-claytondev.rhcloud.com/
https://cartreflect-claytondev.rhcloud.com/reflect?github=phase2/openshift-php-fpm
![Page 25: Drupal and Open shift (and php)](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f75edb4c9052a518b4708/html5/thumbnails/25.jpg)
LINKSLINKShttps://github.com/phase2/openshift-php-fpmhttps://github.com/phase2/drupal-quickstarthttps://www.openshift.com/quickstarts/drupal-8-quickstarthttp://openshift.github.io/documentation/oo_deployment_guide_puppet.htmlhttp://openshift.github.io/documentation/oo_cartridge_developers_guide.html
![Page 26: Drupal and Open shift (and php)](https://reader034.vdocuments.us/reader034/viewer/2022052410/554f75edb4c9052a518b4708/html5/thumbnails/26.jpg)
DĚKUJI VÁM!DĚKUJI VÁM!VIELEN DANK!VIELEN DANK!
@stevenmerrillsmerrill on freenodehttps://github.com/smerrillhttps://phase2technology.com