• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Drupal and Open shift (and php)
 

Drupal and Open shift (and php)

on

  • 4,922 views

Steven presents with Openshift at DrupalCon Prague

Steven presents with Openshift at DrupalCon Prague

Statistics

Views

Total Views
4,922
Views on SlideShare
4,335
Embed Views
587

Actions

Likes
2
Downloads
13
Comments
0

2 Embeds 587

http://www.phase2technology.com 586
http://artjoolree.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution-NoDerivs LicenseCC Attribution-NoDerivs License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Drupal and Open shift (and php) Drupal and Open shift (and php) Presentation Transcript

    • DRUPALANDOPENSHIFT(ANDPHP)DRUPALANDOPENSHIFT(ANDPHP)
    • DOBRÉODPOLEDNE!DOBRÉODPOLEDNE! GUTENTAG!GUTENTAG!
    • STEVENMERRILLSTEVENMERRILL DIRECTOROFENGINEERING,PHASE2DIRECTOROFENGINEERING,PHASE2
    • DRUPAL8QUICKSTARTDRUPAL8QUICKSTART OPENSHIFTONLINEOPENSHIFTONLINE
    • BUTFIRST,BUTFIRST,
    • DRUPAL8DRUPAL8 Needs PHP 5.3.5 OpenShift Online runs RHEL 6.4 RHEL 6.4 has PHP 5.3.3
    • BUILDINGACARTRIDGEBUILDINGACARTRIDGE If it runs on RHEL or Fedora, it will run on OpenShift IUS provides PHP 5.3 and PHP 5.4 cartridges for RHEL Let's make a cartridge from those RPMS
    • RPMSTOCARTRIDGERPMSTOCARTRIDGE Download them Use rpm2cpio to grab the binaries and files is my script to do this from IUS repos Add in the appropriate manifest and hooks Here are some examples of scripts from the PHP 5.4 cartridge https://github.com/smerrill/php-the-ripper
    • RUNNINGAVENDOREDPHPRUNNINGAVENDOREDPHP The toughest part: the path will change every time php and php-fpm must be in $PATH Point to php.ini with $PHPRC Point to other .ini files with $PHP_INI_SCAN_DIR PHP and HTTP libraries live in $LD_LIBRARY_PATH
    • CARTRIDGESCRIPTSCARTRIDGESCRIPTS BIN/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.
    • 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 directory shopt -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 PHP mkdir -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}
    • CARTRIDGESCRIPTSCARTRIDGESCRIPTS BIN/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.
    • 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/modules ln -s /etc/httpd/conf/magic $OPENSHIFT_PHP_DIR/conf/magic
    • bin/install, continued # PEAR setup rm -f $OPENSHIFT_HOMEDIR/.pearrc pear config-create "$OPENSHIFT_PHP_DIR"/phplib/pear/ "$OPENSHIFT_HOMEDIR"/.pearrc pear -c "$OPENSHIFT_HOMEDIR"/.pearrc config-set php_ini "$OPENSHIFT_PHP_DIR"/configuration/etc/php.ini pear -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/php pear -c "$OPENSHIFT_HOMEDIR"/.pearrc config-set bin_dir "$OPENSHIFT_PHP_DIR"/usr/php/5.4.16-1/usr/bin pear -c "$OPENSHIFT_HOMEDIR"/.pearrc upgrade --force pear
    • SETTINGENVIRONMENTALVARIABLESSETTINGENVIRONMENTALVARIABLES Cartridges can set environmental variables $OPENSHIFT_$CARTRIDGE_PATH_ELEMENT adds items to $PATH For PHP, this will be $OPENSHIFT_PHP_PATH_ELEMENT Processed as .erb templates
    • env/OPENSHIFT_PHP_PATH_ELEMENT.erb <%= ENV['OPENSHIFT_PHP_DIR'] %>usr/php/5.4.16-1/usr/bin
    • env/LD_LIBRARY_PATH.erb <%= ENV['OPENSHIFT_PHP_DIR'] %>usr/php/5.4.16-1/usr/lib64
    • WEBCARTRIDGESWEBCARTRIDGES Cartridges that accepts HTTP requests Every application has one and only one web cartridge Bind to the application to a specified port and host In our PHP 5.4 cartridge, PHP-FPM starts and Apache binds
    • CARTRIDGESCRIPTSCARTRIDGESCRIPTS BIN/CONTROLBIN/CONTROL update-configuration, pre-build, build, deploy post-deploy, start, stop, status reload, restart, threaddump, tidy, pre-snapshot, post-snapshot pre-restore, post-restore The control script allows OpenShift or user to control the state of the cartridge.
    • 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 0 esac exit $?
    • bin/control, continued function 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 $? }
    • bin/control, continued function 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 $? ;;
    • 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 }
    • RUNNINGYOURRUNNINGYOUR CARTRIDGESONOPENSHIFTCARTRIDGESONOPENSHIFT The OpenShift CDK (Catridge Development Kit) Example: The cartridge reflector "Reflects" a cartridge from GitHub and adds the download link to the GitHub zipball cartreflect-claytondev.rhcloud.com/reflect?github= Example: https://github.com/smarterclayton/openshift-cdk-cart http://rediscart-claytondev.rhcloud.com/ https://cartreflect-claytondev.rhcloud.com /reflect?github=phase2/openshift-php-fpm
    • LINKSLINKS https://github.com/phase2/openshift-php-fpm https://github.com/phase2/drupal-quickstart https://www.openshift.com/quickstarts/drupal- 8-quickstart http://openshift.github.io/documentation /oo_deployment_guide_puppet.html http://openshift.github.io/documentation /oo_cartridge_developers_guide.html
    • DĚKUJIVÁM!DĚKUJIVÁM! VIELENDANK!VIELENDANK! @stevenmerrill smerrill on freenode https://github.com/smerrill https://phase2technology.com