From 377d9142e701f48dc388c68d74d43197fffa258e Mon Sep 17 00:00:00 2001 From: jurgenhaas <juergen@paragon-es.de> Date: Wed, 30 Mar 2016 14:55:23 +0200 Subject: [PATCH] PHP 5.3 adjustments --- tasks/php53.yml | 42 +++++---- templates/etc-init-d-php53-fpm | 137 +++++++++++++++++++++++++++++ templates/etc-php5-apache2-php.ini | 15 ++++ templates/preferences/libssl | 3 + templates/preferences/openssl | 3 + 5 files changed, 184 insertions(+), 16 deletions(-) create mode 100644 templates/etc-init-d-php53-fpm create mode 100644 templates/preferences/libssl create mode 100644 templates/preferences/openssl diff --git a/tasks/php53.yml b/tasks/php53.yml index 4eb8367..5bef9a9 100644 --- a/tasks/php53.yml +++ b/tasks/php53.yml @@ -8,9 +8,6 @@ dest='{{ item }}' state='directory' with_items: - - '/etc/php5/cli53/conf.d/' - - '/etc/php5/cgi53/conf.d/' - - '/etc/php5/fpm/conf.d/' - '/etc/php5/fpm/pool.d/' - name: "Check PHP 5.3 Requirement" @@ -19,6 +16,17 @@ changed_when: false - block: + - name: "Package Preferences" + template: + src='preferences/{{ item }}' + dest='/etc/apt/preferences.d/{{ item }}-pin' + owner='root' + group='root' + mode='644' + with_items: + - 'openssl' + - 'libssl' + - name: "Install Packages" apt: pkg={{ item }} @@ -32,6 +40,11 @@ - 'libssl-dev' - 'libc-client2007e' - 'libc-client2007e-dev' + - 'libxml2-dev' + - 'libcurl4-openssl-dev' + - 'libpng-dev' + - 'autoconf2.13' + - 'automake1.4' - name: "Link Client Lib" file: @@ -62,10 +75,18 @@ - name: "Compile PHP 5.3" shell: "{{ item }} chdir=/tmp/php53/php-5.3.29" with_items: - - ./configure --with-libdir=/lib/x86_64-linux-gnu --enable-fpm --enable-mbstring --enable-sockets --with-zlib --enable-zip --with-imap-ssl --with-imap --with-curl --with-mcrypt --with-gd --with-mysql --with-pdo-mysql --with-mysqli --with-gettext --with-jpeg-dir=/usr --with-png-dir=/usr --with-kerberos + - ./configure --with-libdir=/lib/x86_64-linux-gnu --enable-fpm --enable-mbstring --enable-sockets --with-zlib --enable-zip --with-imap-ssl --with-imap --with-curl --with-mcrypt --with-gd --with-mysql --with-pdo-mysql --with-mysqli --with-gettext --with-jpeg-dir=/usr --with-png-dir=/usr --with-kerberos --with-openssl --disable-cgi - make - make install + - name: "Create PHP53 Start Script" + template: + src='etc-init-d-php53-fpm' + dest='/etc/init.d/php-fpm' + owner='root' + group='root' + mode='755' + - name: "Add PHP-FPM to Boot-List" command: update-rc.d php-fpm defaults @@ -109,18 +130,6 @@ mode='644' with_items: '{{ php53.modules }}' -- name: "Enable PHP53 Modules" - file: - src='/etc/php5/{{ php_conf_dir }}/{{ item.0 }}.ini' - dest='/etc/php5/{{ item.1 }}/conf.d/{{ item.0 }}.ini' - state='link' - owner='root' - group='root' - mode='644' - with_nested: - - '{{ php53.modules }}' - - ['cli53', 'cgi53'] - - name: "Create PHP53 INI Files" template: src='etc-php5-apache2-php.ini' @@ -131,3 +140,4 @@ with_items: - 'cgi53' - 'cli53' + - 'fpm' diff --git a/templates/etc-init-d-php53-fpm b/templates/etc-init-d-php53-fpm new file mode 100644 index 0000000..773d390 --- /dev/null +++ b/templates/etc-init-d-php53-fpm @@ -0,0 +1,137 @@ +#!/bin/sh + +### BEGIN INIT INFO +# Provides: php-fpm +# Required-Start: $remote_fs $network +# Required-Stop: $remote_fs $network +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: starts php-fpm +# Description: starts the PHP FastCGI Process Manager daemon +### END INIT INFO + +prefix=/usr/local +exec_prefix=${prefix} + +php_fpm_BIN=${exec_prefix}/sbin/php-fpm +php_fpm_CONF=/etc/php5/fpm/php-fpm.conf +php_fpm_INI=/etc/php5/fpm/php.ini +php_fpm_PID=/var/run/php5-fpm.pid + +php_opts="-c $php_fpm_INI --fpm-config $php_fpm_CONF --pid $php_fpm_PID" + +wait_for_pid () { + try=0 + + while test $try -lt 35 ; do + + case "$1" in + 'created') + if [ -f "$2" ] ; then + try='' + break + fi + ;; + + 'removed') + if [ ! -f "$2" ] ; then + try='' + break + fi + ;; + esac + + echo -n . + try=`expr $try + 1` + sleep 1 + + done + +} + +case "$1" in + start) + echo -n "Starting php-fpm " + + $php_fpm_BIN --daemonize $php_opts + + if [ "$?" != 0 ] ; then + echo " failed" + exit 1 + fi + + wait_for_pid created $php_fpm_PID + + if [ -n "$try" ] ; then + echo " failed" + exit 1 + else + echo " done" + fi + ;; + + stop) + echo -n "Gracefully shutting down php-fpm " + + if [ ! -r $php_fpm_PID ] ; then + echo "warning, no pid file found - php-fpm is not running ?" + exit 1 + fi + + kill -QUIT `cat $php_fpm_PID` + + wait_for_pid removed $php_fpm_PID + + if [ -n "$try" ] ; then + echo " failed. Use force-quit" + exit 1 + else + echo " done" + fi + ;; + + force-quit) + echo -n "Terminating php-fpm " + + if [ ! -r $php_fpm_PID ] ; then + echo "warning, no pid file found - php-fpm is not running ?" + exit 1 + fi + + kill -TERM `cat $php_fpm_PID` + + wait_for_pid removed $php_fpm_PID + + if [ -n "$try" ] ; then + echo " failed" + exit 1 + else + echo " done" + fi + ;; + + restart) + $0 stop + $0 start + ;; + + reload) + + echo -n "Reload service php-fpm " + + if [ ! -r $php_fpm_PID ] ; then + echo "warning, no pid file found - php-fpm is not running ?" + exit 1 + fi + + kill -USR2 `cat $php_fpm_PID` + + echo " done" + ;; + + *) + echo "Usage: $0 {start|stop|force-quit|restart|reload}" + exit 1 + ;; + +esac diff --git a/templates/etc-php5-apache2-php.ini b/templates/etc-php5-apache2-php.ini index 9f2359d..c23cca5 100644 --- a/templates/etc-php5-apache2-php.ini +++ b/templates/etc-php5-apache2-php.ini @@ -1966,3 +1966,18 @@ ldap.max_links = -1 [Syslog] define_syslog_variables = Off + +{% if php_version|default('5.5') == '5.3' %} +[apc] +extension = apc.so +apc.rfc1867 = 1 +apc.shm_size = 256M +apc.shm_segments = 1 +apc.num_files_hint = 0 + +[imagick] +extension=imagick.so + +[xmlrpc] +extension=xmlrpc.so +{% endif %} diff --git a/templates/preferences/libssl b/templates/preferences/libssl new file mode 100644 index 0000000..4359f5f --- /dev/null +++ b/templates/preferences/libssl @@ -0,0 +1,3 @@ +Package: libssl-dev +Pin: release o=LP-PPA-ondrej-apache2 +Pin-Priority: -1 diff --git a/templates/preferences/openssl b/templates/preferences/openssl new file mode 100644 index 0000000..542515a --- /dev/null +++ b/templates/preferences/openssl @@ -0,0 +1,3 @@ +Package: openssl +Pin: release o=LP-PPA-ondrej-apache2 +Pin-Priority: -1 -- GitLab