Drupal and Open shift (and php)
-
Upload
phase2 -
Category
Technology
-
view
7.893 -
download
0
description
Transcript of Drupal and Open shift (and php)
DRUPAL AND OPENSHIFT (AND PHP)DRUPAL AND OPENSHIFT (AND PHP)
DOBRÉ ODPOLEDNE!DOBRÉ ODPOLEDNE!GUTEN TAG!GUTEN TAG!
STEVEN MERRILLSTEVEN MERRILLDIRECTOR OF ENGINEERING, PHASE2DIRECTOR OF ENGINEERING, PHASE2
DRUPAL 8 QUICKSTARTDRUPAL 8 QUICKSTART
OPENSHIFT ONLINEOPENSHIFT ONLINE
BUT FIRST,BUT FIRST,
DRUPAL 8DRUPAL 8Needs PHP 5.3.5OpenShift Online runs RHEL 6.4RHEL 6.4 has PHP 5.3.3
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
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
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
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.
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}
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.
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
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
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
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
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
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.
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 $?
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 $?}
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 $? ;;
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}
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
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
DĚKUJI VÁM!DĚKUJI VÁM!VIELEN DANK!VIELEN DANK!
@stevenmerrillsmerrill on freenodehttps://github.com/smerrillhttps://phase2technology.com