From 21085f6b7d8677769c986b2fc85ff985774e9df0 Mon Sep 17 00:00:00 2001 From: Christoph Date: Tue, 21 Feb 2017 02:05:25 +0100 Subject: [PATCH] Initial import --- .gitignore | 2 + DOC/README.php5.2-install | 15 + DOC/README.php5.4-install | 42 + DOC/README.php5.6.redis | 8 + DOC/README.php57.ldap | 14 + DOC/READNE.memcached | 29 + DOC/ffmpeg-php.INSTALL | 56 + DOC/php_pear_install.txt | 24 + DOC/php_pecl_install.txt | 14 + mod_php_install.sh | 2907 +++++++++++++++++ .../mod_php_5.2_apache-2.2_install.sh | 216 ++ .../mod_php_5.2_apache-2.4_install.sh | 215 ++ .../mod_php_5.3_apache-2.2_install.sh | 209 ++ .../mod_php_5.3_apache-2.4_install.sh | 729 +++++ .../mod_php_5.4_apache-2.2_install.sh | 211 ++ .../mod_php_5.4_apache-2.4_install.sh | 1913 +++++++++++ .../mod_php_5.5_apache-2.4_install.sh | 2085 ++++++++++++ 17 files changed, 8689 insertions(+) create mode 100644 .gitignore create mode 100644 DOC/README.php5.2-install create mode 100644 DOC/README.php5.4-install create mode 100644 DOC/README.php5.6.redis create mode 100644 DOC/README.php57.ldap create mode 100644 DOC/READNE.memcached create mode 100644 DOC/ffmpeg-php.INSTALL create mode 100644 DOC/php_pear_install.txt create mode 100644 DOC/php_pecl_install.txt create mode 100755 mod_php_install.sh create mode 100755 old-versions/mod_php_5.2_apache-2.2_install.sh create mode 100755 old-versions/mod_php_5.2_apache-2.4_install.sh create mode 100755 old-versions/mod_php_5.3_apache-2.2_install.sh create mode 100755 old-versions/mod_php_5.3_apache-2.4_install.sh create mode 100755 old-versions/mod_php_5.4_apache-2.2_install.sh create mode 100755 old-versions/mod_php_5.4_apache-2.4_install.sh create mode 100755 old-versions/mod_php_5.5_apache-2.4_install.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2a49bba --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/BAK/* +log_* diff --git a/DOC/README.php5.2-install b/DOC/README.php5.2-install new file mode 100644 index 0000000..5ab5c7b --- /dev/null +++ b/DOC/README.php5.2-install @@ -0,0 +1,15 @@ + +## - if you get the following error: +## - +## - configure: error: libXpm.(a|so) not found +## - +## - set a symlink /usr/lib/libXpm.a --> /usr/lib/x86_64-linux-gnu/libXpm.a +## - +ln -s x86_64-linux-gnu/libXpm.a /usr/lib/libXpm.a +## - or (the same) +ln -s /usr/lib/x86_64-linux-gnu/libXpm.a /usr/lib/libXpm.a + +ln -s x86_64-linux-gnu/libjpeg.a /usr/lib/libjpeg.a + +ln -s x86_64-linux-gnu/libpng.a /usr/lib/libpng.a + diff --git a/DOC/README.php5.4-install b/DOC/README.php5.4-install new file mode 100644 index 0000000..3de1d4d --- /dev/null +++ b/DOC/README.php5.4-install @@ -0,0 +1,42 @@ + +## - if you get the following error: +## - +## - configure: error: libXpm.(a|so) not found +## - +## - set a symlink /usr/lib/libXpm.a --> /usr/lib/x86_64-linux-gnu/libXpm.a +## - +ln -s x86_64-linux-gnu/libXpm.a /usr/lib/libXpm.a +## - or (the same) +ln -s /usr/lib/x86_64-linux-gnu/libXpm.a /usr/lib/libXpm.a + + +## - IMAP support +## - +## - if you get the following error: +## - +## - configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. +## - This should not happen. Check config.log for additional information. +## - +aptitude install libc-client-dev +## - or +apt-get install libc-client2007e libc-client2007e-dev libpam0g-dev mlock + + +## - ICU support (?) +## - +## - configure: error: Unable to detect ICU prefix or no failed. Please verify ICU install +## - prefix and make sure icu-config works. +## - +apt-get install libicu-dev + + +## - PSPELL support +## - +## - configure: error: Cannot find pspell +## - +apt-get install libpspell-dev + + +## - VPX Codecs +# - +apt-get install libvpx-dev diff --git a/DOC/README.php5.6.redis b/DOC/README.php5.6.redis new file mode 100644 index 0000000..57b044c --- /dev/null +++ b/DOC/README.php5.6.redis @@ -0,0 +1,8 @@ +## - Install redis extension under php 5.6 +## - +## - Note: the actual version (at time 3.0) requires php vsersion >= 7.0 +## - (and for now < 7.1) +## - +## - Note: On php 5.6.x install redis v. 2.2.8 +## - +pecl install redis-2.2.8 diff --git a/DOC/README.php57.ldap b/DOC/README.php57.ldap new file mode 100644 index 0000000..aced0c7 --- /dev/null +++ b/DOC/README.php57.ldap @@ -0,0 +1,14 @@ +## - PHP does not find LDAP libraries: +## - +## - configure: error: Cannot find ldap libraries in /usr/lib +## - +## - FIX: set a symlink: +## - ln -s /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/ +## - +ln -s /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/ + +## - Note: +## - +## - If 'apr' and apr-utils' wasn't compiled with ldap support (that +## - is, if libldap.so wasn't present), recompile both + diff --git a/DOC/READNE.memcached b/DOC/READNE.memcached new file mode 100644 index 0000000..832bee0 --- /dev/null +++ b/DOC/READNE.memcached @@ -0,0 +1,29 @@ +## --- +## - Installtion of PHP-Extension Memcached +## --- + +## - Install extension memcached via pecl (pecl install memcached) +## - +## - Note: Installation my fail with error message: +## - +## - configure: error: no, libmemcached sasl support is not enabled. Run configure with --disable-memcached-sasl to disable this check +## - +## - +## - During installation answer with this: +## - +## - libmemcached directory [no] : no --disable-memcached-sasl + + +## - Install extension memcached directly and give configure option --disable-memcached-sasl +## - +## - --disable-memcached-sasl +## - +VERSION=2.2.0 +wget https://pecl.php.net/get/memcached-${VERSION}.tgz +gunzip < memcached-${VERSION}.tgz | tar -xf - +cd memcached-${VERSION} +./configure --disable-memcached-sasl +make +make install + + diff --git a/DOC/ffmpeg-php.INSTALL b/DOC/ffmpeg-php.INSTALL new file mode 100644 index 0000000..d84936c --- /dev/null +++ b/DOC/ffmpeg-php.INSTALL @@ -0,0 +1,56 @@ +## - install prerequisites +## - +apt-get install ffmpeg re2c libavcodec-dev libavformat-dev libswscale-dev libpostproc-dev + +cd /usr/local/src/apache2 + +## - download ffmpeg-php from sourceforge +## - +## - http://sourceforge.net/projects/ffmpeg-php/files/ffmpeg-php/ +## - + + +## - If configure script ends up in error +## - +## - configure: error: ffmpeg shared libraries not found. Make sure ffmpeg is compiled as shared libraries using the --enable-shared option +## - +## - library libavcodec.so was not found. +## - +## - You can solve it, by symlinc libavcodec.so to directory /usr/lib +## - +cd /usr/lib +ln -s x86_64-linux-gnu/libavcodec.so + + + +bunzip2 < ffmpeg-php-0.6.0.tar.bz2 | tar -xf - +cd ffmpeg-php-0.6.0 + +phpize +./configure +make +make install + + +## - in file (/usr/local/apache2/conf/)php.ini add: +## - extension=ffmpeg.so +vim /usr/local/apache2/conf/php.ini + +/etc/init.d/apache2 restart + + +## - Install fron source (svn) + +#svn co https://ffmpeg-php.svn.sourceforge.net/svnroot/ffmpeg-php ffmpeg-php_php-5.3.26 +svn co https://svn.code.sf.net/p/ffmpeg-php/code ffmpeg--php_php-5.3.26 + +cd ffmpeg-php_php-5.4.26/trunk/ffmpeg-php + +phpize +./configure --enable-shared +make +make install + +## - in file (/usr/local/apache2/conf/)php.ini add: +## - extension=ffmpeg.so +vim /usr/local/apache2/conf/php.ini diff --git a/DOC/php_pear_install.txt b/DOC/php_pear_install.txt new file mode 100644 index 0000000..5abf58c --- /dev/null +++ b/DOC/php_pear_install.txt @@ -0,0 +1,24 @@ +PHP 5.3.18 +========== +pear install Auth_SASL +pear install Console_Getopt +pear install HTTP +pear install HTTP_Request +pear install HTTP_Upload-beta +pear install Mail +pear install Mail_Mime +pear install Mail_mimeDecode +pear install Net_SMTP + +PHP 5.4.9 +========= +pear install Auth_SASL +pear install Console_Getopt +pear install HTTP +pear install HTTP_Request +pear install HTTP_Upload-beta +pear install Mail +pear install Mail_Mime +pear install Mail_mimeDecode +pear install Net_SMTP + diff --git a/DOC/php_pecl_install.txt b/DOC/php_pecl_install.txt new file mode 100644 index 0000000..6f3a7a0 --- /dev/null +++ b/DOC/php_pecl_install.txt @@ -0,0 +1,14 @@ +PHP 5.3.18 +========== +pecl install pecl_http +pecl install apc +pecl install imagick +pecl install geoip + + +PHP 5.4.9 +========= +pecl install pecl_http +pecl install apc +pecl install imagick-beta +pecl install geoip diff --git a/mod_php_install.sh b/mod_php_install.sh new file mode 100755 index 0000000..714fada --- /dev/null +++ b/mod_php_install.sh @@ -0,0 +1,2907 @@ +#!/usr/bin/env bash + +# php ( fuer Apache 2 ) +# +_VERSION=7.1.1 + +#WITHOUT_APACHE_MOD_PHP=true +_APACHE_MOD_PHP=no + +_APACHE_VERSION=2.4.25 + +_HTTPD_USER=www-data + +_srcdir=$(dirname $(realpath $0)) + +_pwd=`pwd` + +_PHP_FPM_SUPPORT=yes + +_SYMLINK_PHP=no +_SYMLINK_PHP_MAJOR_VERSION=no + +_MEMORY_LIMIT="512M" +_MAX_EXECUTION_TIME=180 +_MAX_INPUT_TIME=180 +_UPLOAD_MAX_FILESIZE="128M" +_POST_MAX_SIZE="128M" + + +## -------------------------------------------------- + +# - Support systemd ? +# - +if [[ "X$(which systemd)" = "X" ]]; then + SYSTEMD_EXISTS=false +else + SYSTEMD_EXISTS=true +fi + +_required_base_packages="" +_required_compiler_packages="" +_required_extension_packages="" + +# - PHP Extension imagick, geoip, memcached +# - +_required_extension_packages="$_required_extension_packages + libmagickwand-dev libmagickcore-dev + libgeoip1 libgeoip-dev geoip-bin + libmemcached-dev" + +# - Compile stuff +# - +_required_compiler_packages="$_required_compiler_packages + g++ g++-multilib gcc gcc-multilib cpp + make automake autoconf libtool flex bison + gettext pkg-config gnu-standards + libssl-dev libreadline-dev libncurses-dev" + +# - Needed to build apache webserver with php/ruby support +# - +_required_base_packages="$_required_base_packages + libxml2 libxml2-dev + curl libcurl4-openssl-dev + libqdbm-dev libgdbm-dev libpspell-dev + libjpeg-dev libpng12-dev libxpm-dev libfreetype6-dev + libwmf-dev libtiff-dev libjasper-dev libpaper-dev + libmagic-dev + libmagick-dev libgraphics-magick-perl + libgraphicsmagick++1-dev libgraphicsmagick++3 libgraphicsmagick1-dev + libgraphviz-dev libgd2-xpm-dev libcroco3-dev libgsf-1-dev libilmbase-dev + libvpx-dev libvpx1 vpx-tools + libgpm-dev libkpathsea-dev libopenexr-dev librsvg2-dev libdjvulibre-dev + libatm-dev libexpat-dev + imagemagick graphicsmagick + re2c + exif libexiv2-dev + netpbm libnetpbm10-dev + libmcrypt-dev mcrypt + libmysqlclient-dev mysql-client + libpq-dev postgresql-client + libreadline-dev libncurses-dev + libdb5.3 libdb5.3++ libdb5.3++-dev libdb5.3-dev + libxslt1-dev libpcre3-dev + libc-client2007e-dev libc-client-dev + libicu-dev + libtidy-dev + libmm-dev libgmp-dev libkrb5-dev libldap-dev + libmhash-dev libgd-dev + libapr1-dev libaprutil1-dev + liblua5.1-0 liblua5.1-0-dev + libsctp-dev + libcrypto++-dev" + +if $SYSTEMD_EXISTS ; then + _required_base_packages="$_required_base_packages + libsystemd-dev" +fi + +needed_compiler_packages="" +for _pkg in $_required_compiler_packages ; do + needed_compiler_packages="$needed_compiler_packages $_pkg" +done + +needed_debian_packages="" +for _pkg in $_required_base_packages ; do + needed_debian_packages="$needed_debian_packages $_pkg" +done + +needed_extension_packages="" +for _pkg in $_required_extension_packages ; do + needed_extension_packages="$needed_extension_packages $_pkg" +done + +## -------------------------------------------------- + +tmp_err_msg=$(mktemp) + +## - Determin httpd binary +## - +_httpd_binary="`which httpd`" +if [ -z "$_httpd_binary" ]; then + _httpd_binary="`ps -C httpd -f | grep -e \"^root\" | awk '{print$8}'`" + if [ -z "$_httpd_binary" ]; then + if [ -x "/usr/local/apache2/bin/httpd" ]; then + _httpd_binary="/usr/local/apache2/bin/httpd" + fi + fi +fi + + +if [ -x "$_httpd_binary" ];then + ## - Determin websever user + ## - + _pass_web_user=false + web_user="`$_httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" + web_group="`$_httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" + if [ -z "$web_user" -o -z "$web_group" ]; then + _HTTPD_USER=www-data + else + _HTTPD_USER=$web_user + _HTTPD_GROUP=$web_group + fi +fi + + +## -------------------------------------------------- + +## - Let make use multiple cores (-j) +## - +if [[ "$MAJOR_VERSION" != "5.4" ]]; then + export MAKEFLAGS=-j$(expr `grep "^processor" /proc/cpuinfo | sort -u | wc -l` + 1) +else + unset MAKEFLAGS +fi + +## --- Some functions +## --- +echononl(){ + echo X\\c > /tmp/shprompt$$ + if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then + echo -e -n "$*\\c" 1>&2 + else + echo -e -n "$*" 1>&2 + fi + rm /tmp/shprompt$$ +} + +fatal(){ + echo "" + echo -e "\t[ \033[31m\033[1mError\033[m ]: $*" + echo "" + echo -e "\t\033[31m\033[1mInstalllation wird abgebrochen\033[m\033[m" + echo "" + rm -f "$tmp_err_msg" + exit 1 +} + +error(){ + echo "" + echo -e "\t[ \033[31m\033[1mError\033[m ]: $*" + echo "" +} + +warn (){ + echo "" + echo -e "\t[ \033[33m\033[1mWarning\033[m ]: $*" + echo "" +} + +info (){ + echo "" + echo -e "\t[ \033[32m\033[1mInfo\033[m ]: $*" + echo "" +} + + +echo_ok() { + echo -e "\033[75G[ \033[1;32mok\033[m ]" + ## echo -e " [ ok ]" +} +echo_failed(){ + echo -e "\033[75G[ \033[1;31mfailed\033[m ]" + ## echo -e " [ failed ]" +} +echo_skipped() { + echo -e "\033[75G[ \033[33m\033[1mskipped\033[m ]" +} +## --- +## --- END: functions + + +## -------------------------------------------------- + +clear +echo +echo -e "\033[21G\033[32mInstallation PHP \033[m" +echo +echo +echo + +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo "Insert PHP version number." +echo "" +echo "" +VERSION= +while [ "X$VERSION" = "X" ] +do + echononl "PHP Version [$_VERSION]: " + read VERSION + if [ "X$VERSION" = "X" ]; then + VERSION=$_VERSION + fi +done +MAJOR_VERSION=`echo $VERSION | cut -d '.' -f1,2` +MAIN_VERSION=`echo $VERSION | cut -d '.' -f1,1` + +# - A hack, because configure don't work with systemd on version 5.4.x +## - +if [[ "$MAJOR_VERSION" = "5.4" ]]; then + SYSTEMD_EXISTS=false +fi + +echo "" +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo "Insert User/Group for apache daemon (httpd)." +echo "" +echo "" + +HTTPD_USER= +while [ "X$HTTPD_USER" = "X" ] +do + echononl "apache user [${_HTTPD_USER}]: " + read HTTPD_USER + if [ "X$HTTPD_USER" = "X" ]; then + HTTPD_USER=$_HTTPD_USER + fi +done +if [ -z "$_HTTPD_GROUP" ]; then + if [ "$HTTPD_USER" = "nobody" ]; then + _HTTPD_GROUP="nogroup" + else + _HTTPD_GROUP=$HTTPD_USER + fi +fi +while [ "X$HTTPD_GROUP" = "X" ] +do + echononl "apache group [$_HTTPD_GROUP]: " + read HTTPD_GROUP + if [ "X$HTTPD_GROUP" = "X" ]; then + HTTPD_GROUP=$_HTTPD_GROUP + fi +done + +_PHP_FPM_USER=$HTTPD_USER +_PHP_FPM_GROUP=$HTTPD_GROUP + +echo "" +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo "Insert Path to MySQL Installation directory." +echo "" +echo "Type:" +echo -e "\t\033[33mSystem\033[m if installed from package system" +echo -e "\t\033[33mNot Installed\033[m if no MySQL installation is present" +echo "" +echo "" + +if [ -d "/usr/local/mysql/bin" ]; then + _MYSQL_INSTALL_DIR="/usr/local/mysql" +else + __mysql_bin="`which mysql`" + if [ -n "$__mysql_bin" ] ; then + _MYSQL_INSTALL_DIR="System" + else + _MYSQL_INSTALL_DIR="Not Installed" + fi +fi +MYSQL_INSTALL_DIR= +while [ "X$MYSQL_INSTALL_DIR" = "X" ] +do + echononl "MySQL Installation Directory [${_MYSQL_INSTALL_DIR}]: " + read MYSQL_INSTALL_DIR + if [ "X$MYSQL_INSTALL_DIR" = "X" ]; then + MYSQL_INSTALL_DIR=$_MYSQL_INSTALL_DIR + if [ -x "$_MYSQL_INSTALL_DIR/bin/mysql" ]; then + break + fi + fi + __to_lower=`echo $MYSQL_INSTALL_DIR | tr '[:upper:]' '[:lower:]' | tr -d ' '` + if [ "$__to_lower" = "system" ]; then + MYSQL_INSTALL_DIR="system" + break + fi + if [ "$__to_lower" = "notinstalled" ]; then + MYSQL_INSTALL_DIR="not_installed" + break + fi + if [ -x "$MYSQL_INSTALL_DIR/bin/mysql" ]; then + break + fi + echo "" + echo -e "\t\033[31mNo Mysql Instalation found at \"$MYSQL_INSTALL_DIR\" !! Try again..\033[m" + echo "" + MYSQL_INSTALL_DIR="" + +done + +echo "" +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo -e "Install php-$VERSION with apache module? [ \033[33myes/no\033[m ]" +echo "" +echo "" +OK="" +while [ "X$OK" = "X" ] +do + echononl "Install mod_apache ? [ $_APACHE_MOD_PHP ] " + read OK + __to_lower=`echo $OK | tr '[:upper:]' '[:lower:]' | tr -d ' '` + if [ "X$OK" = "X" ]; then + OK=$_APACHE_MOD_PHP + break + fi + if [ "$__to_lower" = "yes" -o "$__to_lower" = "no" ]; then + OK=$__to_lower + break + fi + echo "" + echo -e "\t\033[31mWrong entry !! Try again..\033[m" + echo "" + OK= +done +if [ "$OK" = "yes" ]; then + WITHOUT_APACHE_MOD_PHP=false + WITH_MOD_PHP=true +else + WITHOUT_APACHE_MOD_PHP=true + WITH_MOD_PHP=false +fi + + +if $WITH_MOD_PHP ; then + + echo "" + echo -e "\033[32m--\033[m" + echo "" + echo "Insert version numbers apache (httpd) apr and apr-util." + echo "" + echo "" + APACHE_VERSION= + while [ "X$APACHE_VERSION" = "X" ] + do + echononl "apache version [$_APACHE_VERSION]: " + read APACHE_VERSION + if [ "X$APACHE_VERSION" = "X" ]; then + APACHE_VERSION=$_APACHE_VERSION + fi + if [ -d /usr/local/httpd-${APACHE_VERSION}_php-${VERSION} ]; then + echo "" + #echo -e "\t\033[31mApache Instalation found at \"/usr/local/httpd-${APACHE_VERSION}_php-${VERSION}\" !! Try again..\033[m" + echo -e "\t\033[32mApache Instalation found at \"/usr/local/httpd-${APACHE_VERSION}_php-${VERSION}\" !! Try again..\033[m" + echo "" + #APACHE_VERSION= + fi + done + APACHE_BASEDIR=/usr/local/httpd-${APACHE_VERSION}_php-${VERSION} + APXS=${APACHE_BASEDIR}/bin/apxs + + PHP_VERSION_STRING="${VERSION}_httpd-${APACHE_VERSION}" + + PREFIX_PHP="/usr/local/php-$VERSION-httpd-${APACHE_VERSION}" + PHP_INI_FILE="${APACHE_BASEDIR}/conf/php.ini" + _builddir=${_srcdir}/php-${VERSION}_http-${APACHE_VERSION} + _logdir=${_srcdir}/log_php-${VERSION}_http-${APACHE_VERSION}_build + +else + + PHP_VERSION_STRING="$VERSION" + + PREFIX_PHP=/usr/local/php-$VERSION + PHP_INI_FILE="${PREFIX_PHP}/etc/php.ini" + _builddir=${_srcdir}/php-${VERSION} + _logdir=${_srcdir}/log_php-${VERSION}_build + +fi + + +echo "" +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo -e "Define PHP parameters for php.ini file" +echo "" + +## - php.ini: memory_limit +if [ -f "/usr/local/php-${MAJOR_VERSION}/etc/php.ini" ]; then + __memory_limit=$(grep -e "^\s*memory_limit" /usr/local/php-${MAJOR_VERSION}/etc/php.ini | awk '{print$3}') + if [ -n "$__memory_limit" ] ; then + _MEMORY_LIMIT=$__memory_limit + fi +fi + +if [ -f "/usr/local/php-${MAJOR_VERSION}/etc/php.ini" ]; then + __memory_limit=$(grep -e "^\s*memory_limit" /usr/local/php-${MAJOR_VERSION}/etc/php.ini | awk '{print$3}') + if [ -n "$__memory_limit" ] ; then + __MEMORY_LIMIT=$__memory_limit + fi +fi + +MEMORY_LIMIT="" +echononl "memory_limit in Megabyte !! Append \"M\"? [$_MEMORY_LIMIT] " +read MEMORY_LIMIT +if [ "X$MEMORY_LIMIT" = "X" ]; then + MEMORY_LIMIT=$_MEMORY_LIMIT +fi + +## - php.ini: max_execution_time +if [ -f "/usr/local/php-${MAJOR_VERSION}/etc/php.ini" ]; then + __max_execution_time=$(grep -e "^\s*max_execution_time" /usr/local/php-${MAJOR_VERSION}/etc/php.ini | awk '{print$3}') + if [ -n "$__max_execution_time" ] ; then + _MAX_EXECUTION_TIME=$__max_execution_time + fi +fi + +MAX_EXECUTION_TIME="" +echononl "max_execution_time (in Seconds) !! insert ONLY the number? [$_MAX_EXECUTION_TIME] " +read MAX_EXECUTION_TIME +if [ "X$MAX_EXECUTION_TIME" = "X" ]; then + MAX_EXECUTION_TIME=$_MAX_EXECUTION_TIME +fi + +## - php.ini: upload_max_filesize +if [ -f "/usr/local/php-${MAJOR_VERSION}/etc/php.ini" ]; then + __upload_max_filesize=$(grep -e "^\s*upload_max_filesize" /usr/local/php-${MAJOR_VERSION}/etc/php.ini | awk '{print$3}') + if [ -n "$__upload_max_filesize" ] ; then + _UPLOAD_MAX_FILESIZE=$__upload_max_filesize + fi +fi + +## - php.ini: max_input_time +if [ -f "/usr/local/php-${MAJOR_VERSION}/etc/php.ini" ]; then + __max_input_time=$(grep -e "^\s*max_input_time" /usr/local/php-${MAJOR_VERSION}/etc/php.ini | awk '{print$3}') + if [ -n "$__max_input_time" ] ; then + _MAX_INPUT_TIME=$__max_input_time + fi +fi + +MAX_INPUT_TIME="" +echononl "max_input_time (in Seconds) !! insert ONLY the number? [$_MAX_INPUT_TIME] " +read MAX_INPUT_TIME +if [ "X$MAX_INPUT_TIME" = "X" ]; then + MAX_INPUT_TIME=$_MAX_INPUT_TIME +fi + +## - php.ini: upload_max_filesize +if [ -f "/usr/local/php-${MAJOR_VERSION}/etc/php.ini" ]; then + __upload_max_filesize=$(grep -e "^\s*upload_max_filesize" /usr/local/php-${MAJOR_VERSION}/etc/php.ini | awk '{print$3}') + if [ -n "$__upload_max_filesize" ] ; then + _UPLOAD_MAX_FILESIZE=$__upload_max_filesize + fi +fi + +UPLOAD_MAX_FILESIZE="" +echononl "upload_max_filesize in Megabyte !! Append \"M\"? [$_UPLOAD_MAX_FILESIZE] " +read UPLOAD_MAX_FILESIZE +if [ "X$UPLOAD_MAX_FILESIZE" = "X" ]; then + UPLOAD_MAX_FILESIZE=$_UPLOAD_MAX_FILESIZE +fi + +## - php.ini: post_max_size +if [ -f "/usr/local/php-${MAJOR_VERSION}/etc/php.ini" ]; then + __post_max_size=$(grep -e "^\s*post_max_size" /usr/local/php-${MAJOR_VERSION}/etc/php.ini | awk '{print$3}') + if [ -n "$__post_max_size" ] ; then + _POST_MAX_SIZE=$__post_max_size + fi +fi + +POST_MAX_SIZE="" +echononl "post_max_size in Megabyte !! Append \"M\"? [$_POST_MAX_SIZE] " +read POST_MAX_SIZE +if [ "X$POST_MAX_SIZE" = "X" ]; then + POST_MAX_SIZE=$_POST_MAX_SIZE +fi + + +echo "" +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo -e "Set Symlinks ? [ \033[33myes/no\033[m ]" +echo "" + +echo "" +if [ ! -h /usr/local/php ] ; then + SYMLINK_PHP=true + echo "Symlink /usr/local/php -> /usr/local/php-$MAJOR_VERSION will be set." +else + OK="" + while [ "X$OK" = "X" ] + do + echononl "Set symlink /usr/local/php -> /usr/local/php-$MAJOR_VERSION ? [ $_SYMLINK_PHP ]: " + read OK + __to_lower=`echo $OK | tr '[:upper:]' '[:lower:]' | tr -d ' '` + if [ "X$OK" = "X" ]; then + OK=$_SYMLINK_PHP + break + fi + if [ "$__to_lower" = "yes" -o "$__to_lower" = "no" ]; then + OK=$__to_lower + break + fi + echo "" + echo -e "\t\033[31mWrong entry !! Try again..\033[m" + echo "" + OK= + done + if [ "$OK" = "yes" ]; then + SYMLINK_PHP=true + else + SYMLINK_PHP=false + fi +fi + +echo "" +if [ ! -h /usr/local/php-${MAJOR_VERSION} ] ; then + SYMLINK_PHP_MAJOR_VERSION=true + echo "Symlink /usr/local/php-$MAJOR_VERSION -> `basename $PREFIX_PHP` will be set." +else + OK="" + while [ "X$OK" = "X" ]; do + echononl "Set symlink /usr/local/php-$MAJOR_VERSION -> `basename $PREFIX_PHP` ? [ $_SYMLINK_PHP_MAJOR_VERSION ]: " + read OK + __to_lower=`echo $OK | tr '[:upper:]' '[:lower:]' | tr -d ' '` + if [ "X$OK" = "X" ]; then + OK=$_SYMLINK_PHP_MAJOR_VERSION + break + fi + if [ "$__to_lower" = "yes" -o "$__to_lower" = "no" ]; then + OK=$__to_lower + break; + fi + echo "" + echo -e "\t\033[31mWrong entry !! Try again..\033[m" + echo "" + OK= + done + if [ "$OK" = "yes" ]; then + SYMLINK_PHP_MAJOR_VERSION=true + else + SYMLINK_PHP_MAJOR_VERSION=false + fi + +fi + + + +echo "" +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo -e "Install support of PHP-FPM (FastCGI Process Manager) [ \033[33myes/no\033[m ]" +echo "" +echo "" +OK="" +while [ "X$OK" = "X" ] +do + echononl "Install FPM support ? [ $_PHP_FPM_SUPPORT ] " + read OK + __to_lower=`echo $OK | tr '[:upper:]' '[:lower:]' | tr -d ' '` + if [ "X$OK" = "X" ]; then + OK=$_PHP_FPM_SUPPORT + break + fi + if [ "$__to_lower" = "yes" -o "$__to_lower" = "no" ]; then + OK=$__to_lower + break + fi + echo "" + echo -e "\t\033[31mWrong entry !! Try again..\033[m" + echo "" + OK= +done +if [ "$OK" = "yes" ]; then + WITH_PHP_FPM_SUPPORT=true + ACTIVATE_PHP_FPM_INIT_SCRIPT=true +else + WITH_PHP_FPM_SUPPORT=false + ACTIVATE_PHP_FPM_INIT_SCRIPT=false +fi + +if $WITH_PHP_FPM_SUPPORT ; then + echo "" + echo -e "\033[32m--\033[m" + echo "" + echo "" + OK="" + echononl "Set \"umask\" to \"0002\" for PHP-FPM process? [no]: " + read OK + while [ "X$OK" != "Xyes" -a "X$OK" != "XYes" -a "X$OK" != "Xno" -a "X$OK" != "XNo" -a "X$OK" != "X" ]; do + echononl "falsche Angabe! [no]: " + read OK + done + if [ "$OK" = "yes" -o "$OK" = "Yes" ]; then + SET_UMASK=true + UMASK=0002 + else + SET_UMASK=false + fi +fi + +if $WITH_PHP_FPM_SUPPORT && $WITH_MOD_PHP ; then + if [ -f "/etc/init.d/php-${VERSION}-fpm" ];then + echo "" + OK="" + while [ "X$OK" = "X" ]; do + echononl "Activate PHP-FPM from that installation ? [ no ] " + read OK + __to_lower=`echo $OK | tr '[:upper:]' '[:lower:]' | tr -d ' '` + if [ "X$OK" = "X" ]; then + OK="no" + break + fi + if [ "$__to_lower" = "yes" -o "$__to_lower" = "no" ]; then + OK=$__to_lower + break + fi + echo "" + echo -e "\t\033[31mWrong entry !! Try again..\033[m" + echo "" + OK= + done + if [ "$OK" = "yes" ]; then + ACTIVATE_PHP_FPM_INIT_SCRIPT=true + else + ACTIVATE_PHP_FPM_INIT_SCRIPT=false + fi + fi +fi + + +FPM_PID_FILE=/var/run/php-${MAJOR_VERSION}-fpm.pid + +FPM_SYSTEMD_FILE=/etc/systemd/system/php-${MAJOR_VERSION}-fpm.service +FPM_INIT_SCRIPT=/etc/init.d/php-${MAJOR_VERSION}-fpm + +FPM_LOG_DIR=/var/log/php-${MAJOR_VERSION}-fpm +FPM_ERROR_LOG=${FPM_LOG_DIR}/fpm-${MAJOR_VERSION}-error.log + +FPM_POOL_CONF_DIR=fpm.d +FPM_DEFAULT_POOL=www-${MAJOR_VERSION} + +FPM_DEFAULT_POOL_USER=$_PHP_FPM_USER +FPM_DEFAULT_POOL_GROUP=$_PHP_FPM_GROUP +FPM_DEFAULT_POOL_LISTEN=/tmp/php-${MAJOR_VERSION}-fpm.`echo ${FPM_DEFAULT_POOL} | cut -d'-' -f1`.sock +FPM_DEFAULT_POOL_LISTEN_OWNER=$_PHP_FPM_USER +FPM_DEFAULT_POOL_LISTEN_GROUP=$HTTPD_GROUP +FPM_DEFAULT_POOL_LISTEN_MODE=0660 + +FPM_DEFAULT_POOL_PM=dynamic +FPM_DEFAULT_POOL_MAX_CHILDREN=250 +FPM_DEFAULT_POOL_START_SERVER=5 +FPM_DEFAULT_POOL_MIN_SPARE=5 +FPM_DEFAULT_POOL_MAX_SPARE=10 + +FPM_DEFAULT_POOL_MAX_REQUESTS=500 + +FPM_DEFAULT_POOL_STATUS_PATH="/status-${MAJOR_VERSION}" +FPM_DEFAULT_POOL_PING_PATH="/ping-${MAJOR_VERSION}" +FPM_DEFAULT_POOL_PING_RESPONSE="pong" + +FPM_DEFAULT_POOL_ACCESS_LOG="${FPM_LOG_DIR}/${FPM_DEFAULT_POOL}-access.log" +FPM_DEFAULT_POOL_SLOW_LOG="${FPM_LOG_DIR}/${FPM_DEFAULT_POOL}-slow.log" +FPM_DEFAULT_POOL_ACCESS_FORMAT="\"%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%\"" + +FPM_DEFAULT_POOL_TERMINATE_TIMEOUT="`expr $MAX_EXECUTION_TIME + 1`s" + +FPM_ULIMIT_MAX_FILES=`su -c "ulimit -H -n" -s /bin/bash $_PHP_FPM_USER` + + +echo "" +echo "" +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo -e "\033[21G\033[32mStart PHP Installation with the following Parameters \033[m" +echo "" +echo "PHP version...................: $VERSION" +echo "PHP major version.............: $MAJOR_VERSION" +echo "" +echo "PHP configuration (php.ini)" +echo " memory_limit...............: $MEMORY_LIMIT" +echo " max_execution_time.........: $MAX_EXECUTION_TIME" +echo " max_input_time.............: $MAX_INPUT_TIME" +echo " upload_max_filesize........: $UPLOAD_MAX_FILESIZE" +echo " post_max_size..............: $POST_MAX_SIZE" +echo "" +echo "Apache User...................: $HTTPD_USER" +echo "Apache Group..................: $HTTPD_GROUP" +echo "" +echo "MySQL Installation directory..: $MYSQL_INSTALL_DIR" +echo "" +echo "Install with FPM support......: $WITH_PHP_FPM_SUPPORT" +if $WITH_PHP_FPM_SUPPORT ; then + echo " Activate FPM init script...: $ACTIVATE_PHP_FPM_INIT_SCRIPT" + echo " Set umask 0002 for FPM.....: $SET_UMASK" +fi +echo "Install with systemd Support..: $SYSTEMD_EXISTS" +echo "" +echo "Install with (apache) mod_php.: $WITH_MOD_PHP" +if $WITH_MOD_PHP ; then + echo " Apache Version.............: $APACHE_VERSION" +fi +echo "" +if $SYMLINK_PHP_MAJOR_VERSION -o $SYMLINK_PHP ; then + echo "Set symlniks:" + if $SYMLINK_PHP ; then + echo " /usr/local/php -> /usr/local/php-$MAJOR_VERSION" + fi + if $SYMLINK_PHP_MAJOR_VERSION ; then + echo " /usr/local/php-$MAJOR_VERSION -> `basename $PREFIX_PHP`" + fi +fi +echo "" +echononl "Start with that configuration? [yes/no]: " +read OK +while [ "X$OK" != "Xyes" -a "X$OK" != "XYes" -a "X$OK" != "XNo" -a "X$OK" != "Xno" ] +do + echononl "wrong entry! [yes/no] :" + read OK +done +[ $OK = "Yes" -o $OK = "yes" ] || fatal "Change parameters and restart script: `basename $0`" + +echo "" +echo "" + + +## -------------------------------------------------- + +if [ -d "$_logdir" ];then + mv $_logdir $_logdir.`date +%Y%m%d-%H%M` +fi +mkdir -p $_logdir > /dev/null 2>&1 +if [ -d "$_builddir" ];then + mv $_builddir $_builddir.`date +%Y%m%d-%H%M` +fi +if [ -d "$PREFIX_PHP" ];then + mv $PREFIX_PHP $PREFIX_PHP.`date +%Y%m%d-%H%M` +fi + + +echo "" +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo "Starting Installation of PHP v $VERSION..." +echo "" +echo "" + +echo -e "\t---" +echo -e "\t--- pre-installation tasks" +echo -e "\t---" +echo "" + + +# - Update index files of the debian repositories +# - +echononl "\tUpdate index files of the debian repositories" +apt-get update >> /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed + fatal "\"apt-get update\" failed!" +fi + + +echononl "\tInstall compiler stuff.." +if [[ -n "$needed_compiler_packages" ]]; then + DEBIAN_FRONTEND=noninteractive apt-get -y install $needed_compiler_packages > /dev/null 2> $tmp_err_msg + #DEBIAN_FRONTEND=noninteractive apt-get -y install $needed_packages > /dev/null 2> $tmp_err_msg + if [[ $? -eq 0 ]] ; then + echo_ok + else + echo_failed + error "$(cat $tmp_err_msg)" + fi +else + echo_skipped + info "Up-to-date.." +fi + +echononl "\tInstall needed packages for base install" +if [[ -n "$needed_debian_packages" ]]; then + DEBIAN_FRONTEND=noninteractive apt-get -y install $needed_debian_packages > /dev/null 2> $tmp_err_msg + if [[ $? -eq 0 ]] ; then + echo_ok + else + echo_failed + error "$(cat $tmp_err_msg)" + fi +else + echo_skipped + info "Up-to-date.." +fi + +echononl "\tInstall needed packages for php extensions" +if [[ -n "$needed_extension_packages" ]]; then + DEBIAN_FRONTEND=noninteractive apt-get -y install $needed_extension_packages > /dev/null 2> $tmp_err_msg + if [[ $? -eq 0 ]] ; then + echo_ok + else + echo_failed + error "$(cat $tmp_err_msg)" + fi +else + echo_skipped + info "Up-to-date.." +fi + +## - Set Symlink +## - /usr/include/x86_64-linux-gnu/gmp.h -> /usr/include/gmp.h +## - if not exists +## - +if [ -f "/usr/include/x86_64-linux-gnu/gmp.h" -a ! -e "/usr/include/gmp.h" ]; then + echononl "\tSet Symlink /usr/include/x86_64-linux-gnu/gmp.h.." + ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + warn "Cannot set Symlink /usr/include/x86_64-linux-gnu/gmp.h -> /usr/include/gmp.h" + fi + echo "" +fi + +## - Set Symlink +## - /usr/lib/x86_64-linux-gnu/libldap.so -> /usr/lib/libldap.so +## - if not exists +## - +if [ -f "/usr/lib/x86_64-linux-gnu/libldap.so" -a ! -e "/usr/lib/libldap.so" ]; then + echononl "\tSet Symlink /usr/lib/x86_64-linux-gnu/libldap.so.." + ln -s /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + warn "Cannot set Symlink /usr/lib/x86_64-linux-gnu/libldap.so -> /usr/lib/libldap.so" + fi + echo "" +fi + +## - Set Symlink +## - /usr/lib/x86_64-linux-gnu/libXpm.so -> /usr/lib/libXpm.so +## - if not exists +## - +if [ -f "/usr/lib/x86_64-linux-gnu/libXpm.so" -a ! -e "/usr/lib/libXpm.so" ]; then + echononl "\tSet Symlink /usr/lib/x86_64-linux-gnu/libXpm.so.." + ln -s /usr/lib/x86_64-linux-gnu/libXpm.so /usr/lib/libXpm.so + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + warn "Cannot set Symlink /usr/lib/x86_64-linux-gnu/libXpm.so -> /usr/lib/libXpm.so" + fi + echo "" +fi + +echo "" +echo "" +echo -e "\t---" +echo -e "\t--- Install PHP v $PHP_VERSION_STRING" +echo -e "\t---" +echo "" + +## - get sources.. +## - +cd $_srcdir + +echononl "\tGet source php-$VERSION.tar.bz2.." +if [ ! -f ${_srcdir}/php-$VERSION.tar.bz2 ]; then + wget http://de.php.net/distributions/php-$VERSION.tar.bz2 >> ${_logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fatal "Cannot Download php-$VERSION.tar.bz2" + fi +else + echo_skipped +fi + +echononl "\tUnpack archive \"php-$VERSION.tar.bz2\".." +bunzip2 < ${_srcdir}/php-$VERSION.tar.bz2 | tar -xf - 2> $tmp_err_msg +if [[ $? -eq 0 ]]; then + echo_ok +else + echo_failed + fatal "$(cat $tmp_err_msg)" +fi + +echononl "\tChange ownership of unpacked dirextory \"php-$VERSION\"" +chown -R root.root php-$VERSION > $tmp_err_msg 2>&1 +if [[ $? -eq 0 ]]; then + echo_ok +else + echo_failed + fatal "$(cat $tmp_err_msg)" +fi + +if ! $WITHOUT_APACHE_MOD_PHP ; then + mv php-$VERSION $_builddir +fi +cd $_builddir || exit 1 + +echononl "\tGoing to configure.." + +# : ${_arch:=i686} +# : ${_arch:=athlon} +# : ${_arch:=k8} ## --> x86-64 instructionset + +##_cflags="-O2 -march=$_arch " + +## - LDFLAGS="-s" --> Remove all symbol table and relocation information from the executable. +## F77="/usr/bin/g77-3.4" \ +## CXXCPP="/usr/bin/g++-3.4 -E" \ +## CC="/usr/bin/gcc-3.4" \ +## CXX="/usr/bin/g++-3.4" \ +## CPP="/usr/bin/cpp-3.4" \ +## CFLAGS="$_cflags" LDFLAGS="-s" \ +config_params=" + --prefix=$PREFIX_PHP \ + --with-gd \ + --with-pgsql \ + --with-pdo-pgsql \ + --with-pcre-regex \ + --enable-wddx \ + --enable-exif \ + --with-zlib \ + --with-openssl \ + --with-gdbm \ + --with-jpeg-dir \ + --with-png-dir \ + --with-curl \ + --enable-dba \ + --with-mcrypt \ + --with-xpm-dir \ + --with-vpx-dir \ + --with-freetype-dir \ + --enable-ftp \ + --with-gmp \ + --with-readline \ + --enable-sockets \ + --with-imap \ + --with-imap-ssl \ + --with-kerberos \ + --with-gettext \ + --with-pspell \ + --enable-soap \ + --enable-mbstring \ + --enable-zip \ + --enable-calendar \ + --enable-bcmath \ + --enable-opcache \ + --with-bz2 \ + --enable-intl \ + --enable-shmop \ + --enable-sysvmsg \ + --enable-sysvsem \ + --enable-sysvshm \ + --enable-pcntl \ + --with-ldap=shared \ + --with-xsl \ + --with-mhash \ + --enable-cgi" + +# --with-t1lib \ + +# --with-fpm-systemd \ +if $SYSTEMD_EXISTS ; then + config_params="$config_params \ + --with-fpm-systemd" +fi + +## - since version 7.0: unrecognized options --with-t1lib +## - +if [[ $MAIN_VERSION -lt 7 ]] ; then + config_params="$config_params \ + --with-vpx-dir" +fi + + +if [ "$MYSQL_INSTALL_DIR" != "not_installed" ]; then + if [ "$MYSQL_INSTALL_DIR" = "system" ];then + if [ -f "/etc/mysql/my.cnf" ]; then + _mysql_socket="`cat /etc/mysql/my.cnf | grep -E \"^\s*socket\" | head -1 | awk '{print$3}'`" + if [ -S "$_mysql_socket" ]; then + config_params="$config_params \ + --with-mysqli \ + --with-pdo-mysql \ + --with-mysql-sock" + else + config_params="$config_params \ + --with-mysqli \ + --with-pdo-mysql " + fi + else + ## - since version 7.0: unrecognized options --with-mysql + ## - + if [[ $MAIN_VERSION -lt 7 ]] ; then + config_params="$config_params \ + --with-mysql" + fi + config_params="$config_params \ + --with-mysqli \ + --with-pdo-mysql " + fi + else + ## - since version 7.0: unrecognized options --with-mysql + ## - + if [[ $MAIN_VERSION -lt 7 ]] ; then + config_params="$config_params \ + --with-mysql=$MYSQL_INSTALL_DIR" + fi + config_params="$config_params \ + --with-mysqli=${MYSQL_INSTALL_DIR}/bin/mysql_config \ + --with-pdo-mysql=$MYSQL_INSTALL_DIR \ + --with-mysql-sock" + fi +fi + +if $WITHOUT_APACHE_MOD_PHP ; then + config_params="$config_params --without-apxs2 --with-config-file-path=${PREFIX_PHP}/etc" +else + config_params="$config_params --with-apxs2=$APXS --with-config-file-path=${APACHE_BASEDIR}/conf" +fi + +if $WITH_PHP_FPM_SUPPORT ; then + config_params="$config_params --enable-fpm" +fi + +LDFLAGS="-s" \ +./configure $config_params > ${_logdir}/php-configure.log 2>&1 +make > ${_logdir}/php-make.log 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed + fatal "Configuring PHP failed!\n\t see ${_logdir}/php-configure.log for more details" +fi + + +## --with-mm \ # does not work with apache v2.4 + +## --with-pgsql=/usr/local/pgsql \ + +## --with-mysql=/usr/local/mysql \ +## --with-mysqli=/usr/local/mysql/bin/mysql_config \ +## --with-pdo-mysql=/usr/local/mysql \ +## --with-mysql-sock \ + +## --with-mysql \ +## --with-mysqli \ +## --with-pdo-mysql \ +## --with-mysql-sock \ + +## --enable-force-cgi-redirect \ +## --enable-track-vars \ +## --with-tiff-dir \ +## --with-ttf \ +## --with-memcache \ +## --with-xml \ + +echononl "\tGoing to compile.." +make > ${_logdir}/php-make.log 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed + fatal "Compiling PHP failed!\n\t see ${_logdir}/php-make.log for more details" +fi + + +sync + +echononl "\tGoing to install.." +make install > ${_logdir}/php-make_install.log 2>&1 +if [[ $? -ne 0 ]]; then + echo_failed + if [[ "$MAJOR_VERSION" = "5.4" ]]; then + echononl "\tRetry Installing.." + make install > ${_logdir}/php-make_install.log 2>&1 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + fatal "Installing PHP failed!\n\t see ${_logdir}/php-make_install.log for more details" + fi + else + fatal "Installing PHP failed!\n\t see ${_logdir}/php-make_install.log for more details" + fi +else + echo_ok +fi + + +#cp php.ini-production $PHP_INI_FILE || exit 1 +[ -f $PHP_INI_FILE ] && cp -a $PHP_INI_FILE ${$PHP_INI_FILE}-`date +"%Y-%m-%d-%H%M"` +cp php.ini-production $PHP_INI_FILE || exit 1 + +## - Temporarily change PATH environment variable +## - +export PATH=/usr/local/php-${VERSION}/bin:$PATH + + +if ! $WITHOUT_APACHE_MOD_PHP ; then + _set_php_entries="" + echo "" + echo -n "do you want to set \"LoadModule\" entries in httpd.conf ? [y/n]: " + read _set_php_entries + if [ "y" = "$_set_php_entries" -o "Y" = "$_set_php_entries" -o "Yes" = "$_set_php_entries" -o "yes" = "$_set_php_entries" ];then + sed -i -r \ + -e "s&(^\s*LoadModule php5_module.*$)&\1\n#\n AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml\n AddType application/x-httpd-php-source .phps\n#&" ${APACHE_BASEDIR}/conf/httpd.conf + #-e "s&(^\s*LoadModule php5_module.*$)&\1\n\n AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml\n AddType application/x-httpd-php-source .phps\n&" ${APACHE_BASEDIR}/conf/httpd.conf + fi +fi + +echo "" +echo "" +echo -e "\t---" +echo -e "\t--- post installation tasks" +echo -e "\t---" + +if $SYMLINK_PHP ; then + echononl "\tSet symlink /usr/local/php -> /usr/local/php-$MAJOR_VERSION" + if [ -L /usr/local/php ];then + rm -f /usr/local/php + fi + ln -s `basename $PREFIX_PHP` /usr/local/php + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi +fi + +if $SYMLINK_PHP_MAJOR_VERSION ; then + echononl "\tSet symlink /usr/local/php-$MAJOR_VERSION -> `basename $PREFIX_PHP`" + if [ -h /usr/local/php-${MAJOR_VERSION} ] ; then + rm -f /usr/local/php-${MAJOR_VERSION} + fi + ln -s `basename $PREFIX_PHP` /usr/local/php-$MAJOR_VERSION + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi +fi + + +## - special for debian. set manpath entries +## - +if [ -f /etc/manpath.config ];then + if ! grep /usr/local/php/man /etc/manpath.config > /dev/null 2<&1 ; then + echo >> /etc/manpath.config + echo "MANDATORY_MANPATH /usr/local/php/php/man /var/cache/man" >> /etc/manpath.config + echo "MANPATH_MAP /usr/local/php/bin /usr/local/php/php/man" >> /etc/manpath.config + echo "MANDB_MAP /usr/local/php/php/man /var/cache/man" >> /etc/manpath.config + fi +elif [ -f /etc/man.conf];then + if ! grep /opt/php/man /etc/man.conf > /dev/null 2<&1 ; then + echo >> /etc/man.conf + echo "MANPATH /opt/php/man /var/cache/man" >> /etc/man.conf + echo "MANPATH_MAP /opt/php/bin /opt/php/man" >> /etc/man.conf + fi +fi + + +## - Add /usr/local/php/bin to the systems PATH variable +## - +echo "" +echononl "\tAdd `dirname $PREFIX_PHP`/php/bin to the systems PATH variable" +_checkdir=`dirname $PREFIX_PHP`/php/bin +if [ -f /etc/profile ]; then + if ! grep -e "$_checkdir" /etc/profile > /dev/null 2<&1 ; then + perl -i -n -p -e "s#^([ ]*export[ ]*PATH.*$)#check_dir=$_checkdir\nif [ -d \"\\\$check_dir\" ];then\n PATH=\\\${check_dir}:\\\$PATH\nfi\n\n\1#" /etc/profile > /dev/null 2<&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + if ! echo "$PATH" | grep $_checkdir > /dev/null 2>&1 ; then + export PATH=${_checkdir}:$PATH + fi + + else + echo_skipped + fi +fi + + +## - PHP FPM +## - +echo "" +echo "" +echo -e "\t---" +echo -e "\t--- Install support for PHP-FPM" +echo -e "\t---" +echo "" + +if $WITH_PHP_FPM_SUPPORT ; then + + if $SYSTEMD_EXISTS ; then + + if $ACTIVATE_PHP_FPM_INIT_SCRIPT ; then + + if systemctl is-enabled php-${MAJOR_VERSION}-fpm.service > /dev/null 2>&1 ; then + + echononl "\tStop service php-${MAJOR_VERSION}-fpm" + systemctl stop php-${MAJOR_VERSION}-fpm.service > /dev/null 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Stopping Service \"php-${MAJOR_VERSION}-fpm\" failed!" + fi + + echononl "\tDisable service php-${MAJOR_VERSION}-fpm" + systemctl disable php-${MAJOR_VERSION}-fpm.service > /dev/null 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Disabling Service \"php-${MAJOR_VERSION}-fpm\" failed!" + fi + fi # if systemctl is-enabled php-${MAJOR_VERSION}-fpm.service + + echononl "\tRemove existing service file \"php-${MAJOR_VERSION}-fpm.service\"" + if [[ -f "$FPM_SYSTEMD_FILE" ]] ; then + rm "$FPM_SYSTEMD_FILE" > /dev/null 2<&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Removing file \"$FPM_SYSTEMD_FILE\" failed!" + fi + else + echo_skipped + fi + + echononl "\tAdding systemd service \"$FPM_SYSTEMD_FILE\".." + cp ${_builddir}/sapi/fpm/php-fpm.service "$FPM_SYSTEMD_FILE" > /dev/null 2<&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fatal "Adding systemd service \"$FPM_SYSTEMD_FILE\" failed!" + fi + + _failed=false + echononl "\tAdjust php-${MAJOR_VERSION}-fpm.service (PrivateTmp=false)" + + sed -i -r -e "s#(Description.*)#\1 v${MAJOR_VERSION}#" "$FPM_SYSTEMD_FILE" > /dev/null 2<&1 + if [[ $? -ne 0 ]]; then + _failed=true + fi + + sed -i -r -e "s#PIDFile=.*#PIDFile=${FPM_PID_FILE}#" "$FPM_SYSTEMD_FILE" > /dev/null 2<&1 + if [[ $? -ne 0 ]]; then + _failed=true + fi + + if grep -q "PrivateTmp" "$FPM_SYSTEMD_FILE" > /dev/null 2<&1 ; then + sed -i -r -e "s#^([[:space:]]*PrivateTmp).*#\1=false#" "$FPM_SYSTEMD_FILE" + if [[ $? -ne 0 ]]; then + _failed=true + fi + fi + + if grep -q -E "\\\$\{prefix\}" "$FPM_SYSTEMD_FILE" > /dev/null 2<&1 ; then + + sed -i -r -e "s#\\\$\{prefix\}#${PREFIX_PHP}#g" "$FPM_SYSTEMD_FILE" > /dev/null 2<&1 + if [[ $? -ne 0 ]]; then + _failed=true + fi + fi + + if grep -q -E "\\\$\{exec_prefix\}" "$FPM_SYSTEMD_FILE" > /dev/null 2<&1 ; then + sed -i -r -e "s#\\\$\{exec_prefix\}#${PREFIX_PHP}#g" "$FPM_SYSTEMD_FILE" > /dev/null 2<&1 + if [[ $? -ne 0 ]]; then + _failed=true + fi + fi + + + if $_failed ; then + echo_failed + error "Some errors adjusting php-${MAJOR_VERSION}-fpm.service occured!" + else + echo_ok + fi + + + echononl "\tEnable Service \"php-${MAJOR_VERSION}-fpm.service\".." + systemctl enable "php-${MAJOR_VERSION}-fpm.service" > /dev/null 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fatal "Enabling systemd service \"${FPM_SYSTEMD_FILE}\" failed!" + fi + + echononl "\tReload systemd manager configuration.." + systemctl daemon-reload > /dev/null 2<&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fatal "Reloading systemd manager configuration failed!" + fi + + fi # if $ACTIVATE_PHP_FPM_INIT_SCRIPT + + else + + echononl "\tAdd init script ${PREFIX_PHP}/sbin/php-${PHP_VERSION_STRING}-fpm" + cp ${_builddir}/sapi/fpm/init.d.php-fpm ${PREFIX_PHP}/sbin/php-${PHP_VERSION_STRING}-fpm > /dev/null 2<&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + echononl "\tMake init script executable" + chmod 755 ${PREFIX_PHP}/sbin/php-${PHP_VERSION_STRING}-fpm + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + echononl "\tSet \"umask 0002\" for FPM Processes .." + if $SET_UMASK ; then + sed -i "1 s/\(.*\)/\1\n\numask 0002\n/" ${PREFIX_PHP}/sbin/php-${PHP_VERSION_STRING}-fpm > /dev/null 2<&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + else + echo_skipped + fi + + if $ACTIVATE_PHP_FPM_INIT_SCRIPT ; then + + PID=`ps aux | grep "php-fpm: " | grep "master" | grep "${MAJOR_VERSION}" | grep -v grep | awk '{print$2}'` + + if [[ -n "$PID" ]] ; then + if [[ -x "$FPM_INIT_SCRIPT" ]]; then + echononl "\tStopping PHP-FPM Service" + $FPM_INIT_SCRIPT stop > /dev/null 2<&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Stopping init script $FPM_INIT_SCRIPT failed!" + fi + fi + + sleep 5 + declare -i i=0 + + PIDS=`ps aux | grep "php-fpm: " | grep -E "(master|pool)" | grep "${MAJOR_VERSION}" | grep -v grep | awk '{print$2}'` + while [ "X$PIDS" != "X" ]; do + + if [[ $i -eq 0 ]]; then + echononl "\tGoing to kill PHP-FPM Processes.." + fi + if [ $i -gt 20 ]; then + echo_failed + break + fi + + for _PID in $PIDS ; do + kill -9 $_PID > /dev/null 2>&1 + done + + sleep 2 + + PIDS=`ps aux | grep "php-fpm: " | grep -E "(master|pool)" | grep "${MAJOR_VERSION}" | grep -v grep | awk '{print$2}'` + i+=1 + + done + + rm -f $FPM_DEFAULT_POOL_LISTEN + rm -f $FPM_PID_FILE + + fi + + if [[ $i -lt 20 ]]; then + echo_ok + fi + + echononl "\tRemove existsing init script /etc/init.d/php-${PHP_VERSION_STRING}-fpm" + if [ -f "/etc/init.d/php-${PHP_VERSION_STRING}-fpm" ]; then + rm /etc/init.d/php-${PHP_VERSION_STRING}-fpm > /dev/null 2<&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Removing existing init script /etc/init.d/php-${PHP_VERSION_STRING}-fpm failed!" + fi + else + echo_skipped + fi + + if [[ -f "$FPM_INIT_SCRIPT" ]] || [[ -h $FPM_INIT_SCRIPT ]] ; then + echononl "\tRemove \"$FPM_INIT_SCRIPT\"" + rm -f $FPM_INIT_SCRIPT + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Removing $FPM_INIT_SCRIPT failed!" + fi + fi + + echononl "\tSet Symlink $FPM_INIT_SCRIPT --> ${PREFIX_PHP}/sbin/php-${PHP_VERSION_STRING}-fpm" + ln -s ${PREFIX_PHP}/sbin/php-${PHP_VERSION_STRING}-fpm $FPM_INIT_SCRIPT > /dev/null 2<&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + fi + + echononl "\tMake php-${MAJOR_VERSION}-fpm start at boottime" + if ! grep -e "$FPM_INIT_SCRIPT" /etc/rc.local > /dev/null 2>&1 ; then + sed -i -r -e "s#^([[:space:]]*exit\ +.*)#sleep 2\n$FPM_INIT_SCRIPT restart > /dev/null || /bin/true\n\n\1#" /etc/rc.local + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + else + echo_skipped + fi + + _failed=false + echononl "\tAdjust ${PREFIX_PHP}/sbin/php-${PHP_VERSION_STRING}-fpm" + sed -i -r -e "s&^(([ ^t]*php_fpm_PID=).*)$&## \1\n\2${FPM_PID_FILE}&g" ${PREFIX_PHP}/sbin/php-${PHP_VERSION_STRING}-fpm || _failed=true + sed -i -r -e "s&^(#\ .+)php-fpm&\1php-${MAJOR_VERSION}-fpm&" ${PREFIX_PHP}/sbin/php-${PHP_VERSION_STRING}-fpm || _failed=true + if ! $_failed ; then + echo_ok + else + echo_failed + fi + + fi # if $SYSTEMD_EXISTS + + + + echononl "\tCreate php-fpm global configuration file" + cat < ${PREFIX_PHP}/etc/php-fpm.conf +;;;;;;;;;;;;;;;;;;;;; +; FPM Configuration ; +;;;;;;;;;;;;;;;;;;;;; + +; All relative paths in this configuration file are relative to PHP's install +; prefix (/usr/local/php-5.4.35). This prefix can be dynamically changed by using the +; '-p' argument from the command line. + +; Include one or more files. If glob(3) exists, it is used to include a bunch of +; files from a glob(3) pattern. This directive can be used everywhere in the +; file. +; Relative path can also be used. They will be prefixed by: +; - the global prefix if it's been set (-p argument) +; - /usr/local/php-5.4.35 otherwise +;include=etc/fpm.d/*.conf + +;;;;;;;;;;;;;;;;;; +; Global Options ; +;;;;;;;;;;;;;;;;;; + +[global] +; Pid file +; Note: the default prefix is /usr/local/php-5.4.35/var +; Default Value: none +pid = $FPM_PID_FILE + +; Set open file descriptor rlimit for the master process. +; Default Value: system defined value +;rlimit_files = 1024 +rlimit_files = $FPM_ULIMIT_MAX_FILES + +; Error log file +; If it's set to "syslog", log is sent to syslogd instead of being written +; in a local file. +; Note: the default prefix is /usr/local/php-5.4.35/var +; Default Value: log/php-fpm.log +error_log = $FPM_ERROR_LOG + +include=etc/${FPM_POOL_CONF_DIR}/*.conf +EOF + + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + echononl "\tCreate Configuration Directory \"${FPM_POOL_CONF_DIR}\"" + mkdir -p ${PREFIX_PHP}/etc/$FPM_POOL_CONF_DIR + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + echononl "\tCreate php-fpm configuration file for pool \"${FPM_DEFAULT_POOL}\"" + cat < ${PREFIX_PHP}/etc/${FPM_POOL_CONF_DIR}/${FPM_DEFAULT_POOL}.php-fpm.conf +;;;;;;;;;;;;;;;;;;;; +; Pool Definitions ; +;;;;;;;;;;;;;;;;;;;; + +; Multiple pools of child processes may be started with different listening +; ports and different management options. The name of the pool will be +; used in logs and stats. There is no limitation on the number of pools which +; FPM can handle. Your system will tell you anyway :) + +; Start a new pool named '$FPM_DEFAULT_POOL'. +; the variable \$pool can we used in any directive and will be replaced by the +; pool name ('$FPM_DEFAULT_POOL' here) +[$FPM_DEFAULT_POOL] + +; Unix user/group of processes +; Note: The user is mandatory. If the group is not set, the default user's group +; will be used. +user = $FPM_DEFAULT_POOL_USER +group = $FPM_DEFAULT_POOL_GROUP + +; The address on which to accept FastCGI requests. +; Valid syntaxes are: +; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on +; a specific port; +; 'port' - to listen on a TCP socket to all addresses on a +; specific port; +; '/path/to/unix/socket' - to listen on a unix socket. +; Note: This value is mandatory. +listen = $FPM_DEFAULT_POOL_LISTEN + +; Set permissions for unix socket, if one is used. In Linux, read/write +; permissions must be set in order to allow connections from a web server. Many +; BSD-derived systems allow connections regardless of permissions. +; Default Values: user and group are set as the running user +; mode is set to 0660 +listen.owner = $FPM_DEFAULT_POOL_LISTEN_OWNER +listen.group = $FPM_DEFAULT_POOL_LISTEN_GROUP +listen.mode = $FPM_DEFAULT_POOL_LISTEN_MODE + +; Choose how the process manager will control the number of child processes. +; Possible Values: +; static - a fixed number (pm.max_children) of child processes; +; dynamic - the number of child processes are set dynamically based on the +; following directives. With this process management, there will be +; always at least 1 children. +; pm.max_children - the maximum number of children that can +; be alive at the same time. +; pm.start_servers - the number of children created on startup. +; pm.min_spare_servers - the minimum number of children in 'idle' +; state (waiting to process). If the number +; of 'idle' processes is less than this +; number then some children will be created. +; pm.max_spare_servers - the maximum number of children in 'idle' +; state (waiting to process). If the number +; of 'idle' processes is greater than this +; number then some children will be killed. +; ondemand - no children are created at startup. Children will be forked when +; new requests will connect. The following parameter are used: +; pm.max_children - the maximum number of children that +; can be alive at the same time. +; pm.process_idle_timeout - The number of seconds after which +; an idle process will be killed. +; Note: This value is mandatory. +pm = $FPM_DEFAULT_POOL_PM + +; The number of child processes to be created when pm is set to 'static' and the +; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. +; This value sets the limit on the number of simultaneous requests that will be +; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. +; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP +; CGI. The below defaults are based on a server without much resources. Don't +; forget to tweak pm.* to fit your needs. +; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' +; Note: This value is mandatory. +pm.max_children = $FPM_DEFAULT_POOL_MAX_CHILDREN + +; The number of child processes created on startup. +; Note: Used only when pm is set to 'dynamic' +; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 +pm.start_servers = $FPM_DEFAULT_POOL_START_SERVER + +; The desired minimum number of idle server processes. +; Note: Used only when pm is set to 'dynamic' +; Note: Mandatory when pm is set to 'dynamic' +pm.min_spare_servers = $FPM_DEFAULT_POOL_MIN_SPARE + +; The desired maximum number of idle server processes. +; Note: Used only when pm is set to 'dynamic' +; Note: Mandatory when pm is set to 'dynamic' +pm.max_spare_servers = $FPM_DEFAULT_POOL_MAX_SPARE + +; The number of requests each child process should execute before respawning. +; This can be useful to work around memory leaks in 3rd party libraries. For +; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. +; Default Value: 0 +pm.max_requests = $FPM_DEFAULT_POOL_MAX_REQUESTS + +; The URI to view the FPM status page. If this value is not set, no URI will be +; recognized as a status page. It shows the following informations: +; pool - the name of the pool; +; process manager - static, dynamic or ondemand; +; start time - the date and time FPM has started; +; start since - number of seconds since FPM has started; +; accepted conn - the number of request accepted by the pool; +; listen queue - the number of request in the queue of pending +; connections (see backlog in listen(2)); +; max listen queue - the maximum number of requests in the queue +; of pending connections since FPM has started; +; listen queue len - the size of the socket queue of pending connections; +; idle processes - the number of idle processes; +; active processes - the number of active processes; + + +; total processes - the number of idle + active processes; +; max active processes - the maximum number of active processes since FPM +; has started; +; max children reached - number of times, the process limit has been reached, +; when pm tries to start more children (works only for +; pm 'dynamic' and 'ondemand'); +; Value are updated in real time. +; Example output: +; pool: www +; process manager: static +; start time: 01/Jul/2011:17:53:49 +0200 +; start since: 62636 +; accepted conn: 190460 +; listen queue: 0 +; max listen queue: 1 +; listen queue len: 42 +; idle processes: 4 +; active processes: 11 +; total processes: 15 +; max active processes: 12 +; max children reached: 0 +; +; By default the status page output is formatted as text/plain. Passing either +; 'html', 'xml' or 'json' in the query string will return the corresponding +; output syntax. Example: +; http://www.foo.bar/status +; http://www.foo.bar/status?json +; http://www.foo.bar/status?html +; http://www.foo.bar/status?xml +; +; By default the status page only outputs short status. Passing 'full' in the +; query string will also return status for each pool process. +; Example: +; http://www.foo.bar/status?full +; http://www.foo.bar/status?json&full +; http://www.foo.bar/status?html&full +; http://www.foo.bar/status?xml&full +; The Full status returns for each process: +; pid - the PID of the process; +; state - the state of the process (Idle, Running, ...); +; start time - the date and time the process has started; +; start since - the number of seconds since the process has started; +; requests - the number of requests the process has served; +; request duration - the duration in µs of the requests; +; request method - the request method (GET, POST, ...); +; request URI - the request URI with the query string; +; content length - the content length of the request (only with POST); +; user - the user (PHP_AUTH_USER) (or '-' if not set); +; script - the main script called (or '-' if not set); +; last request cpu - the %cpu the last request consumed +; it's always 0 if the process is not in Idle state +; because CPU calculation is done when the request +; processing has terminated; +; last request memory - the max amount of memory the last request consumed +; it's always 0 if the process is not in Idle state +; because memory calculation is done when the request +; processing has terminated; +; If the process is in Idle state, then informations are related to the +; last request the process has served. Otherwise informations are related to +; the current request being served. +; Example output: +; ************************ +; pid: 31330 +; state: Running +; start time: 01/Jul/2011:17:53:49 +0200 +; start since: 63087 +; requests: 12808 +; request duration: 1250261 +; request method: GET +; request URI: /test_mem.php?N=10000 +; content length: 0 +; user: - +; script: /home/fat/web/docs/php/test_mem.php +; last request cpu: 0.00 +; last request memory: 0 +; +; Note: There is a real-time FPM status monitoring sample web page available +; It's available in: ${prefix}/share/fpm/status.html +; +; Note: The value must start with a leading slash (/). The value can be +; anything, but it may not be a good idea to use the .php extension or it +; may conflict with a real PHP file. +; Default Value: not set +pm.status_path = $FPM_DEFAULT_POOL_STATUS_PATH + +; The ping URI to call the monitoring page of FPM. If this value is not set, no +; URI will be recognized as a ping page. This could be used to test from outside +; that FPM is alive and responding, or to +; - create a graph of FPM availability (rrd or such); +; - remove a server from a group if it is not responding (load balancing); +; - trigger alerts for the operating team (24/7). +; Note: The value must start with a leading slash (/). The value can be +; anything, but it may not be a good idea to use the .php extension or it +; may conflict with a real PHP file. +; Default Value: not set +ping.path = $FPM_DEFAULT_POOL_PING_PATH + +; This directive may be used to customize the response of a ping request. The +; response is formatted as text/plain with a 200 response code. +; Default Value: pong +ping.response = $FPM_DEFAULT_POOL_PING_RESPONSE + +; The access log file +; Default: not set +access.log = $FPM_DEFAULT_POOL_ACCESS_LOG +; The access log format. +; The following syntax is allowed +; %%: the '%' character +; %C: %CPU used by the request +; it can accept the following format: +; - %{user}C for user CPU only +; - %{system}C for system CPU only +; - %{total}C for user + system CPU (default) +; %d: time taken to serve the request +; it can accept the following format: +; - %{seconds}d (default) +; - %{miliseconds}d +; - %{mili}d +; - %{microseconds}d +; - %{micro}d +; %e: an environment variable (same as $_ENV or $_SERVER) +; it must be associated with embraces to specify the name of the env +; variable. Some exemples: +; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e +; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e +; %f: script filename +; %l: content-length of the request (for POST request only) +; %m: request method +; %M: peak of memory allocated by PHP +; it can accept the following format: +; - %{bytes}M (default) +; - %{kilobytes}M +; - %{kilo}M +; - %{megabytes}M +; - %{mega}M +; %n: pool name +; %o: output header +; it must be associated with embraces to specify the name of the header: +; - %{Content-Type}o +; - %{X-Powered-By}o +; - %{Transfert-Encoding}o +; - .... +; %p: PID of the child that serviced the request +; %P: PID of the parent of the child that serviced the request +; %q: the query string +; %Q: the '?' character if query string exists +; %r: the request URI (without the query string, see %q and %Q) +; %R: remote IP address +; %s: status (response code) +; %t: server time the request was received +; it can accept a strftime(3) format: +; %d/%b/%Y:%H:%M:%S %z (default) +; %T: time the log has been written (the request has finished) +; it can accept a strftime(3) format: +; %d/%b/%Y:%H:%M:%S %z (default) +; %u: remote user +; +; Default: "%R - %u %t \"%m %r\" %s" +access.format = $FPM_DEFAULT_POOL_ACCESS_FORMAT + +; The log file for slow requests +; Default Value: not set +; Note: slowlog is mandatory if request_slowlog_timeout is set +request_slowlog_timeout = 10s +slowlog = $FPM_DEFAULT_POOL_SLOW_LOG + +; The timeout for serving a single request after which the worker process will +; be killed. This option should be used when the 'max_execution_time' ini option +; does not stop script execution for some reason. A value of '0' means 'off'. +; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) +; Default Value: 0 +request_terminate_timeout = $FPM_DEFAULT_POOL_TERMINATE_TIMEOUT + +EOF + + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + if [ "$_HTTPD_USER" != $FPM_DEFAULT_POOL_LISTEN_OWNER ]; then + echononl "\tAdd apache user to group \"$FPM_DEFAULT_POOL_LISTEN_GROUP\"" + usermod -a -G $FPM_DEFAULT_POOL_LISTEN_GROUP $_HTTPD_USER + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + fi + + echononl "\tCreate log directory for PHP-FPM \"${FPM_LOG_DIR}\"" + mkdir -p $FPM_LOG_DIR + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + echononl "\tConfigure logrotation for \"${FPM_LOG_DIR}\"" + if [ ! -f "/etc/logrotate.d/php-${MAJOR_VERSION}-fpm" ]; then + cat < /etc/logrotate.d/php-${MAJOR_VERSION}-fpm +$FPM_LOG_DIR/*log { + daily + rotate 7 + start 0 + compress + delaycompress + missingok + notifempty +} +EOF + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + else + echo_skipped + fi + +fi + + + +echo "" + +echononl "\tUpdate file name database (updatedb).." +updatedb > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## - PHP Extensions +## - +echo "" +echo "" +echo -e "\t---" +echo -e "\t--- Install PHP extensions" +echo -e "\t---" +echo "" + + +## ----- +## - Install geoip +## ----- + +echononl "\tInstall geoip v.1.1.1 via pecl.." +${PREFIX_PHP}/bin/pecl install geoip-1.1.1 > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok + + echononl "\tphp.ini: extension=geoip.so .." + _extension="geoip.so" + perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\n#" $PHP_INI_FILE + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + +else + echo_failed +fi + +## ----- +## - END: Install geoip +## ----- + + +## ----- +## - Install uploadprogress +## ----- + +echononl "\tInstall uploadprogress via pecl.." +printf "\n" | ${PREFIX_PHP}/bin/pecl install uploadprogress > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok + + echononl "\tphp.ini: extension=uploadprogress .." + zend_extension_uploadprogress=`find ${PREFIX_PHP}/lib/php/extensions -name uploadprogress.so -print` + if [[ -n "$zend_extension_uploadprogress" ]]; then + _extension="uploadprogress.so" + perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\n#" $PHP_INI_FILE + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + else + echo_skipped + warn "Maybe extension \"uploadprogress.so\" is not supported!" + fi + +else + echo_failed +fi + +## ----- +## - END: Install uploadprogress +## ----- + + +## ----- +## - Install solr +## ----- + +echononl "\tInstall solr via pecl.." +printf "\n" | ${PREFIX_PHP}/bin/pecl install solr > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok + + echononl "\tphp.ini: extension=solr .." + _extension="solr.so" + perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\n#" $PHP_INI_FILE + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + +else + echo_failed +fi + +## ----- +## - END: Install solr +## ----- + + +## ----- +## - Install redis +## ----- + +echononl "\tInstall redis via pecl.." +printf "\n" | ${PREFIX_PHP}/bin/pecl install redis > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok + + echononl "\tphp.ini: extension=redis .." + _extension="redis.so" + perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\n#" $PHP_INI_FILE + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + +else + echo_failed +fi + +## ----- +## - END: Install redis +## ----- + + +## ----- +## - Install APCu +## ----- + +echononl "\tInstall APCu via pecl.." +if [[ $MAIN_VERSION -lt 7 ]] ; then + printf "\n" | ${PREFIX_PHP}/bin/pecl install apcu-4.0.11 > /dev/null 2>&1 + if [ "$?" = "0" ]; then + echo_ok + + echononl "\tphp.ini: extension=apcu .." + _extension="apcu.so" + perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\napc.enable_cli = 1\n#" $PHP_INI_FILE + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + else + echo_failed + fi + +else + printf "\n" | ${PREFIX_PHP}/bin/pecl install apcu > /dev/null 2>&1 + if [ "$?" = "0" ]; then + echo_ok + + echononl "\tphp.ini: extension=apcu .." + _extension="apcu.so" + perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\napc.enable_cli = 1\n#" $PHP_INI_FILE + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + else + echo_failed + fi +fi + +## ----- +## - END: Install APCu +## ----- + + +## ----- +## - Install memcached +## ----- + +echononl "\tInstall memcached via pecl.." +if [[ $MAIN_VERSION -lt 7 ]] ; then + printf "\n" | ${PREFIX_PHP}/bin/pecl install memcached-2.2.0 > /dev/null 2>&1 +else + printf "\n" | ${PREFIX_PHP}/bin/pecl install memcached > /dev/null 2>&1 +fi +if [ "$?" = "0" ]; then + echo_ok + echononl "\tphp.ini: extension=memcsched .." + _extension="memcached.so" + perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\n#" $PHP_INI_FILE + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi +else + echo_failed + echo -e "\tTry to install memcached from source.." + cd /tmp + rm -rf /tmp/php-memcached + _failed=false + echononl "\tInstalling git .." + if ! dpkg -l git 2> /dev/null | grep -e "^ii" | grep git > /dev/null 2>&1 ; then + apt-get -q -y install git > /dev/null 2>&1 + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + _failed=true + fi + else + echo_skipped + fi + if ! $_failed ; then + echononl "\tClone from github repository.." + git clone https://github.com/php-memcached-dev/php-memcached.git > /dev/null 2>&1 + if [ "$?" = 0 ]; then + echo_ok + cd php-memcached + else + echo_failed + failed=true + fi + fi + if ! $_failed ; then + echononl "\tgit checkout php7.." + git checkout php7 > /dev/null 2>&1 + if [ "$?" = 0 ]; then + echo_ok + cd /tmp/php-memcached + else + echo_failed + failed=true + fi + fi + if ! $_failed ; then + echononl "\t/usr/local/php-${VERSION}/bin/phpize.." + /usr/local/php-${VERSION}/bin/phpize > /dev/null 2>&1 + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + failed=true + fi + fi + if ! $_failed ; then + echononl "\tConfigure memcached extension.." + ./configure --disable-memcached-sasl > /dev/null 2>&1 + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + failed=true + fi + fi + if ! $_failed ; then + echononl "\tCompile memcached extension.." + make > /dev/null 2>&1 + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + failed=true + fi + fi + if ! $_failed ; then + echononl "\tInstall memcached extension.." + make install > /dev/null 2>&1 + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + failed=true + fi + fi + rm -rf /tmp/php-memcached + if ! $_failed ; then + echononl "\tphp.ini: extension=memcsched .." + _extension="memcached.so" + perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\n#" $PHP_INI_FILE + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + fi +fi + +## ----- +## - END: Install memcached +## ----- + + +## ----- +## - Install imagick +## ----- + +cd /tmp +_MagickWand_config=`which MagickWand-config` +if [ -z "$_MagickWand_config" ]; then + + echononl "\tUpdate file name database (updatedb).." + updatedb > /dev/null 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + _MagickWand_config=`locate MagickWand-config | grep -e "/MagickWand-config$" | head -n 1` + if [ -f "$_MagickWand_config" ]; then + echononl "\tSymlink /usr/bin/MagickWand-config --> $_MagickWand_config" + ln -s $_MagickWand_config /usr/bin/ + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + else + warn "Cannot find \"MagickWand_config\" - but is needed for \"imagick\"." + + fi +fi + +echononl "\tInstall imagick via pecl.." +printf "\n" | ${PREFIX_PHP}/bin/pecl install imagick > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok + + echononl "\tphp.ini: extension=imagick.so .." + _extension="imagick.so" + perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\n#" $PHP_INI_FILE + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + +else + echo_failed +fi + + +## ----- +## - END: Install imagick +## ----- + + +## ----- +## - Install pcntl +## ----- + +#echononl "\tphp.ini: extension=pcntl.so .." +#_extension="pcntl.so" +#perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\n#" $PHP_INI_FILE +#if [ "$?" = "0" ]; then +# echo_ok +#else +# echo_failed +#fi + +## ----- +## - END: Install pcntl +## ----- + + +## ----- +## - Enable ldap.so +## ----- + +echononl "\tphp.ini: extension=ldap .." +_extension="ldap.so" +perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\n#" $PHP_INI_FILE +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +## ----- +## - END: Enable ldap.so +## ----- + + +## ----- +## - Install xdebug +## ----- + +echononl "\tInstall xdebug via pecl.." +if [[ "$MAJOR_VERSION" = "5.4" ]] ; then + printf "\n" | ${PREFIX_PHP}/bin/pecl install xdebug-2.2.7 > /dev/null 2>&1 +else + printf "\n" | ${PREFIX_PHP}/bin/pecl install xdebug > /dev/null 2>&1 +fi +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + + +#if $WITHOUT_APACHE_MOD_PHP ; then +# zend_extension_xdebug=`find /usr/local/php-${MAJOR_VERSION}/lib/php/extensions -name xdebug.so -print` +#else +# #zend_extension_xdebug=`locate xdebug.so | grep ${PREFIX_PHP}/lib/php/extensions` + zend_extension_xdebug=`find ${PREFIX_PHP}/lib/php/extensions -name xdebug.so -print` +#fi + +echononl "\tphp.ini: zend_extension = \"$zend_extension_xdebug\" .." +if [[ -n "$zend_extension_xdebug" ]]; then + perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\n;zend_extension = $zend_extension_xdebug\n#" $PHP_INI_FILE + #sed -i "s/^/\nzend_extension = ${zend_extension_xdebug}\n\n/" $PHP_INI_FILE + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi +else + echo_skipped + warn "Extension library \"xdebug.so\" not found!" +fi + +echononl "\tphp.ini: Create section [xdebug]" +echo "[xdebug]" >> $PHP_INI_FILE +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tphp.ini: xdebug.max_nesting_level = 150" +echo "xdebug.max_nesting_level = 150" >> $PHP_INI_FILE +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +info "Enable xdebug extension by commenting in the apropriate line at top of php.ini file" + +## ----- +## - END: Install xdebug +## ----- + + + +echo "" +echo "" +echo -e "\t---" +echo -e "\t--- Install PHP PEAR extensions" +echo -e "\t---" +echo "" + +echononl "\tInstall Mail via pear.." +${PREFIX_PHP}/bin/pear install Mail > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tInstall Mail_Mime via pear.." +${PREFIX_PHP}/bin/pear install Mail_Mime > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tInstall Mail_mimeDecode via pear.." +${PREFIX_PHP}/bin/pear install Mail_mimeDecode > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tInstall Net_Socket via pear.." +${PREFIX_PHP}/bin/pear install Net_Socket > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tInstall Net_SMTP via pear.." +${PREFIX_PHP}/bin/pear install Net_SMTP > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tInstall Net_Sieve via pear.." +${PREFIX_PHP}/bin/pear install Net_Sieve > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tInstall Net_IDNA2 via pear.." +${PREFIX_PHP}/bin/pear install Net_IDNA2 > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed + echononl "\tInstall (beta) Net_IDNA2-0.1.1 via pear.." + ${PREFIX_PHP}/bin/pear install channel://pear.php.net/Net_IDNA2-0.1.1 > /dev/null 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi +fi + +echononl "\tInstall Auth via pear.." +${PREFIX_PHP}/bin/pear install Auth > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tInstall Auth_SASL via pear.." +${PREFIX_PHP}/bin/pear install Auth_SASL > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +#echononl "\tInstall Auth_SASL2 via pear.." +#${PREFIX_PHP}/bin/pear install Auth_SASL2 > /dev/null 2>&1 +#if [ "$?" = "0" ]; then +# echo_ok +#else +# echo_failed +# echononl "\tInstall (beta) Auth_SASL2-0.1.0 via pear.." +# ${PREFIX_PHP}/bin/pear install channel://pear.php.net/Auth_SASL2-0.1.0 > /dev/null 2>&1 +# if [ "$?" = "0" ]; then +# echo_ok +# else +# echo_failed +# fi +#fi + +echononl "\tInstall MDB2 via pear.." +${PREFIX_PHP}/bin/pear install MDB2 > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tInstall MDB2_Driver_pgsql via pear.." +${PREFIX_PHP}/bin/pear install MDB2_Driver_pgsql > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +#echononl "\tInstall Console_Getopt via pear.." +#${PREFIX_PHP}/bin/pear install Console_Getopt > /dev/null 2>&1 +#if [ "$?" = "0" ]; then +# echo_ok +#else +# echo_failed +#fi + +echononl "\tInstall Crypt_GPG via pear.." +${PREFIX_PHP}/bin/pear install Crypt_GPG > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## - Configure php.ini (base) +## - +echo "" +echo "" +echo -e "\t---" +echo -e "\t--- Configure php.ini (base)" +echo -e "\t---" +echo "" + +## - set date.timezon = "Europe/Berlin" +## - +echononl "\tphp.ini: date.timezone = \"Europe/Berlin\"" +_key="date.timezone" +_val="Europe/Berlin" +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = \"${_val}\"#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + +## - set short_open_tag = On +## - +echononl "\tphp.ini: short_open_tag = On" +_key="short_open_tag" +_val="Off" +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## - set memory_limit = $MEMORY_LIMIT +## - +echononl "\tphp.ini: memory_limit = $MEMORY_LIMIT" +_key="memory_limit" +_val=$MEMORY_LIMIT +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## - set max_execution_time = $MAX_EXECUTION_TIME +## - +echononl "\tphp.ini: max_execution_time = $MAX_EXECUTION_TIME" +_key="max_execution_time" +_val=$MAX_EXECUTION_TIME +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## - set max_input_time = $MAX_INPUT_TIME +## - +echononl "\tphp.ini: max_input_time = $MAX_INPUT_TIME" +_key="max_input_time" +_val=$MAX_INPUT_TIME +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## - set error_log = /var/log/apache2/php_errors.log +## - +echononl "\tphp.ini: error_log = /var/log/apache2/php_errors.log" +_key="error_log" +_val="/var/log/apache2/php_errors.log" +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi +touch $_val +chown ${HTTPD_USER}:$HTTPD_GROUP $_val + + +## - set upload_max_filesize = $UPLOAD_MAX_FILESIZE +## - +echononl "\tphp.ini: upload_max_filesize = $UPLOAD_MAX_FILESIZE" +_key="upload_max_filesize" +_val="$UPLOAD_MAX_FILESIZE" +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## - set post_max_size = $POST_MAX_SIZE +## - +echononl "\tphp.ini: post_max_size = $POST_MAX_SIZE" +_key="post_max_size" +_val="$POST_MAX_SIZE" +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## - set max_file_uploads = 50 +## - +echononl "\tphp.ini: max_file_uploads = 50" +_key="max_file_uploads" +_val=50 +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## - set always_populate_raw_post_data = -1 +## - +echononl "\tphp.ini: always_populate_raw_post_data = -1" +_key="always_populate_raw_post_data" +_val=-1 +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + +## ----- +## - END: Configure php.ini (base) +## ----- + + + +## ----- +## - configure OPCache +## ----- + +zend_extension_opcache=$(find ${PREFIX_PHP}/lib/php/extensions -name opcache.so -print) + +if [[ -n "$zend_extension_opcache" ]];then + + echononl "\tphp.ini: zend_extension = \"$zend_extension_opcache\" .." + perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nzend_extension = ${zend_extension_opcache}\n#" $PHP_INI_FILE + #sed -i "s/^/\nzend_extension = ${zend_extension_opcache}\n\n/" $PHP_INI_FILE + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + ## - set opcache.error_log="/var/log/apache2/ + ## - + echononl "\tphp.ini: opcache.error_log = /var/log/apache2/opcache_errors.log" + _key="opcache.error_log" + _val="/var/log/apache2/opcache_errors.log" + if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? + elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? + fi + if [ "$_retval" = "0" ]; then + echo_ok + else + echo_failed + fi + touch $_val + chown ${HTTPD_USER}:$HTTPD_GROUP $_val + + ## - set opcache.enable=1 + ## - + echononl "\tphp.ini: opcache.enable = 1 .." + opcache_key="opcache.enable" + opcache_val=1 + if grep -e "^\s*${opcache_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${opcache_key}\s*=.*)#;\1\n*${opcache_key} = ${opcache_val}#" $PHP_INI_FILE + _retval=$? + elif grep -e "^\s*;\s*${opcache_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*;${opcache_key}\s*=.*)#\1\n${opcache_key} = ${opcache_val}#" $PHP_INI_FILE + _retval=$? + fi + if [ "$_retval" = "0" ]; then + echo_ok + else + echo_failed + fi + + ## - set opcache.enable_cli=0 + ## - + echononl "\tphp.ini: opcache.enable_cli = 0 .." + opcache_key="opcache.enable_cli" + opcache_val=0 + if grep -e "^\s*${opcache_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${opcache_key}\s*=.*)#;\1\n*${opcache_key} = ${opcache_val}#" $PHP_INI_FILE + _retval=$? + elif grep -e "^\s*;\s*${opcache_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*;${opcache_key}\s*=.*)#\1\n${opcache_key} = ${opcache_val}#" $PHP_INI_FILE + _retval=$? + fi + if [ "$_retval" = "0" ]; then + echo_ok + else + echo_failed + fi + + ## - set opcache.interned_strings_buffer=8 + ## - + echononl "\tphp.ini: opcache.interned_strings_buffer = 8 .." + opcache_key="opcache.interned_strings_buffer" + opcache_val=8 + if grep -e "^\s*${opcache_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${opcache_key}\s*=.*)#;\1\n*${opcache_key} = ${opcache_val}#" $PHP_INI_FILE + _retval=$? + elif grep -e "^\s*;\s*${opcache_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*;${opcache_key}\s*=.*)#\1\n${opcache_key} = ${opcache_val}#" $PHP_INI_FILE + _retval=$? + fi + if [ "$_retval" = "0" ]; then + echo_ok + else + echo_failed + fi + + ## - set opcache.max_accelerated_files=4000 + ## - + echononl "\tphp.ini: opcache.max_accelerated_files = 4000 .." + opcache_key="opcache.max_accelerated_files" + opcache_val=4000 + if grep -e "^\s*${opcache_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${opcache_key}\s*=.*)#;\1\n*${opcache_key} = ${opcache_val}#" $PHP_INI_FILE + _retval=$? + elif grep -e "^\s*;\s*${opcache_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*;${opcache_key}\s*=.*)#\1\n${opcache_key} = ${opcache_val}#" $PHP_INI_FILE + _retval=$? + fi + if [ "$_retval" = "0" ]; then + echo_ok + else + echo_failed + fi + + ## - set opcache.validate_timestamps=1 + ## - + echononl "\tphp.ini: opcache.validate_timestamps = 1 .." + opcache_key="opcache.validate_timestamps" + opcache_val=1 + if grep -e "^\s*${opcache_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${opcache_key}\s*=.*)#;\1\n*${opcache_key} = ${opcache_val}#" $PHP_INI_FILE + _retval=$? + elif grep -e "^\s*;\s*${opcache_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*;${opcache_key}\s*=.*)#\1\n${opcache_key} = ${opcache_val}#" $PHP_INI_FILE + _retval=$? + fi + if [ "$_retval" = "0" ]; then + echo_ok + else + echo_failed + fi + + ## - set opcache.revalidate_freq=60 + ## - + echononl "\tphp.ini: opcache.revalidate_freq = 60 .." + opcache_key="opcache.revalidate_freq" + opcache_val=60 + if grep -e "^\s*${opcache_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${opcache_key}\s*=.*)#;\1\n*${opcache_key} = ${opcache_val}#" $PHP_INI_FILE + _retval=$? + elif grep -e "^\s*;\s*${opcache_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*;${opcache_key}\s*=.*)#\1\n${opcache_key} = ${opcache_val}#" $PHP_INI_FILE + _retval=$? + fi + if [ "$_retval" = "0" ]; then + echo_ok + else + echo_failed + fi + + ## - set opcache.fast_shutdown=0 + ## - + ## - setting opcache.fast_shutdown=1 causes the following error in apache error_log: + ## - + ## - zend_mm_heap corrupted + ## - + ## - sometimes un conjunction with + ## - + ## - [Sun May 11 23:02:25.120263 2014] [core:warn] [pid 11566:tid 139746681894656] + ## - AH00045: child process 28405 still did not exit, sending a SIGTERM + ## - + echononl "\tphp.ini: opcache.fast_shutdown = 0 .." + opcache_key="opcache.fast_shutdown" + opcache_val=0 + if grep -e "^\s*${opcache_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${opcache_key}\s*=.*)#;\1\n*${opcache_key} = ${opcache_val}#" $PHP_INI_FILE + _retval=$? + elif grep -e "^\s*;\s*${opcache_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*;${opcache_key}\s*=.*)#\1\n${opcache_key} = ${opcache_val}#" $PHP_INI_FILE + _retval=$? + fi + if [ "$_retval" = "0" ]; then + echo_ok + else + echo_failed + fi +fi + +## ----- +## - END: configure OPCache +## ----- + +## ----- +## - Start PHP-FPM Engine if requested +## ----- + +echo "" +echononl "\tStarting PHP-FPM Engine (v${MAJOR_VERSION}).." +if $ACTIVATE_PHP_FPM_INIT_SCRIPT ; then + if $SYSTEMD_EXISTS ; then + systemctl start php-${MAJOR_VERSION}-fpm > /dev/null 2>&1 + if [[ "$?" = "0" ]]; then + echo_ok + else + echo_failed + error "Starting PHP-FPM Engine failed!" + fi + else + $FPM_INIT_SCRIPT start > /dev/null 2>&1 + if [[ "$?" = "0" ]]; then + echo_ok + else + echo_failed + error "Starting PHP-FPM Engine failed!" + fi + fi +fi + + +cd $pwd + +cat< /dev/null 2>&1 + +## -------------------------------------------------- + +## - get sources.. +## - +cd $_srcdir + +if [ ! -f ${_srcdir}/php-$VERSION.tar.bz2 ]; then + wget http://museum.php.net/php5/php-$VERSION.tar.bz2 +fi + + +bunzip2 < ${_srcdir}/php-$VERSION.tar.bz2 | tar -xf - || exit 1 +chown -R root.root php-$VERSION || exit 1 +mv php-$VERSION $_builddir +cd $_builddir || exit 1 + +echo -e "\n\tgoing to configure.." +echo -e "\t(see ${_logdir}/php-configure.log for more details)" + + +# : ${_arch:=i686} +# : ${_arch:=athlon} +: ${_arch:=k8} ## --> x86-64 instructionset + +##_cflags="-O2 -march=$_arch " + +## - LDFLAGS="-s" --> Remove all symbol table and relocation information from the executable. +## F77="/usr/bin/g77-3.4" \ +## CXXCPP="/usr/bin/g++-3.4 -E" \ +## CC="/usr/bin/gcc-3.4" \ +## CXX="/usr/bin/g++-3.4" \ +## CPP="/usr/bin/cpp-3.4" \ +## CFLAGS="$_cflags" LDFLAGS="-s" \ +CFLAGS="-fPIC" \ +LDFLAGS="-s" \ +./configure \ + --prefix=$PREFIX_PHP \ + --with-apxs2=$APXS \ + --with-gd \ + --with-config-file-path=${APACHE_BASEDIR}/conf \ + --with-mysql=/usr/local/mysql \ + --with-mysqli=/usr/local/mysql/bin/mysql_config \ + --with-pdo-mysql=/usr/local/mysql \ + --with-mysql-sock \ + --with-pgsql \ + --with-regex=system \ + --enable-wddx \ + --enable-exif \ + --with-zlib \ + --with-gdbm \ + --with-openssl=/usr/local/openssl-0.9.8y \ + --with-jpeg-dir \ + --with-png-dir \ + --with-curl \ + --enable-dba \ + --with-mcrypt \ + --with-xpm-dir \ + --with-t1lib \ + --with-freetype-dir \ + --enable-ftp \ + --with-readline \ + --enable-sockets \ + --with-imap-ssl \ + --with-kerberos \ + --with-gettext \ + --enable-soap \ + --enable-mbstring \ + --enable-zip \ + --enable-calendar \ + --enable-bcmath \ + --with-bz2 \ + --enable-shmop \ + --enable-sysvmsg \ + --enable-sysvsem \ + --enable-sysvshm \ + > ${_logdir}/php-configure.log 2>&1 || exit 1 + + + ## --with-mm \ # does not work with apache v2.4 + +## --with-pgsql=/usr/local/pgsql \ +## --with-mysql \ +## --with-mysql \ +## --with-mysqli \ +## --with-pdo-mysql \ + +## --with-openssl=/usr/local/openssl-0.9.8y \ + +## --enable-force-cgi-redirect \ +## --enable-track-vars \ +## --with-tiff-dir \ +## --with-ttf \ +## --with-memcache \ +## --with-xml \ + +echo -e "\n\tgoing to compile.." +echo -e "\t(see ${_logdir}/php-make.log for more details)" +make > ${_logdir}/php-make.log 2>&1 || exit 1 + +echo -e "\n\tgoing to install.." +echo -e "\t(see ${_logdir}/php-make_install.log for more details)" +make install > ${_logdir}/php-make_install.log 2>&1 || exit 1 + +#cp php.ini-dist ${APACHE_BASEDIR}/conf/php.ini || exit 1 +[ -f ${APACHE_BASEDIR}/conf/php.ini ] && cp -a ${APACHE_BASEDIR}/conf/php.ini ${APACHE_BASEDIR}/conf/php.ini-`date +"%Y-%m-%d-%H%M"` +cp php.ini-dist ${APACHE_BASEDIR}/conf/php.ini || exit 1 + +_set_php_entries="" +echo "" +echo -n "do you want to set \"LoadModule\" entries in httpd.conf ? [y/n]: " +read _set_php_entries +if [ "y" = "$_set_php_entries" -o "Y" = "$_set_php_entries" -o "Yes" = "$_set_php_entries" -o "yes" = "$_set_php_entries" ];then + sed -i -r \ + -e "s&(^\s*LoadModule php5_module.*$)&\1\n#\n AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml\n AddType application/x-httpd-php-source .phps\n#&" ${APACHE_BASEDIR}/conf/httpd.conf + #-e "s&(^\s*LoadModule php5_module.*$)&\1\n\n AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml\n AddType application/x-httpd-php-source .phps\n&" ${APACHE_BASEDIR}/conf/httpd.conf +fi + +_set_link="" +echo +echo -n "do you want to set symlink /usr/local/php -> `basename $PREFIX_PHP` ? [y/n]: " +read _set_link +if [ "y" = "$_set_link" -o "Y" = "$_set_link" -o "Yes" = "$_set_link" -o "yes" = "$_set_link" ];then + if [ -L /usr/local/php ];then + rm -f /usr/local/php + fi + ln -s `basename $PREFIX_PHP` /usr/local/php +fi + +## - special for debian. set manpath entries +## - +if [ -f /etc/manpath.config ];then + if ! grep /usr/local/php/man /etc/manpath.config > /dev/null 2<&1 ; then + echo >> /etc/manpath.config + echo "MANDATORY_MANPATH /usr/local/php/man /var/cache/man" >> /etc/manpath.config + echo "MANPATH_MAP /usr/local/php/bin /usr/local/php/man" >> /etc/manpath.config + echo "MANDB_MAP /usr/local/php/man /var/cache/man" >> /etc/manpath.config + fi +elif [ -f /etc/man.conf];then + if ! grep /opt/php/man /etc/man.conf > /dev/null 2<&1 ; then + echo >> /etc/man.conf + echo "MANPATH /opt/php/man /var/cache/man" >> /etc/man.conf + echo "MANPATH_MAP /opt/php/bin /opt/php/man" >> /etc/man.conf + fi +fi + + + +cd $pwd + +cat< + AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml + AddType application/x-httpd-php-source .phps + + + +EOF + +exit 0 diff --git a/old-versions/mod_php_5.2_apache-2.4_install.sh b/old-versions/mod_php_5.2_apache-2.4_install.sh new file mode 100755 index 0000000..2b44830 --- /dev/null +++ b/old-versions/mod_php_5.2_apache-2.4_install.sh @@ -0,0 +1,215 @@ +#!/usr/bin/env bash + +# php ( fuer Apache 2 ) +# +VERSION=5.2.17 +APACHE_VERSION=2.4.10 +APACHE_BASEDIR=/usr/local/httpd-${APACHE_VERSION}_php-${VERSION} +APXS=${APACHE_BASEDIR}/bin/apxs + +PREFIX_PHP="/usr/local/php-$VERSION-httpd-${APACHE_VERSION}" + +_srcdir=/usr/local/src/apache2 +_logdir=${_srcdir}/log_php-${VERSION}_http-${APACHE_VERSION}_build + +_pwd=`pwd` +_builddir=${_srcdir}/php-${VERSION}_http-${APACHE_VERSION} + +mkdir -p $_logdir > /dev/null 2>&1 + +## -------------------------------------------------- + +## - get sources.. +## - +cd $_srcdir + +if [ ! -f ${_srcdir}/php-$VERSION.tar.bz2 ]; then + wget http://museum.php.net/php5/php-$VERSION.tar.bz2 +fi + + +bunzip2 < ${_srcdir}/php-$VERSION.tar.bz2 | tar -xf - || exit 1 +chown -R root.root php-$VERSION || exit 1 +mv php-$VERSION $_builddir +cd $_builddir || exit 1 + +echo -e "\n\tgoing to configure.." +echo -e "\t(see ${_logdir}/php-configure.log for more details)" + + +# : ${_arch:=i686} +# : ${_arch:=athlon} +: ${_arch:=k8} ## --> x86-64 instructionset + +##_cflags="-O2 -march=$_arch " + +## - LDFLAGS="-s" --> Remove all symbol table and relocation information from the executable. +## F77="/usr/bin/g77-3.4" \ +## CXXCPP="/usr/bin/g++-3.4 -E" \ +## CC="/usr/bin/gcc-3.4" \ +## CXX="/usr/bin/g++-3.4" \ +## CPP="/usr/bin/cpp-3.4" \ +## CFLAGS="$_cflags" LDFLAGS="-s" \ +LDFLAGS="-s" \ +./configure \ + --prefix=$PREFIX_PHP \ + --with-apxs2=$APXS \ + --with-gd \ + --with-config-file-path=${APACHE_BASEDIR}/conf \ + --with-mysql=/usr/local/mysql \ + --with-mysqli=/usr/local/mysql/bin/mysql_config \ + --with-pdo-mysql=/usr/local/mysql \ + --with-mysql-sock \ + --with-pgsql \ + --with-regex=system \ + --enable-wddx \ + --enable-exif \ + --with-zlib \ + --with-gdbm \ + --with-openssl=/usr/local/openssl-0.9.8y \ + --with-jpeg-dir \ + --with-png-dir \ + --with-curl \ + --enable-dba \ + --with-mcrypt \ + --with-xpm-dir \ + --with-t1lib \ + --with-freetype-dir \ + --enable-ftp \ + --with-readline \ + --enable-sockets \ + --with-imap-ssl \ + --with-kerberos \ + --with-gettext \ + --enable-soap \ + --enable-mbstring \ + --enable-zip \ + --enable-calendar \ + --enable-bcmath \ + --with-bz2 \ + --enable-shmop \ + --enable-sysvmsg \ + --enable-sysvsem \ + --enable-sysvshm \ + > ${_logdir}/php-configure.log 2>&1 || exit 1 + + + ## --with-mm \ # does not work with apache v2.4 + +## --with-pgsql=/usr/local/pgsql \ +## --with-mysql \ +## --with-mysql \ +## --with-mysqli \ +## --with-pdo-mysql \ + +## --with-openssl=/usr/local/openssl-0.9.8y \ + +## --enable-force-cgi-redirect \ +## --enable-track-vars \ +## --with-tiff-dir \ +## --with-ttf \ +## --with-memcache \ +## --with-xml \ + +echo -e "\n\tgoing to compile.." +echo -e "\t(see ${_logdir}/php-make.log for more details)" +make > ${_logdir}/php-make.log 2>&1 || exit 1 + +echo -e "\n\tgoing to install.." +echo -e "\t(see ${_logdir}/php-make_install.log for more details)" +make install > ${_logdir}/php-make_install.log 2>&1 || exit 1 + +#cp php.ini-dist ${APACHE_BASEDIR}/conf/php.ini || exit 1 +[ -f ${APACHE_BASEDIR}/conf/php.ini ] && cp -a ${APACHE_BASEDIR}/conf/php.ini ${APACHE_BASEDIR}/conf/php.ini-`date +"%Y-%m-%d-%H%M"` +cp php.ini-dist ${APACHE_BASEDIR}/conf/php.ini || exit 1 + +_set_php_entries="" +echo "" +echo -n "do you want to set \"LoadModule\" entries in httpd.conf ? [y/n]: " +read _set_php_entries +if [ "y" = "$_set_php_entries" -o "Y" = "$_set_php_entries" -o "Yes" = "$_set_php_entries" -o "yes" = "$_set_php_entries" ];then + sed -i -r \ + -e "s&(^\s*LoadModule php5_module.*$)&\1\n#\n AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml\n AddType application/x-httpd-php-source .phps\n#&" ${APACHE_BASEDIR}/conf/httpd.conf + #-e "s&(^\s*LoadModule php5_module.*$)&\1\n\n AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml\n AddType application/x-httpd-php-source .phps\n&" ${APACHE_BASEDIR}/conf/httpd.conf +fi + +_set_link="" +echo +echo -n "do you want to set symlink /usr/local/php -> `basename $PREFIX_PHP` ? [y/n]: " +read _set_link +if [ "y" = "$_set_link" -o "Y" = "$_set_link" -o "Yes" = "$_set_link" -o "yes" = "$_set_link" ];then + if [ -L /usr/local/php ];then + rm -f /usr/local/php + fi + ln -s `basename $PREFIX_PHP` /usr/local/php +fi + +## - special for debian. set manpath entries +## - +if [ -f /etc/manpath.config ];then + if ! grep /usr/local/php/man /etc/manpath.config > /dev/null 2<&1 ; then + echo >> /etc/manpath.config + echo "MANDATORY_MANPATH /usr/local/php/man /var/cache/man" >> /etc/manpath.config + echo "MANPATH_MAP /usr/local/php/bin /usr/local/php/man" >> /etc/manpath.config + echo "MANDB_MAP /usr/local/php/man /var/cache/man" >> /etc/manpath.config + fi +elif [ -f /etc/man.conf];then + if ! grep /opt/php/man /etc/man.conf > /dev/null 2<&1 ; then + echo >> /etc/man.conf + echo "MANPATH /opt/php/man /var/cache/man" >> /etc/man.conf + echo "MANPATH_MAP /opt/php/bin /opt/php/man" >> /etc/man.conf + fi +fi + + + +cd $pwd + +cat< + AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml + AddType application/x-httpd-php-source .phps + + + +EOF + +exit 0 diff --git a/old-versions/mod_php_5.3_apache-2.2_install.sh b/old-versions/mod_php_5.3_apache-2.2_install.sh new file mode 100755 index 0000000..9f3a99f --- /dev/null +++ b/old-versions/mod_php_5.3_apache-2.2_install.sh @@ -0,0 +1,209 @@ +#!/usr/bin/env bash + +# php ( fuer Apache 2 ) +# +VERSION=5.3.27 +APACHE_VERSION=2.2.25 +APACHE_BASEDIR=/usr/local/httpd-${APACHE_VERSION}_php-${VERSION} +APXS=${APACHE_BASEDIR}/bin/apxs + +PREFIX_PHP="/usr/local/php-$VERSION-httpd-${APACHE_VERSION}" + +_srcdir=/usr/local/src/apache2 +_logdir=${_srcdir}/log_php-${VERSION}_http-${APACHE_VERSION}_build + +_pwd=`pwd` +_builddir=${_srcdir}/php-${VERSION}_http-${APACHE_VERSION} + +mkdir -p $_logdir > /dev/null 2>&1 + +## -------------------------------------------------- + +## - get sources.. +## - +cd $_srcdir + +if [ ! -f ${_srcdir}/php-$VERSION.tar.bz2 ]; then + wget http://de.php.net/distributions/php-$VERSION.tar.bz2 +fi + + +bunzip2 < ${_srcdir}/php-$VERSION.tar.bz2 | tar -xf - || exit 1 +chown -R root.root php-$VERSION || exit 1 +mv php-$VERSION $_builddir +cd $_builddir || exit 1 + +echo -e "\n\tgoing to configure.." +echo -e "\t(see ${_logdir}/php-configure.log for more details)" + + +# : ${_arch:=i686} +# : ${_arch:=athlon} +: ${_arch:=k8} ## --> x86-64 instructionset + +##_cflags="-O2 -march=$_arch " + +## - LDFLAGS="-s" --> Remove all symbol table and relocation information from the executable. +## F77="/usr/bin/g77-3.4" \ +## CXXCPP="/usr/bin/g++-3.4 -E" \ +## CC="/usr/bin/gcc-3.4" \ +## CXX="/usr/bin/g++-3.4" \ +## CPP="/usr/bin/cpp-3.4" \ +## CFLAGS="$_cflags" LDFLAGS="-s" \ +LDFLAGS="-s" \ +./configure \ + --prefix=$PREFIX_PHP \ + --with-apxs2=$APXS \ + --with-gd \ + --with-config-file-path=${APACHE_BASEDIR}/conf \ + --with-mysql \ + --with-mysql-sock \ + --with-mysqli \ + --with-pdo-mysql \ + --with-pgsql \ + --with-regex=system \ + --enable-wddx \ + --enable-exif \ + --with-zlib \ + --with-openssl \ + --with-gdbm \ + --with-jpeg-dir \ + --with-png-dir \ + --with-curl \ + --enable-dba \ + --with-mcrypt \ + --with-xpm-dir \ + --with-t1lib \ + --with-freetype-dir \ + --enable-ftp \ + --with-readline \ + --with-mm \ + --enable-sockets \ + --with-imap-ssl \ + --with-kerberos \ + --with-gettext \ + --enable-soap \ + --enable-mbstring \ + --enable-zip \ + --enable-calendar \ + --enable-bcmath \ + --with-bz2 \ + --enable-shmop \ + --enable-sysvmsg \ + --enable-sysvsem \ + --enable-sysvshm \ + > ${_logdir}/php-configure.log 2>&1 || exit 1 + + +## --with-pgsql=/usr/local/pgsql \ +## --with-mysql=/usr/local/mysql \ + +## --enable-force-cgi-redirect \ +## --enable-track-vars \ +## --with-tiff-dir \ +## --with-ttf \ +## --with-memcache \ +## --with-xml \ + +echo -e "\n\tgoing to compile.." +echo -e "\t(see ${_logdir}/php-make.log for more details)" +make > ${_logdir}/php-make.log 2>&1 || exit 1 + +echo -e "\n\tgoing to install.." +echo -e "\t(see ${_logdir}/php-make_install.log for more details)" +make install > ${_logdir}/php-make_install.log 2>&1 || exit 1 + +#cp php.ini-dist ${APACHE_BASEDIR}/conf/php.ini || exit 1 +[ -f ${APACHE_BASEDIR}/conf/php.ini ] && cp -a ${APACHE_BASEDIR}/conf/php.ini ${APACHE_BASEDIR}/conf/php.ini-`date +"%Y-%m-%d-%H%M"` +cp php.ini-production ${APACHE_BASEDIR}/conf/php.ini || exit 1 + +_set_php_entries="" +echo "" +echo -n "\do you want to set \"LoadModule\" entries in httpd.conf ? [y/n]: " +read _set_php_entries +if [ "y" = "$_set_php_entries" -o "Y" = "$_set_php_entries" -o "Yes" = "$_set_php_entries" -o "yes" = "$_set_php_entries" ];then + sed -i -r \ + -e "s&(^\s*LoadModule php5_module.*$)&\1\n#\n AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml\n AddType application/x-httpd-php-source .phps\n#&" ${APACHE_BASEDIR}/conf/httpd.conf + #-e "s&(^\s*LoadModule php5_module.*$)&\1\n\n AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml\n AddType application/x-httpd-php-source .phps\n&" ${APACHE_BASEDIR}/conf/httpd.conf +fi + +_set_link="" +echo +echo -n "do you want to set symlink /usr/local/php -> `basename $PREFIX_PHP` ? [y/n]: " +read _set_link +if [ "y" = "$_set_link" -o "Y" = "$_set_link" -o "Yes" = "$_set_link" -o "yes" = "$_set_link" ];then + if [ -L /usr/local/php ];then + rm -f /usr/local/php + fi + ln -s `basename $PREFIX_PHP` /usr/local/php +fi + +## - special for debian. set manpath entries +## - +if [ -f /etc/manpath.config ];then + if ! grep /usr/local/php/man /etc/manpath.config > /dev/null 2<&1 ; then + echo >> /etc/manpath.config + echo "MANDATORY_MANPATH /usr/local/php/man /var/cache/man" >> /etc/manpath.config + echo "MANPATH_MAP /usr/local/php/bin /usr/local/php/man" >> /etc/manpath.config + echo "MANDB_MAP /usr/local/php/man /var/cache/man" >> /etc/manpath.config + fi +elif [ -f /etc/man.conf];then + if ! grep /opt/php/man /etc/man.conf > /dev/null 2<&1 ; then + echo >> /etc/man.conf + echo "MANPATH /opt/php/man /var/cache/man" >> /etc/man.conf + echo "MANPATH_MAP /opt/php/bin /opt/php/man" >> /etc/man.conf + fi +fi + + + +cd $pwd + +cat< + AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml + AddType application/x-httpd-php-source .phps + + + +EOF + +exit 0 diff --git a/old-versions/mod_php_5.3_apache-2.4_install.sh b/old-versions/mod_php_5.3_apache-2.4_install.sh new file mode 100755 index 0000000..8964167 --- /dev/null +++ b/old-versions/mod_php_5.3_apache-2.4_install.sh @@ -0,0 +1,729 @@ +#!/usr/bin/env bash + +# php ( fuer Apache 2 ) +# +VERSION=5.3.29 + +WITHOUT_APACHE_MOD_PHP=false +#WITHOUT_APACHE_MOD_PHP=true + +APACHE_VERSION=2.4.12 +APACHE_BASEDIR=/usr/local/httpd-${APACHE_VERSION}_php-${VERSION} +APXS=${APACHE_BASEDIR}/bin/apxs + + +_srcdir=/usr/local/src/apache2 + +_pwd=`pwd` + +## -------------------------------------------------- + +## - Let make use multiple cores (-j) +## - +export MAKEFLAGS=-j$(expr `grep "^processor" /proc/cpuinfo | sort -u | wc -l` + 1) + + +## --- Some functions +## --- +echononl(){ + echo X\\c > /tmp/shprompt$$ + if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then + echo -e -n "$*\\c" 1>&2 + else + echo -e -n "$*" 1>&2 + fi + rm /tmp/shprompt$$ +} + +fatal(){ + echo "" + echo -e "Fehler: $*" + echo "" + echo -e "\t\033[31m\033[1mInstalllation wird abgebrochen\033[m\033[m" + echo "" + exit 1 +} + +echo_ok() { + echo -e "\033[75G[ \033[1;32mok\033[m ]" + ## echo -e " [ ok ]" +} +echo_failed(){ + echo -e "\033[75G[ \033[1;31mfailed\033[m ]" + ## echo -e " [ failed ]" +} +echo_skipped() { + echo -e "\033[75G[ \033[33m\033[1mskipped\033[m ]" +} +## --- +## --- END: functions + + +## -------------------------------------------------- + +if $WITHOUT_APACHE_MOD_PHP ; then + PREFIX_PHP=/usr/local/php-$VERSION + PHP_INI_FILE="${PREFIX_PHP}/etc/php.ini" + _builddir=${_srcdir}/php-${VERSION} + _logdir=${_srcdir}/log_php-${VERSION}_build +elif [ -n "$APACHE_VERSION" ]; then + PREFIX_PHP="/usr/local/php-$VERSION-httpd-${APACHE_VERSION}" + PHP_INI_FILE="${APACHE_BASEDIR}/conf/php.ini" + _builddir=${_srcdir}/php-${VERSION}_http-${APACHE_VERSION} + _logdir=${_srcdir}/log_php-${VERSION}_http-${APACHE_VERSION}_build +else + echo "" + echo -e "\t[ Error ]: I was requested to build php with apache mod_php module," + echo -e "\t but environment \"APACHE_VERSION\" is unset." + echo "" + exit +fi + + +if [ -d "$_logdir" ];then + mv $_logdir $_logdir.`date +%Y%m%d-%H%M` +fi +mkdir -p $_logdir > /dev/null 2>&1 +if [ -d "$_builddir" ];then + mv $_builddir $_builddir.`date +%Y%m%d-%H%M` +fi +if [ -d "$PREFIX_PHP" ];then + mv $PREFIX_PHP $PREFIX_PHP.`date +%Y%m%d-%H%M` +fi + + +## - get sources.. +## - +cd $_srcdir + +if [ ! -f ${_srcdir}/php-$VERSION.tar.bz2 ]; then + wget http://de.php.net/distributions/php-$VERSION.tar.bz2 +fi + + +bunzip2 < ${_srcdir}/php-$VERSION.tar.bz2 | tar -xf - || exit 1 +chown -R root.root php-$VERSION || exit 1 +if ! $WITHOUT_APACHE_MOD_PHP ; then + mv php-$VERSION $_builddir +fi +cd $_builddir || exit 1 + +if [ "$VERSION" = "5.3.28" ]; then + echo -e "\n\tgoing to patch file \"Zend/zend_language_parser.y\" .." + if [ ! -f "${_srcdir}/bison_build_2a.patch" ]; then + fatal "Cannot find patch \"bison_build_2a.patch\" for Zend/zend_language_parser.y\n\t See: https://bugs.php.net/patch-display.php?bug_id=64503&patch=bison_build_2a.patch&revision=latest" + else + patch ${_builddir}/Zend/zend_language_parser.y ${_srcdir}/bison_build_2a.patch > /dev/null + fi +fi + +echo -e "\n\tgoing to configure.." +echo -e "\t(see ${_logdir}/php-configure.log for more details)" + + +## - if you get the following error: +## - +## - configure: error: libXpm.(a|so) not found +## - +## - set a symlink /usr/lib/libXpm.a --> /usr/lib/x86_64-linux-gnu/libXpm.a +## - +if [ ! -h "/usr/lib/libXpm.a" -a ! -f "/usr/lib/libXpm.a" ];then + ln -s x86_64-linux-gnu/libXpm.a /usr/lib/libXpm.a +fi +if [ ! -h "/usr/lib/libjpeg.a" -a ! -f "/usr/lib/libjpeg.a" ];then + ln -s x86_64-linux-gnu/libjpeg.a /usr/lib/libjpeg.a +fi +if [ ! -h "/usr/lib/libXpm.a" -a ! -f "/usr/lib/libXpm.a" ];then + ln -s x86_64-linux-gnu/libpng.a /usr/lib/libpng.a +fi + + +# : ${_arch:=i686} +# : ${_arch:=athlon} +: ${_arch:=k8} ## --> x86-64 instructionset + +##_cflags="-O2 -march=$_arch " + +## - LDFLAGS="-s" --> Remove all symbol table and relocation information from the executable. +## F77="/usr/bin/g77-3.4" \ +## CXXCPP="/usr/bin/g++-3.4 -E" \ +## CC="/usr/bin/gcc-3.4" \ +## CXX="/usr/bin/g++-3.4" \ +## CPP="/usr/bin/cpp-3.4" \ +## CFLAGS="$_cflags" LDFLAGS="-s" \ +config_params=" + --prefix=$PREFIX_PHP \ + --with-gd \ + --with-mysql=/usr/local/mysql \ + --with-mysqli=/usr/local/mysql/bin/mysql_config \ + --with-pdo-mysql=/usr/local/mysql \ + --with-mysql-sock \ + --with-pgsql \ + --with-pdo-pgsql \ + --with-regex=system \ + --enable-wddx \ + --enable-exif \ + --with-zlib \ + --with-openssl \ + --with-gdbm \ + --with-jpeg-dir \ + --with-png-dir \ + --with-curl \ + --enable-dba \ + --with-mcrypt \ + --with-xpm-dir \ + --with-t1lib \ + --with-freetype-dir \ + --enable-ftp \ + --with-readline \ + --enable-sockets \ + --with-imap \ + --with-imap-ssl \ + --with-kerberos \ + --with-gettext \ + --with-pspell \ + --enable-soap \ + --enable-mbstring \ + --enable-zip \ + --enable-calendar \ + --enable-bcmath \ + --with-bz2 \ + --enable-shmop \ + --enable-sysvmsg \ + --enable-sysvsem \ + --enable-sysvshm \ + --enable-cgi" + +if $WITHOUT_APACHE_MOD_PHP ; then + config_params="$config_params --without-apxs2 --without-apxs --with-config-file-path=${PREFIX_PHP}/etc" +else + config_params="$config_params --with-apxs2=$APXS --with-config-file-path=${APACHE_BASEDIR}/conf" +fi + +LDFLAGS="-s" \ +./configure $config_params > ${_logdir}/php-configure.log 2>&1 || exit 1 + + ## --with-mm \ # does not work with apache v2.4 + +## --with-pgsql=/usr/local/pgsql \ +## --with-mysql=/usr/local/mysql \ +## --with-mysqli=/usr/local/mysql/bin/mysql_config \ +## --with-pdo-mysql=/usr/local/mysql \ + +## --enable-force-cgi-redirect \ +## --enable-track-vars \ +## --with-tiff-dir \ +## --with-ttf \ +## --with-memcache \ +## --with-xml \ + +echo -e "\n\tgoing to compile.." +echo -e "\t(see ${_logdir}/php-make.log for more details)" +make > ${_logdir}/php-make.log 2>&1 || exit 1 + +echo -e "\n\tgoing to install.." +echo -e "\t(see ${_logdir}/php-make_install.log for more details)" +make install > ${_logdir}/php-make_install.log 2>&1 + +if [ "$?" != "0" ]; then + make install > ${_logdir}/php-make_install.log 2>&1 + if [ "$?" != "0" ]; then + echo -e "\n [ Warn ] make install returncode: $?" + echo " for safety:" + echo " # cd $_builddir" + echo " # make install" + fi +fi + +echo -e "\n\tBasic installation complete..\n" + +#cp php.ini-production $PHP_INI_FILE || exit 1 +[ -f $PHP_INI_FILE ] && cp -a $PHP_INI_FILE ${PHP_INI_FILE}-`date +"%Y-%m-%d-%H%M"` +cp php.ini-production $PHP_INI_FILE || exit 1 + + +if ! $WITHOUT_APACHE_MOD_PHP ; then + _set_php_entries="" + echo "" + echo -n "do you want to set \"LoadModule\" entries in httpd.conf ? [y/n]: " + read _set_php_entries + if [ "y" = "$_set_php_entries" -o "Y" = "$_set_php_entries" -o "Yes" = "$_set_php_entries" -o "yes" = "$_set_php_entries" ];then + sed -i -r \ + -e "s&(^\s*LoadModule php5_module.*$)&\1\n#\n AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml\n AddType application/x-httpd-php-source .phps\n#&" ${APACHE_BASEDIR}/conf/httpd.conf + #-e "s&(^\s*LoadModule php5_module.*$)&\1\n\n AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml\n AddType application/x-httpd-php-source .phps\n&" ${APACHE_BASEDIR}/conf/httpd.conf + fi +fi + +_set_link="" +echo +echo -n "do you want to set symlink /usr/local/php -> `basename $PREFIX_PHP` ? [y/n]: " +read _set_link +if [ "y" = "$_set_link" -o "Y" = "$_set_link" -o "Yes" = "$_set_link" -o "yes" = "$_set_link" ];then + if [ -L /usr/local/php ];then + rm -f /usr/local/php + fi + ln -s `basename $PREFIX_PHP` /usr/local/php +fi + +## - special for debian. set manpath entries +## - +if [ -f /etc/manpath.config ];then + if ! grep /usr/local/php/man /etc/manpath.config > /dev/null 2<&1 ; then + echo >> /etc/manpath.config + echo "MANDATORY_MANPATH /usr/local/php/man /var/cache/man" >> /etc/manpath.config + echo "MANPATH_MAP /usr/local/php/bin /usr/local/php/man" >> /etc/manpath.config + echo "MANDB_MAP /usr/local/php/man /var/cache/man" >> /etc/manpath.config + fi +elif [ -f /etc/man.conf];then + if ! grep /opt/php/man /etc/man.conf > /dev/null 2<&1 ; then + echo >> /etc/man.conf + echo "MANPATH /opt/php/man /var/cache/man" >> /etc/man.conf + echo "MANPATH_MAP /opt/php/bin /opt/php/man" >> /etc/man.conf + fi +fi + + +## - Add /usr/local/php/bin to the systems PATH variable +## - +echononl "\tAdd `dirname $PREFIX_PHP`/php/bin to the systems PATH variable" +_checkdir=`dirname $PREFIX_PHP`/php/bin +if [ -f /etc/profile ]; then + if ! grep -e "$_checkdir" /etc/profile > /dev/null 2<&1 ; then + perl -i -n -p -e "s#^([ ]*export[ ]*PATH.*$)#check_dir=$_checkdir\nif [ -d \"\\\$check_dir\" ];then\n PATH=\\\${check_dir}:\\\$PATH\nfi\n\n\1#" /etc/profile > /dev/null 2<&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + if ! echo "$PATH" | grep $_checkdir > /dev/null 2>&1 ; then + export PATH=${_checkdir}:$PATH + fi + + else + echo_skipped + fi +fi + + +echo "" + +## ----- +## - Install geoip +## ----- + +echononl "\tInstalling libgeoip1 libgeoip-dev geoip-bin .." +if ! dpkg -l libgeoip-dev | grep -e "^ii" | grep libgeoip-dev > /dev/null 2>&1 ; then + apt-get -q -y install libgeoip1 libgeoip-dev geoip-bin > /dev/null 2>&1 + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + fi +else + echo_skipped +fi + +echononl "\tInstall geoip via pecl.." +${PREFIX_PHP}/bin/pecl install geoip > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tphp.ini: extension=geoip.so .." +_extension="geoip.so" +perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\n#" $PHP_INI_FILE +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +## ----- +## - END: Install geoip +## ----- + + +## ----- +## - Install APC +## ----- + +echononl "\tInstall APC via pecl.." +printf "\n" | ${PREFIX_PHP}/bin/pecl install apc > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tphp.ini: extension=APC .." +_extension="apc.so" +perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\n#" $PHP_INI_FILE +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## ----- +## - END: Install APC +## ----- + + +## ----- +## - Install intl +## ----- + +echononl "\tInstall intl via pecl.." +printf "\n" | ${PREFIX_PHP}/bin/pecl install intl > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tphp.ini: extension=intl .." +_extension="intl.so" +perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\n#" $PHP_INI_FILE +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## ----- +## - END: Install intl +## ----- + + +## ----- +## - Install uploadprogress +## ----- + +echononl "\tInstall uploadprogress via pecl.." +printf "\n" | ${PREFIX_PHP}/bin/pecl install uploadprogress > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tphp.ini: extension=uploadprogress .." +_extension="uploadprogress.so" +perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\n#" $PHP_INI_FILE +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## ----- +## - END: Install uploadprogress +## ----- + + +## ----- +## - Install solr +## ----- + +echononl "\tInstall solr via pecl.." +printf "\n" | ${PREFIX_PHP}/bin/pecl install solr > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tphp.ini: extension=solr .." +_extension="solr.so" +perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\n#" $PHP_INI_FILE +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## ----- +## - END: Install solr +## ----- + + + +## ----- +## - Configure php.ini (base) +## ----- + +## - set date.timezon = "Europe/Berlin" +## - +echononl "\tphp.ini: date.timezone = \"Europe/Berlin\"" +_key="date.timezone" +_val="Europe/Berlin" +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*error_log\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*;${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + +## - set short_open_tag = On +## - +echononl "\tphp.ini: short_open_tag = On" +_key="short_open_tag" +_val="Off" +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*;${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## - set memory_limit = 256M +## - +echononl "\tphp.ini: memory_limit = 256M" +_key="memory_limit" +_val="256M" +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*error_log\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*;${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## - set error_log = /var/log/apache2/php_error.log +## - +echononl "\tphp.ini: error_log = /var/log/apache2/php_error.log" +_key="error_log" +_val="/var/log/apache2/php_error.log" +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*error_log\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*;${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## - set upload_max_filesize = 16M +## - +echononl "\tphp.ini: upload_max_filesize = 16M" +_key="upload_max_filesize" +_val="16M" +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*error_log\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*;${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## - set post_max_size = 128M +## - +echononl "\tphp.ini: post_max_size = 128M" +_key="post_max_size" +_val="128M" +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*error_log\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*;${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## - set max_file_uploads = 50 +## - +echononl "\tphp.ini: max_file_uploads = 50" +_key="max_file_uploads" +_val=50 +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*error_log\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*;${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## - set safe_mode = Off +## - +echononl "\tphp.ini: safe_mode = Off" +_key="safe_mode" +_val="Off" +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*error_log\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*;${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## - set register_globals = Off +## - +echononl "\tphp.ini: register_globals = Off" +_key="register_globals" +_val="Off" +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*error_log\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*;${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + +## ----- +## - END: Configure php.ini (base) +## ----- + + + + +cd $pwd + +if $WITHOUT_APACHE_MOD_PHP ; then + cat<" + > + FCGIWrapper /fcgid .php + + SetHandler fcgid-script + + Options +ExecCGI -Indexes + +END + +else + cat< + AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml + AddType application/x-httpd-php-source .phps + + + +EOF +fi + +exit 0 diff --git a/old-versions/mod_php_5.4_apache-2.2_install.sh b/old-versions/mod_php_5.4_apache-2.2_install.sh new file mode 100755 index 0000000..bbac72c --- /dev/null +++ b/old-versions/mod_php_5.4_apache-2.2_install.sh @@ -0,0 +1,211 @@ +#!/usr/bin/env bash + +# php ( fuer Apache 2 ) +# +VERSION=5.4.45 +APACHE_VERSION=2.2.31 +APACHE_BASEDIR=/usr/local/httpd-${APACHE_VERSION}_php-${VERSION} +APXS=${APACHE_BASEDIR}/bin/apxs + +PREFIX_PHP="/usr/local/php-$VERSION-httpd-${APACHE_VERSION}" + +_srcdir=/usr/local/src/apache2 +_logdir=${_srcdir}/log_php-${VERSION}_http-${APACHE_VERSION}_build + +_pwd=`pwd` +_builddir=${_srcdir}/php-${VERSION}_http-${APACHE_VERSION} + +mkdir -p $_logdir > /dev/null 2>&1 + +## -------------------------------------------------- + +## - get sources.. +## - +cd $_srcdir + +if [ ! -f ${_srcdir}/php-$VERSION.tar.bz2 ]; then + wget http://de.php.net/distributions/php-$VERSION.tar.bz2 +fi + + +bunzip2 < ${_srcdir}/php-$VERSION.tar.bz2 | tar -xf - || exit 1 +chown -R root.root php-$VERSION || exit 1 +mv php-$VERSION $_builddir +cd $_builddir || exit 1 + +echo -e "\n\tgoing to configure.." +echo -e "\t(see ${_logdir}/php-configure.log for more details)" + + +# : ${_arch:=i686} +# : ${_arch:=athlon} +: ${_arch:=k8} ## --> x86-64 instructionset + +##_cflags="-O2 -march=$_arch " + +## - LDFLAGS="-s" --> Remove all symbol table and relocation information from the executable. +## F77="/usr/bin/g77-3.4" \ +## CXXCPP="/usr/bin/g++-3.4 -E" \ +## CC="/usr/bin/gcc-3.4" \ +## CXX="/usr/bin/g++-3.4" \ +## CPP="/usr/bin/cpp-3.4" \ +## CFLAGS="$_cflags" LDFLAGS="-s" \ +LDFLAGS="-s" \ +./configure \ + --prefix=$PREFIX_PHP \ + --with-apxs2=$APXS \ + --with-gd \ + --with-config-file-path=${APACHE_BASEDIR}/conf \ + --with-mysql \ + --with-mysql-sock \ + --with-mysqli \ + --with-pdo-mysql \ + --with-pgsql \ + --with-regex=system \ + --enable-wddx \ + --enable-exif \ + --with-zlib \ + --with-openssl \ + --with-gdbm \ + --with-jpeg-dir \ + --with-png-dir \ + --with-curl \ + --enable-dba \ + --with-mcrypt \ + --with-xpm-dir \ + --with-t1lib \ + --with-freetype-dir \ + --enable-ftp \ + --with-readline \ + --with-mm \ + --enable-sockets \ + --with-imap \ + --with-imap-ssl \ + --with-kerberos \ + --with-gettext \ + --enable-soap \ + --enable-mbstring \ + --enable-zip \ + --enable-calendar \ + --enable-bcmath \ + --with-bz2 \ + --enable-intl \ + --enable-shmop \ + --enable-sysvmsg \ + --enable-sysvsem \ + --enable-sysvshm \ + > ${_logdir}/php-configure.log 2>&1 || exit 1 + + +## --with-pgsql=/usr/local/pgsql \ +## --with-mysql=/usr/local/mysql \ + +## --enable-force-cgi-redirect \ +## --enable-track-vars \ +## --with-tiff-dir \ +## --with-ttf \ +## --with-memcache \ +## --with-xml \ + +echo -e "\n\tgoing to compile.." +echo -e "\t(see ${_logdir}/php-make.log for more details)" +make > ${_logdir}/php-make.log 2>&1 || exit 1 + +echo -e "\n\tgoing to install.." +echo -e "\t(see ${_logdir}/php-make_install.log for more details)" +make install > ${_logdir}/php-make_install.log 2>&1 || exit 1 + +#cp php.ini-dist ${APACHE_BASEDIR}/conf/php.ini || exit 1 +[ -f ${APACHE_BASEDIR}/conf/php.ini ] && cp -a ${APACHE_BASEDIR}/conf/php.ini ${APACHE_BASEDIR}/conf/php.ini-`date +"%Y-%m-%d-%H%M"` +cp php.ini-production ${APACHE_BASEDIR}/conf/php.ini || exit 1 + +_set_php_entries="" +echo "" +echo -n "\do you want to set \"LoadModule\" entries in httpd.conf ? [y/n]: " +read _set_php_entries +if [ "y" = "$_set_php_entries" -o "Y" = "$_set_php_entries" -o "Yes" = "$_set_php_entries" -o "yes" = "$_set_php_entries" ];then + sed -i -r \ + -e "s&(^\s*LoadModule php5_module.*$)&\1\n#\n AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml\n AddType application/x-httpd-php-source .phps\n#&" ${APACHE_BASEDIR}/conf/httpd.conf + #-e "s&(^\s*LoadModule php5_module.*$)&\1\n\n AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml\n AddType application/x-httpd-php-source .phps\n&" ${APACHE_BASEDIR}/conf/httpd.conf +fi + +_set_link="" +echo +echo -n "do you want to set symlink /usr/local/php -> `basename $PREFIX_PHP` ? [y/n]: " +read _set_link +if [ "y" = "$_set_link" -o "Y" = "$_set_link" -o "Yes" = "$_set_link" -o "yes" = "$_set_link" ];then + if [ -L /usr/local/php ];then + rm -f /usr/local/php + fi + ln -s `basename $PREFIX_PHP` /usr/local/php +fi + +## - special for debian. set manpath entries +## - +if [ -f /etc/manpath.config ];then + if ! grep /usr/local/php/man /etc/manpath.config > /dev/null 2<&1 ; then + echo >> /etc/manpath.config + echo "MANDATORY_MANPATH /usr/local/php/man /var/cache/man" >> /etc/manpath.config + echo "MANPATH_MAP /usr/local/php/bin /usr/local/php/man" >> /etc/manpath.config + echo "MANDB_MAP /usr/local/php/man /var/cache/man" >> /etc/manpath.config + fi +elif [ -f /etc/man.conf];then + if ! grep /opt/php/man /etc/man.conf > /dev/null 2<&1 ; then + echo >> /etc/man.conf + echo "MANPATH /opt/php/man /var/cache/man" >> /etc/man.conf + echo "MANPATH_MAP /opt/php/bin /opt/php/man" >> /etc/man.conf + fi +fi + + + +cd $pwd + +cat< + AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml + AddType application/x-httpd-php-source .phps + + + +EOF + +exit 0 diff --git a/old-versions/mod_php_5.4_apache-2.4_install.sh b/old-versions/mod_php_5.4_apache-2.4_install.sh new file mode 100755 index 0000000..d0f3baf --- /dev/null +++ b/old-versions/mod_php_5.4_apache-2.4_install.sh @@ -0,0 +1,1913 @@ +#!/usr/bin/env bash + +# php ( fuer Apache 2 ) +# +_VERSION=5.4.45 + +#WITHOUT_APACHE_MOD_PHP=true +_APACHE_MOD_PHP=no + +_APACHE_VERSION=2.4.25 + +_HTTPD_USER=www-data + +_srcdir=/usr/local/src/apache2 + +_pwd=`pwd` + +_PHP_FPM_SUPPORT=yes + +_SYMLINK_PHP=no +_SYMLINK_PHP_MAJOR_VERSION=no + +MEMORY_LIMIT="256M" +MAX_EXECUTION_TIME=180 +UPLOAD_MAX_FILESIZE="128M" +POST_MAX_SIZE="128M" + + +## - Determin httpd binary +## - +_httpd_binary="`which httpd`" +if [ -z "$_httpd_binary" ]; then + _httpd_binary="`ps -C httpd -f | grep -e \"^root\" | awk '{print$8}'`" + if [ -z "$_httpd_binary" ]; then + if [ -x "/usr/local/apache2/bin/httpd" ]; then + _httpd_binary="/usr/local/apache2/bin/httpd" + fi + fi +fi + + +if [ -x "$_httpd_binary" ];then + ## - Determin websever user + ## - + _pass_web_user=false + web_user="`$_httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" + web_group="`$_httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`" + if [ -z "$web_user" -o -z "$web_group" ]; then + _HTTPD_USER=www-data + else + _HTTPD_USER=$web_user + _HTTPD_GROUP=$web_group + fi +fi + + +## -------------------------------------------------- + +## - Let make use multiple cores (-j) +## - +#export MAKEFLAGS=-j$(expr `grep "^processor" /proc/cpuinfo | sort -u | wc -l` + 1) + +## --- Some functions +## --- +echononl(){ + echo X\\c > /tmp/shprompt$$ + if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then + echo -e -n "$*\\c" 1>&2 + else + echo -e -n "$*" 1>&2 + fi + rm /tmp/shprompt$$ +} + +fatal(){ + echo "" + echo -e "Fehler: $*" + echo "" + echo -e "\t\033[31m\033[1mInstalllation wird abgebrochen\033[m\033[m" + echo "" + exit 1 +} + +warn (){ + echo "" + echo -e "\t[ \033[33m\033[1mWarning\033[m ]: $*" + echo "" +} + + +echo_ok() { + echo -e "\033[75G[ \033[1;32mok\033[m ]" + ## echo -e " [ ok ]" +} +echo_failed(){ + echo -e "\033[75G[ \033[1;31mfailed\033[m ]" + ## echo -e " [ failed ]" +} +echo_skipped() { + echo -e "\033[75G[ \033[33m\033[1mskipped\033[m ]" +} +## --- +## --- END: functions + + +## -------------------------------------------------- + +clear +echo +echo -e "\033[21G\033[32mInstallation PHP \033[m" +echo +echo +echo + +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo "Insert PHP version number." +echo "" +echo "" +VERSION= +while [ "X$VERSION" = "X" ] +do + echononl "PHP Version [$_VERSION]: " + read VERSION + if [ "X$VERSION" = "X" ]; then + VERSION=$_VERSION + fi +done +MAJOR_VERSION=`echo $VERSION | cut -d '.' -f1,2` + +echo "" +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo "Insert User/Group for apache daemon (httpd)." +echo "" +echo "" + +HTTPD_USER= +while [ "X$HTTPD_USER" = "X" ] +do + echononl "apache user [${_HTTPD_USER}]: " + read HTTPD_USER + if [ "X$HTTPD_USER" = "X" ]; then + HTTPD_USER=$_HTTPD_USER + fi +done +if [ -z "$_HTTPD_GROUP" ]; then + if [ "$HTTPD_USER" = "nobody" ]; then + _HTTPD_GROUP="nogroup" + else + _HTTPD_GROUP=$HTTPD_USER + fi +fi +while [ "X$HTTPD_GROUP" = "X" ] +do + echononl "apache group [$_HTTPD_GROUP]: " + read HTTPD_GROUP + if [ "X$HTTPD_GROUP" = "X" ]; then + HTTPD_GROUP=$_HTTPD_GROUP + fi +done + +_PHP_FPM_USER=$HTTPD_USER +_PHP_FPM_GROUP=$HTTPD_GROUP + +echo "" +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo "Insert Path to MySQL Installation directory." +echo "" +echo "Type:" +echo -e "\t\033[33mSystem\033[m if installed from package system" +echo -e "\t\033[33mNot Installed\033[m if no MySQL installation is present" +echo "" +echo "" + +if [ -d "/usr/local/mysql/bin" ]; then + _MYSQL_INSTALL_DIR="/usr/local/mysql" +else + __mysql_bin="`which mysql`" + if [ -n "$__mysql_bin" ] ; then + _MYSQL_INSTALL_DIR="System" + else + _MYSQL_INSTALL_DIR="Not Installed" + fi +fi +MYSQL_INSTALL_DIR= +while [ "X$MYSQL_INSTALL_DIR" = "X" ] +do + echononl "MySQL Installation Directory [${_MYSQL_INSTALL_DIR}]: " + read MYSQL_INSTALL_DIR + if [ "X$MYSQL_INSTALL_DIR" = "X" ]; then + MYSQL_INSTALL_DIR=$_MYSQL_INSTALL_DIR + if [ -x "$_MYSQL_INSTALL_DIR/bin/mysql" ]; then + break + fi + fi + __to_lower=`echo $MYSQL_INSTALL_DIR | tr '[:upper:]' '[:lower:]' | tr -d ' '` + if [ "$__to_lower" = "system" ]; then + MYSQL_INSTALL_DIR="system" + break + fi + if [ "$__to_lower" = "notinstalled" ]; then + MYSQL_INSTALL_DIR="not_installed" + break + fi + if [ -x "$MYSQL_INSTALL_DIR/bin/mysql" ]; then + break + fi + echo "" + echo -e "\t\033[31mNo Mysql Instalation found at \"$MYSQL_INSTALL_DIR\" !! Try again..\033[m" + echo "" + MYSQL_INSTALL_DIR="" + +done + +echo "" +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo -e "Install php-$VERSION with apache module? [ \033[33myes/no\033[m ]" +echo "" +echo "" +OK="" +while [ "X$OK" = "X" ] +do + echononl "Install mod_apache ? [ $_APACHE_MOD_PHP ] " + read OK + __to_lower=`echo $OK | tr '[:upper:]' '[:lower:]' | tr -d ' '` + if [ "X$OK" = "X" ]; then + OK=$_APACHE_MOD_PHP + break + fi + if [ "$__to_lower" = "yes" -o "$__to_lower" = "no" ]; then + OK=$__to_lower + break + fi + echo "" + echo -e "\t\033[31mWrong entry !! Try again..\033[m" + echo "" + OK= +done +if [ "$OK" = "yes" ]; then + WITHOUT_APACHE_MOD_PHP=false + WITH_MOD_PHP=true +else + WITHOUT_APACHE_MOD_PHP=true + WITH_MOD_PHP=false +fi + + +if $WITH_MOD_PHP ; then + + echo "" + echo -e "\033[32m--\033[m" + echo "" + echo "Insert version numbers apache (httpd) apr and apr-util." + echo "" + echo "" + APACHE_VERSION= + while [ "X$APACHE_VERSION" = "X" ] + do + echononl "apache version [$_APACHE_VERSION]: " + read APACHE_VERSION + if [ "X$APACHE_VERSION" = "X" ]; then + APACHE_VERSION=$_APACHE_VERSION + fi + if [ ! -d /usr/local/httpd-${APACHE_VERSION}_php-${VERSION} ]; then + echo "" + echo -e "\t\033[31mApache Instalation found at \"/usr/local/httpd-${APACHE_VERSION}_php-${VERSION}\" !! Try again..\033[m" + echo "" + APACHE_VERSION= + fi + done + APACHE_BASEDIR=/usr/local/httpd-${APACHE_VERSION}_php-${VERSION} + APXS=${APACHE_BASEDIR}/bin/apxs + + PHP_VERSION_STRING="${VERSION}_httpd-${APACHE_VERSION}" + + PREFIX_PHP="/usr/local/php-${VERSION}_httpd-${APACHE_VERSION}" + PHP_INI_FILE="${APACHE_BASEDIR}/conf/php.ini" + _builddir=${_srcdir}/php-${VERSION}_http-${APACHE_VERSION} + _logdir=${_srcdir}/log_php-${VERSION}_http-${APACHE_VERSION}_build + +else + + PHP_VERSION_STRING="$VERSION" + + PREFIX_PHP=/usr/local/php-$VERSION + PHP_INI_FILE="${PREFIX_PHP}/etc/php.ini" + _builddir=${_srcdir}/php-${VERSION} + _logdir=${_srcdir}/log_php-${VERSION}_build + +fi + + +echo "" +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo -e "Define PHP parameters for php.ini file" +echo "" + +## - php.ini: memory_limit +if [ -f "/usr/local/php-${MAJOR_VERSION}/etc/php.ini" ]; then + __memory_limit=$(grep -e "^\s*memory_limit" /usr/local/php-${MAJOR_VERSION}/etc/php.ini | awk '{print$3}') + if [ -n "$__memory_limit" ] ; then + _MEMORY_LIMIT=$__memory_limit + fi +fi + +if [ -f "/usr/local/php-${MAJOR_VERSION}/etc/php.ini" ]; then + __memory_limit=$(grep -e "^\s*memory_limit" /usr/local/php-${MAJOR_VERSION}/etc/php.ini | awk '{print$3}') + if [ -n "$__memory_limit" ] ; then + __MEMORY_LIMIT=$__memory_limit + fi +fi + +MEMORY_LIMIT="" +echononl "memory_limit in Megabyte !! Append \"M\"? [$_MEMORY_LIMIT] " +read MEMORY_LIMIT +if [ "X$MEMORY_LIMIT" = "X" ]; then + MEMORY_LIMIT=$_MEMORY_LIMIT +fi + +## - php.ini: max_execution_time +if [ -f "/usr/local/php-${MAJOR_VERSION}/etc/php.ini" ]; then + __max_execution_time=$(grep -e "^\s*max_execution_time" /usr/local/php-${MAJOR_VERSION}/etc/php.ini | awk '{print$3}') + if [ -n "$__max_execution_time" ] ; then + _MAX_EXECUTION_TIME=$__max_execution_time + fi +fi + +MAX_EXECUTION_TIME="" +echononl "max_execution_time (in Seconds) !! insert ONLY the number? [$_MAX_EXECUTION_TIME] " +read MAX_EXECUTION_TIME +if [ "X$MAX_EXECUTION_TIME" = "X" ]; then + MAX_EXECUTION_TIME=$_MAX_EXECUTION_TIME +fi + +## - php.ini: upload_max_filesize +if [ -f "/usr/local/php-${MAJOR_VERSION}/etc/php.ini" ]; then + __upload_max_filesize=$(grep -e "^\s*upload_max_filesize" /usr/local/php-${MAJOR_VERSION}/etc/php.ini | awk '{print$3}') + if [ -n "$__upload_max_filesize" ] ; then + _UPLOAD_MAX_FILESIZE=$__upload_max_filesize + fi +fi + +UPLOAD_MAX_FILESIZE="" +echononl "upload_max_filesize in Megabyte !! Append \"M\"? [$_UPLOAD_MAX_FILESIZE] " +read UPLOAD_MAX_FILESIZE +if [ "X$UPLOAD_MAX_FILESIZE" = "X" ]; then + UPLOAD_MAX_FILESIZE=$_UPLOAD_MAX_FILESIZE +fi + +## - php.ini: post_max_size +if [ -f "/usr/local/php-${MAJOR_VERSION}/etc/php.ini" ]; then + __post_max_size=$(grep -e "^\s*post_max_size" /usr/local/php-${MAJOR_VERSION}/etc/php.ini | awk '{print$3}') + if [ -n "$__post_max_size" ] ; then + _POST_MAX_SIZE=$__post_max_size + fi +fi + +POST_MAX_SIZE="" +echononl "post_max_size in Megabyte !! Append \"M\"? [$_POST_MAX_SIZE] " +read POST_MAX_SIZE +if [ "X$POST_MAX_SIZE" = "X" ]; then + POST_MAX_SIZE=$_POST_MAX_SIZE +fi + + +echo "" +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo -e "Set Symlinks ? [ \033[33myes/no\033[m ]" +echo "" + +echo "" +if [ ! -h /usr/local/php ] ; then + SYMLINK_PHP=true + echo "Symlink /usr/local/php -> /usr/local/php-$MAJOR_VERSION will be set." +else + OK="" + while [ "X$OK" = "X" ] + do + echononl "Set symlink /usr/local/php -> /usr/local/php-$MAJOR_VERSION ? [ $_SYMLINK_PHP ]: " + read OK + __to_lower=`echo $OK | tr '[:upper:]' '[:lower:]' | tr -d ' '` + if [ "X$OK" = "X" ]; then + OK=$_SYMLINK_PHP + break + fi + if [ "$__to_lower" = "yes" -o "$__to_lower" = "no" ]; then + OK=$__to_lower + break + fi + echo "" + echo -e "\t\033[31mWrong entry !! Try again..\033[m" + echo "" + OK= + done + if [ "$OK" = "yes" ]; then + SYMLINK_PHP=true + else + SYMLINK_PHP=false + fi +fi + +echo "" +if [ ! -h /usr/local/php-${MAJOR_VERSION} ] ; then + SYMLINK_PHP_MAJOR_VERSION=true + echo "Symlink /usr/local/php-$MAJOR_VERSION -> `basename $PREFIX_PHP` will be set." +else + OK="" + while [ "X$OK" = "X" ]; do + echononl "Set symlink /usr/local/php-$MAJOR_VERSION -> `basename $PREFIX_PHP` ? [ $_SYMLINK_PHP_MAJOR_VERSION ]: " + read OK + __to_lower=`echo $OK | tr '[:upper:]' '[:lower:]' | tr -d ' '` + if [ "X$OK" = "X" ]; then + OK=$_SYMLINK_PHP_MAJOR_VERSION + break + fi + if [ "$__to_lower" = "yes" -o "$__to_lower" = "no" ]; then + OK=$__to_lower + break; + fi + echo "" + echo -e "\t\033[31mWrong entry !! Try again..\033[m" + echo "" + OK= + done + if [ "$OK" = "yes" ]; then + SYMLINK_PHP_MAJOR_VERSION=true + else + SYMLINK_PHP_MAJOR_VERSION=false + fi + +fi + + + +echo "" +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo -e "Install support of PHP-FPM (FastCGI Process Manager) [ \033[33myes/no\033[m ]" +echo "" +echo "" +OK="" +while [ "X$OK" = "X" ] +do + echononl "Install FPM support ? [ $_PHP_FPM_SUPPORT ] " + read OK + __to_lower=`echo $OK | tr '[:upper:]' '[:lower:]' | tr -d ' '` + if [ "X$OK" = "X" ]; then + OK=$_PHP_FPM_SUPPORT + break + fi + if [ "$__to_lower" = "yes" -o "$__to_lower" = "no" ]; then + OK=$__to_lower + break + fi + echo "" + echo -e "\t\033[31mWrong entry !! Try again..\033[m" + echo "" + OK= +done +if [ "$OK" = "yes" ]; then + WITH_PHP_FPM_SUPPORT=true + ACTIVATE_PHP_FPM_INIT_SCRIPT=true +else + WITH_PHP_FPM_SUPPORT=false + ACTIVATE_PHP_FPM_INIT_SCRIPT=false +fi + +if $WITH_PHP_FPM_SUPPORT ; then + echo "" + echo -e "\033[32m--\033[m" + echo "" + echo "" + OK="" + echononl "Set \"umask\" to \"0002\" for PHP-FPM process? [no]: " + read OK + while [ "X$OK" != "Xyes" -a "X$OK" != "XYes" -a "X$OK" != "Xno" -a "X$OK" != "XNo" -a "X$OK" != "X" ]; do + echononl "falsche Angabe! [no]: " + read OK + done + if [ "$OK" = "yes" -o "$OK" = "Yes" ]; then + SET_UMASK=true + UMASK=0002 + else + SET_UMASK=false + fi +fi + +if $WITH_PHP_FPM_SUPPORT && $WITH_MOD_PHP ; then + if [ -f "/etc/init.d/php-${VERSION}-fpm" ];then + echo "" + OK="" + while [ "X$OK" = "X" ]; do + echononl "Activate PHP-FPM from that installation ? [ no ] " + read OK + __to_lower=`echo $OK | tr '[:upper:]' '[:lower:]' | tr -d ' '` + if [ "X$OK" = "X" ]; then + OK="no" + break + fi + if [ "$__to_lower" = "yes" -o "$__to_lower" = "no" ]; then + OK=$__to_lower + break + fi + echo "" + echo -e "\t\033[31mWrong entry !! Try again..\033[m" + echo "" + OK= + done + if [ "$OK" = "yes" ]; then + ACTIVATE_PHP_FPM_INIT_SCRIPT=true + else + ACTIVATE_PHP_FPM_INIT_SCRIPT=false + fi + fi +fi + + +FPM_PID_FILE=/var/run/php-${MAJOR_VERSION}-fpm.pid + +FPM_LOG_DIR=/var/log/php-${MAJOR_VERSION}-fpm +FPM_ERROR_LOG=${FPM_LOG_DIR}/php-${MAJOR_VERSION}-fpm.log + +FPM_POOL_CONF_DIR=fpm.d +FPM_DEFAULT_POOL=www-${MAJOR_VERSION} + +FPM_DEFAULT_POOL_USER=$_PHP_FPM_USER +FPM_DEFAULT_POOL_GROUP=$_PHP_FPM_GROUP +FPM_DEFAULT_POOL_LISTEN=/tmp/php-${MAJOR_VERSION}-fpm.`echo ${FPM_DEFAULT_POOL} | cut -d'-' -f1`.sock +FPM_DEFAULT_POOL_LISTEN_OWNER=$_PHP_FPM_USER +FPM_DEFAULT_POOL_LISTEN_GROUP=$HTTPD_GROUP +FPM_DEFAULT_POOL_LISTEN_MODE=0660 + +FPM_DEFAULT_POOL_PM=dynamic +FPM_DEFAULT_POOL_MAX_CHILDREN=250 +FPM_DEFAULT_POOL_START_SERVER=5 +FPM_DEFAULT_POOL_MIN_SPARE=5 +FPM_DEFAULT_POOL_MAX_SPARE=10 + +FPM_DEFAULT_POOL_MAX_REQUESTS=500 + +FPM_DEFAULT_POOL_STATUS_PATH="/status-${MAJOR_VERSION}" +FPM_DEFAULT_POOL_PING_PATH="/ping-${MAJOR_VERSION}" +FPM_DEFAULT_POOL_PING_RESPONSE="pong" + +FPM_DEFAULT_POOL_ACCESS_LOG="${FPM_LOG_DIR}/${FPM_DEFAULT_POOL}-access.log" +FPM_DEFAULT_POOL_SLOW_LOG="${FPM_LOG_DIR}/${FPM_DEFAULT_POOL}-slow.log" +FPM_DEFAULT_POOL_ACCESS_FORMAT="\"%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%\"" + +FPM_DEFAULT_POOL_TERMINATE_TIMEOUT="`expr $MAX_EXECUTION_TIME + 1`s" + +FPM_ULIMIT_MAX_FILES=`su -c "ulimit -H -n" -s /bin/bash $_PHP_FPM_USER` + + +echo "" +echo "" +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo -e "\033[21G\033[32mStart PHP Installation with the following Parameters \033[m" +echo "" +echo "PHP version...................: $VERSION" +echo "PHP major version.............: $MAJOR_VERSION" +echo "" +echo "PHP configuration (php.ini)" +echo " memory_limit...............: $MEMORY_LIMIT" +echo " max_execution_time.........: $MAX_EXECUTION_TIME" +echo " upload_max_filesize........: $UPLOAD_MAX_FILESIZE" +echo " post_max_size..............: $POST_MAX_SIZE" +echo "" +echo "Apache User...................: $HTTPD_USER" +echo "Apache Group..................: $HTTPD_GROUP" +echo "" +echo "MySQL Installation directory..: $MYSQL_INSTALL_DIR" +echo "" +echo "Install with FPM support......: $WITH_PHP_FPM_SUPPORT" +if $WITH_PHP_FPM_SUPPORT && $WITH_MOD_PHP ; then + echo " Activate FPM init script...: $ACTIVATE_PHP_FPM_INIT_SCRIPT" +fi +if $WITH_PHP_FPM_SUPPORT ; then + echo " Set umask 0002 for FPM.....: $SET_UMASK" +fi +if $WITH_PHP_FPM_SUPPORT ; then + echo " FPM_DEFAULT_POOL_USER......: $FPM_DEFAULT_POOL_USER" + echo " FPM_DEFAULT_POOL_GROUP.....: $FPM_DEFAULT_POOL_GROUP" + echo " FPM_DEFAULT_POOL_LISTEN....: $FPM_DEFAULT_POOL_LISTEN" + echo " FPM_ULIMIT_MAX_FILES.......: $FPM_ULIMIT_MAX_FILES" +fi +echo "" +echo "Install with (apache) mod_php.: $WITH_MOD_PHP" +if $WITH_MOD_PHP ; then + echo " Apache Version.............: $APACHE_VERSION" +fi +echo "" +if $SYMLINK_PHP_MAJOR_VERSION -o $SYMLINK_PHP ; then + echo "Set symlniks:" + if $SYMLINK_PHP ; then + echo " /usr/local/php -> /usr/local/php-$MAJOR_VERSION" + fi + if $SYMLINK_PHP_MAJOR_VERSION ; then + echo " /usr/local/php-$MAJOR_VERSION -> `basename $PREFIX_PHP`" + fi +fi +echo "" +echononl "Start with that configuration? [yes/no]: " +read OK +while [ "X$OK" != "Xyes" -a "X$OK" != "XYes" -a "X$OK" != "XNo" -a "X$OK" != "Xno" ] +do + echononl "wrong entry! [yes/no] :" + read OK +done +[ $OK = "Yes" -o $OK = "yes" ] || fatal "Change parameters and restart script: `basename $0`" + +echo "" +echo "" + + +## -------------------------------------------------- + +if [ -d "$_logdir" ];then + mv $_logdir $_logdir.`date +%Y%m%d-%H%M` +fi +mkdir -p $_logdir > /dev/null 2>&1 +if [ -d "$_builddir" ];then + mv $_builddir $_builddir.`date +%Y%m%d-%H%M` +fi +if [ -d "$PREFIX_PHP" ];then + mv $PREFIX_PHP $PREFIX_PHP.`date +%Y%m%d-%H%M` +fi + + +echo "" +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo "Starting Installation of php-$VERSION..." +echo "" +echo "" + +## - get sources.. +## - +cd $_srcdir + +echononl "\tGet source php-$VERSION.tar.bz2.." +if [ ! -f ${_srcdir}/php-$VERSION.tar.bz2 ]; then + wget http://de.php.net/distributions/php-$VERSION.tar.bz2 >> ${_logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fatal "Cannot Download php-$VERSION.tar.bz2" + fi +else + echo_skipped +fi + + +bunzip2 < ${_srcdir}/php-$VERSION.tar.bz2 | tar -xf - || exit 1 +chown -R root.root php-$VERSION || exit 1 +if ! $WITHOUT_APACHE_MOD_PHP ; then + mv php-$VERSION $_builddir +fi +cd $_builddir || exit 1 + +echo -e "\n\tgoing to configure.." +echo -e "\t(see ${_logdir}/php-configure.log for more details)" + + +## - if you get the following error: +## - +## - configure: error: libXpm.(a|so) not found +## - +## - set a symlink /usr/lib/libXpm.a --> /usr/lib/x86_64-linux-gnu/libXpm.a +## - +if [ ! -h "/usr/lib/libXpm.a" -a ! -f "/usr/lib/libXpm.a" ];then + ln -s x86_64-linux-gnu/libXpm.a /usr/lib/libXpm.a +fi +if [ ! -h "/usr/lib/libjpeg.a" -a ! -f "/usr/lib/libjpeg.a" ];then + ln -s x86_64-linux-gnu/libjpeg.a /usr/lib/libjpeg.a +fi +if [ ! -h "/usr/lib/libXpm.a" -a ! -f "/usr/lib/libXpm.a" ];then + ln -s x86_64-linux-gnu/libpng.a /usr/lib/libpng.a +fi + + +# : ${_arch:=i686} +# : ${_arch:=athlon} +: ${_arch:=k8} ## --> x86-64 instructionset + +##_cflags="-O2 -march=$_arch " + +## - LDFLAGS="-s" --> Remove all symbol table and relocation information from the executable. +## F77="/usr/bin/g77-3.4" \ +## CXXCPP="/usr/bin/g++-3.4 -E" \ +## CC="/usr/bin/gcc-3.4" \ +## CXX="/usr/bin/g++-3.4" \ +## CPP="/usr/bin/cpp-3.4" \ +## CFLAGS="$_cflags" LDFLAGS="-s" \ +config_params=" + --prefix=$PREFIX_PHP \ + --with-gd \ + --with-pgsql \ + --with-pdo-pgsql \ + --with-regex=system \ + --enable-wddx \ + --enable-exif \ + --with-zlib \ + --with-openssl \ + --with-gdbm \ + --with-jpeg-dir \ + --with-png-dir \ + --with-curl \ + --enable-dba \ + --with-mcrypt \ + --with-xpm-dir \ + --with-vpx-dir \ + --with-freetype-dir \ + --enable-ftp \ + --with-readline \ + --enable-sockets \ + --with-imap \ + --with-imap-ssl \ + --with-kerberos \ + --with-gettext \ + --with-pspell \ + --enable-soap \ + --enable-mbstring \ + --enable-zip \ + --enable-calendar \ + --enable-bcmath \ + --with-bz2 \ + --enable-intl \ + --enable-shmop \ + --enable-sysvmsg \ + --enable-sysvsem \ + --enable-sysvshm \ + --with-ldap=shared \ + --with-xsl \ + --enable-cgi" + +## - t1lib-dev (libt1-dev) not available in debian 8.0 (jessie) +## - +if [ -f "/etc/debian_version" ]; then + DEBIAN_MAJOR_VERSION=`cat /etc/debian_version | cut -d '.' -f1` + if [ $DEBIAN_MAJOR_VERSION -lt 8 ] ; then + config_params="$config_params \ + --with-t1lib" + fi +fi + +if [ "$MYSQL_INSTALL_DIR" != "not_installed" ]; then + if [ "$MYSQL_INSTALL_DIR" = "system" ];then + if [ -f "/etc/mysql/my.cnf" ]; then + _mysql_socket="`cat /etc/mysql/my.cnf | grep -E \"^\s*socket\" | head -1 | awk '{print$3}'`" + if [ -S "$_mysql_socket" ]; then + config_params="$config_params \ + --with-mysql \ + --with-pdo-mysql \ + --with-mysql-sock" + else + config_params="$config_params \ + --with-mysql \ + --with-pdo-mysql " + fi + else + config_params="$config_params \ + --with-mysql \ + --with-pdo-mysql " + fi + else + config_params="$config_params \ + --with-mysql=$MYSQL_INSTALL_DIR \ + --with-pdo-mysql=$MYSQL_INSTALL_DIR \ + --with-mysql-sock" + fi +fi + + ## - mysqli failed to compile with MySQL v 5.7.x + ## - + #--with-mysqli \ + #--with-mysqli=${MYSQL_INSTALL_DIR}/bin/mysql_config \ + +if $WITHOUT_APACHE_MOD_PHP ; then + config_params="$config_params --without-apxs2 --without-apxs --with-config-file-path=${PREFIX_PHP}/etc" +else + config_params="$config_params --with-apxs2=$APXS --with-config-file-path=${APACHE_BASEDIR}/conf" +fi + +if $WITH_PHP_FPM_SUPPORT ; then + config_params="$config_params --enable-fpm" +fi + +echo "LDFLAGS=\"-s\" ./configure $config_params" > ${_logdir}/php-configure.log +LDFLAGS="-s" ./configure $config_params >> ${_logdir}/php-configure.log 2>&1 || exit 1 + + +## --with-mm \ # does not work with apache v2.4 + +## --with-pgsql=/usr/local/pgsql \ + +## --with-mysql=/usr/local/mysql \ +## --with-mysqli=/usr/local/mysql/bin/mysql_config \ +## --with-pdo-mysql=/usr/local/mysql \ +## --with-mysql-sock \ + +## --with-mysql \ +## --with-mysqli \ +## --with-pdo-mysql \ +## --with-mysql-sock \ + +## --enable-force-cgi-redirect \ +## --enable-track-vars \ +## --with-tiff-dir \ +## --with-ttf \ +## --with-memcache \ +## --with-xml \ + +echo -e "\n\tgoing to compile.." +echo -e "\t(see ${_logdir}/php-make.log for more details)" +make > ${_logdir}/php-make.log 2>&1 || exit 1 + +echo -e "\n\tgoing to install.." +echo -e "\t(see ${_logdir}/php-make_install.log for more details)" +make install > ${_logdir}/php-make_install.log 2>&1 || exit 1 + + +#cp php.ini-production $PHP_INI_FILE || exit 1 +[ -f $PHP_INI_FILE ] && cp -a $PHP_INI_FILE ${PHP_INI_FILE}-`date +"%Y-%m-%d-%H%M"` +cp php.ini-production $PHP_INI_FILE || exit 1 + + +if ! $WITHOUT_APACHE_MOD_PHP ; then + _set_php_entries="" + echo "" + echo -n "do you want to set \"LoadModule\" entries in httpd.conf ? [y/n]: " + read _set_php_entries + if [ "y" = "$_set_php_entries" -o "Y" = "$_set_php_entries" -o "Yes" = "$_set_php_entries" -o "yes" = "$_set_php_entries" ];then + sed -i -r \ + -e "s&(^\s*LoadModule php5_module.*$)&\1\n#\n AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml\n AddType application/x-httpd-php-source .phps\n#&" ${APACHE_BASEDIR}/conf/httpd.conf + #-e "s&(^\s*LoadModule php5_module.*$)&\1\n\n AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml\n AddType application/x-httpd-php-source .phps\n&" ${APACHE_BASEDIR}/conf/httpd.conf + fi +fi + +echo "" +echo "" +echo -e "\t---" +echo -e "\t--- post installation tasks" +echo -e "\t---" + +if $SYMLINK_PHP ; then + echononl "\tSet symlink /usr/local/php -> /usr/local/php-$MAJOR_VERSION" + if [ -L /usr/local/php ];then + rm -f /usr/local/php + fi + ln -s `basename $PREFIX_PHP` /usr/local/php + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi +fi + +if $SYMLINK_PHP_MAJOR_VERSION ; then + echononl "\tSet symlink /usr/local/php-$MAJOR_VERSION -> `basename $PREFIX_PHP`" + if [ -h /usr/local/php-${MAJOR_VERSION} ] ; then + rm -f /usr/local/php-${MAJOR_VERSION} + fi + ln -s `basename $PREFIX_PHP` /usr/local/php-$MAJOR_VERSION + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi +fi + + +## - special for debian. set manpath entries +## - +if [ -f /etc/manpath.config ];then + if ! grep /usr/local/php/man /etc/manpath.config > /dev/null 2<&1 ; then + echo >> /etc/manpath.config + echo "MANDATORY_MANPATH /usr/local/php/php/man /var/cache/man" >> /etc/manpath.config + echo "MANPATH_MAP /usr/local/php/bin /usr/local/php/php/man" >> /etc/manpath.config + echo "MANDB_MAP /usr/local/php/php/man /var/cache/man" >> /etc/manpath.config + fi +elif [ -f /etc/man.conf];then + if ! grep /opt/php/man /etc/man.conf > /dev/null 2<&1 ; then + echo >> /etc/man.conf + echo "MANPATH /opt/php/man /var/cache/man" >> /etc/man.conf + echo "MANPATH_MAP /opt/php/bin /opt/php/man" >> /etc/man.conf + fi +fi + + +## - Add /usr/local/php/bin to the systems PATH variable +## - +echo "" +echononl "\tAdd `dirname $PREFIX_PHP`/php/bin to the systems PATH variable" +_checkdir=`dirname $PREFIX_PHP`/php/bin +if [ -f /etc/profile ]; then + if ! grep -e "$_checkdir" /etc/profile > /dev/null 2<&1 ; then + perl -i -n -p -e "s#^([ ]*export[ ]*PATH.*$)#check_dir=$_checkdir\nif [ -d \"\\\$check_dir\" ];then\n PATH=\\\${check_dir}:\\\$PATH\nfi\n\n\1#" /etc/profile > /dev/null 2<&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + if ! echo "$PATH" | grep $_checkdir > /dev/null 2>&1 ; then + export PATH=${_checkdir}:$PATH + fi + + else + echo_skipped + fi +fi + + +## - PHP FPM +## - +echo "" +echo "" +echo -e "\t---" +echo -e "\t--- Install support for PHP-FPM" +echo -e "\t---" +echo "" + +if $WITH_PHP_FPM_SUPPORT ; then + + echononl "\tBackup existsing init script /etc/init.d/php-${PHP_VERSION_STRING}-fpm" + if [ -f "/etc/init.d/php-${PHP_VERSION_STRING}-fpm" ]; then + mv /etc/init.d/php-${PHP_VERSION_STRING}-fpm /etc/init.d/php-${PHP_VERSION_STRING}-fpm.`date +%Y%m%d-%H%M` > /dev/null 2<&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + else + echo_skipped + fi + + echononl "\tAdd init script /etc/init.d/php-${PHP_VERSION_STRING}-fpm" + cp ${_builddir}/sapi/fpm/init.d.php-fpm /etc/init.d/php-${PHP_VERSION_STRING}-fpm > /dev/null 2<&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + echononl "\tSet \"umask 0002\" for FPM Processes .." + if $SET_UMASK ; then + sed -i "1 s/\(.*\)/\1\n\numask 0002\n/" /etc/init.d/php-${PHP_VERSION_STRING}-fpm > /dev/null 2<&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + else + echo_skipped + fi + + echononl "\tMake init script executable" + chmod 755 /etc/init.d/php-${PHP_VERSION_STRING}-fpm + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + if [ ! -h /etc/init.d/php-${MAJOR_VERSION}-fpm ]; then + echononl "\tSet Symlink /etc/init.d/php-${MAJOR_VERSION}-fpm --> /etc/init.d/php-${PHP_VERSION_STRING}-fpm" + ln -s /etc/init.d/php-${VERSION}-fpm /etc/init.d/php-${MAJOR_VERSION}-fpm > /dev/null 2<&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + else + if $ACTIVATE_PHP_FPM_INIT_SCRIPT ; then + echononl "\tSet Symlink /etc/init.d/php-${MAJOR_VERSION}-fpm --> /etc/init.d/php-${PHP_VERSION_STRING}-fpm" + rm -f /etc/init.d/php-${MAJOR_VERSION}-fpm + ln -s /etc/init.d/php-${VERSION}-fpm /etc/init.d/php-${MAJOR_VERSION}-fpm > /dev/null 2<&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + fi + fi + + echononl "\tMake php-${MAJOR_VERSION}-fpm start at boottime" + if ! grep -e "/etc/init.d/php-${MAJOR_VERSION}-fpm" /etc/rc.local > /dev/null 2>&1 ; then + sed -i -r -e "s#^([[:space:]]*exit\ +.*)#sleep 2\n/etc/init.d/php-${MAJOR_VERSION}-fpm restart > /dev/null || /bin/true\n\n\1#" /etc/rc.local + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + else + echo_skipped + fi + + _failed=false + echononl "\tAdjust /etc/init.d/php-${PHP_VERSION_STRING}-fpm" + sed -i -r -e "s&^(([ ^t]*php_fpm_PID=).*)$&## \1\n\2${FPM_PID_FILE}&g" /etc/init.d/php-${PHP_VERSION_STRING}-fpm || _failed=true + sed -i -r -e "s&^(#\ .+)php-fpm&\1php-${MAJOR_VERSION}-fpm&" /etc/init.d/php-${PHP_VERSION_STRING}-fpm || _failed=true + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + + echononl "\tCreate php-fpm global configuration file" + cat < ${PREFIX_PHP}/etc/php-fpm.conf +;;;;;;;;;;;;;;;;;;;;; +; FPM Configuration ; +;;;;;;;;;;;;;;;;;;;;; + +; All relative paths in this configuration file are relative to PHP's install +; prefix (/usr/local/php-5.4.35). This prefix can be dynamically changed by using the +; '-p' argument from the command line. + +; Include one or more files. If glob(3) exists, it is used to include a bunch of +; files from a glob(3) pattern. This directive can be used everywhere in the +; file. +; Relative path can also be used. They will be prefixed by: +; - the global prefix if it's been set (-p argument) +; - /usr/local/php-5.4.35 otherwise +;include=etc/fpm.d/*.conf + +;;;;;;;;;;;;;;;;;; +; Global Options ; +;;;;;;;;;;;;;;;;;; + +[global] +; Pid file +; Note: the default prefix is /usr/local/php-5.4.35/var +; Default Value: none +pid = $FPM_PID_FILE + +; Set open file descriptor rlimit for the master process. +; Default Value: system defined value +;rlimit_files = 1024 +rlimit_files = $FPM_ULIMIT_MAX_FILES + +; Error log file +; If it's set to "syslog", log is sent to syslogd instead of being written +; in a local file. +; Note: the default prefix is /usr/local/php-5.4.35/var +; Default Value: log/php-fpm.log +error_log = $FPM_ERROR_LOG + +include=etc/${FPM_POOL_CONF_DIR}/*.conf +EOF + + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + echononl "\tCreate Configuration Directory \"${FPM_POOL_CONF_DIR}\"" + mkdir -p ${PREFIX_PHP}/etc/$FPM_POOL_CONF_DIR + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + echononl "\tCreate php-fpm configuration file for pool \"${FPM_DEFAULT_POOL}\"" + cat < ${PREFIX_PHP}/etc/${FPM_POOL_CONF_DIR}/${FPM_DEFAULT_POOL}.php-fpm.conf +;;;;;;;;;;;;;;;;;;;; +; Pool Definitions ; +;;;;;;;;;;;;;;;;;;;; + +; Multiple pools of child processes may be started with different listening +; ports and different management options. The name of the pool will be +; used in logs and stats. There is no limitation on the number of pools which +; FPM can handle. Your system will tell you anyway :) + +; Start a new pool named '$FPM_DEFAULT_POOL'. +; the variable \$pool can we used in any directive and will be replaced by the +; pool name ('$FPM_DEFAULT_POOL' here) +[$FPM_DEFAULT_POOL] + +; Unix user/group of processes +; Note: The user is mandatory. If the group is not set, the default user's group +; will be used. +user = $FPM_DEFAULT_POOL_USER +group = $FPM_DEFAULT_POOL_GROUP + +; The address on which to accept FastCGI requests. +; Valid syntaxes are: +; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on +; a specific port; +; 'port' - to listen on a TCP socket to all addresses on a +; specific port; +; '/path/to/unix/socket' - to listen on a unix socket. +; Note: This value is mandatory. +listen = $FPM_DEFAULT_POOL_LISTEN + +; Set permissions for unix socket, if one is used. In Linux, read/write +; permissions must be set in order to allow connections from a web server. Many +; BSD-derived systems allow connections regardless of permissions. +; Default Values: user and group are set as the running user +; mode is set to 0660 +listen.owner = $FPM_DEFAULT_POOL_LISTEN_OWNER +listen.group = $FPM_DEFAULT_POOL_LISTEN_GROUP +listen.mode = $FPM_DEFAULT_POOL_LISTEN_MODE + +; Choose how the process manager will control the number of child processes. +; Possible Values: +; static - a fixed number (pm.max_children) of child processes; +; dynamic - the number of child processes are set dynamically based on the +; following directives. With this process management, there will be +; always at least 1 children. +; pm.max_children - the maximum number of children that can +; be alive at the same time. +; pm.start_servers - the number of children created on startup. +; pm.min_spare_servers - the minimum number of children in 'idle' +; state (waiting to process). If the number +; of 'idle' processes is less than this +; number then some children will be created. +; pm.max_spare_servers - the maximum number of children in 'idle' +; state (waiting to process). If the number +; of 'idle' processes is greater than this +; number then some children will be killed. +; ondemand - no children are created at startup. Children will be forked when +; new requests will connect. The following parameter are used: +; pm.max_children - the maximum number of children that +; can be alive at the same time. +; pm.process_idle_timeout - The number of seconds after which +; an idle process will be killed. +; Note: This value is mandatory. +pm = $FPM_DEFAULT_POOL_PM + +; The number of child processes to be created when pm is set to 'static' and the +; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. +; This value sets the limit on the number of simultaneous requests that will be +; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. +; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP +; CGI. The below defaults are based on a server without much resources. Don't +; forget to tweak pm.* to fit your needs. +; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' +; Note: This value is mandatory. +pm.max_children = $FPM_DEFAULT_POOL_MAX_CHILDREN + +; The number of child processes created on startup. +; Note: Used only when pm is set to 'dynamic' +; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 +pm.start_servers = $FPM_DEFAULT_POOL_START_SERVER + +; The desired minimum number of idle server processes. +; Note: Used only when pm is set to 'dynamic' +; Note: Mandatory when pm is set to 'dynamic' +pm.min_spare_servers = $FPM_DEFAULT_POOL_MIN_SPARE + +; The desired maximum number of idle server processes. +; Note: Used only when pm is set to 'dynamic' +; Note: Mandatory when pm is set to 'dynamic' +pm.max_spare_servers = $FPM_DEFAULT_POOL_MAX_SPARE + +; The number of requests each child process should execute before respawning. +; This can be useful to work around memory leaks in 3rd party libraries. For +; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. +; Default Value: 0 +pm.max_requests = $FPM_DEFAULT_POOL_MAX_REQUESTS + +; The URI to view the FPM status page. If this value is not set, no URI will be +; recognized as a status page. It shows the following informations: +; pool - the name of the pool; +; process manager - static, dynamic or ondemand; +; start time - the date and time FPM has started; +; start since - number of seconds since FPM has started; +; accepted conn - the number of request accepted by the pool; +; listen queue - the number of request in the queue of pending +; connections (see backlog in listen(2)); +; max listen queue - the maximum number of requests in the queue +; of pending connections since FPM has started; +; listen queue len - the size of the socket queue of pending connections; +; idle processes - the number of idle processes; +; active processes - the number of active processes; + + +; total processes - the number of idle + active processes; +; max active processes - the maximum number of active processes since FPM +; has started; +; max children reached - number of times, the process limit has been reached, +; when pm tries to start more children (works only for +; pm 'dynamic' and 'ondemand'); +; Value are updated in real time. +; Example output: +; pool: www +; process manager: static +; start time: 01/Jul/2011:17:53:49 +0200 +; start since: 62636 +; accepted conn: 190460 +; listen queue: 0 +; max listen queue: 1 +; listen queue len: 42 +; idle processes: 4 +; active processes: 11 +; total processes: 15 +; max active processes: 12 +; max children reached: 0 +; +; By default the status page output is formatted as text/plain. Passing either +; 'html', 'xml' or 'json' in the query string will return the corresponding +; output syntax. Example: +; http://www.foo.bar/status +; http://www.foo.bar/status?json +; http://www.foo.bar/status?html +; http://www.foo.bar/status?xml +; +; By default the status page only outputs short status. Passing 'full' in the +; query string will also return status for each pool process. +; Example: +; http://www.foo.bar/status?full +; http://www.foo.bar/status?json&full +; http://www.foo.bar/status?html&full +; http://www.foo.bar/status?xml&full +; The Full status returns for each process: +; pid - the PID of the process; +; state - the state of the process (Idle, Running, ...); +; start time - the date and time the process has started; +; start since - the number of seconds since the process has started; +; requests - the number of requests the process has served; +; request duration - the duration in µs of the requests; +; request method - the request method (GET, POST, ...); +; request URI - the request URI with the query string; +; content length - the content length of the request (only with POST); +; user - the user (PHP_AUTH_USER) (or '-' if not set); +; script - the main script called (or '-' if not set); +; last request cpu - the %cpu the last request consumed +; it's always 0 if the process is not in Idle state +; because CPU calculation is done when the request +; processing has terminated; +; last request memory - the max amount of memory the last request consumed +; it's always 0 if the process is not in Idle state +; because memory calculation is done when the request +; processing has terminated; +; If the process is in Idle state, then informations are related to the +; last request the process has served. Otherwise informations are related to +; the current request being served. +; Example output: +; ************************ +; pid: 31330 +; state: Running +; start time: 01/Jul/2011:17:53:49 +0200 +; start since: 63087 +; requests: 12808 +; request duration: 1250261 +; request method: GET +; request URI: /test_mem.php?N=10000 +; content length: 0 +; user: - +; script: /home/fat/web/docs/php/test_mem.php +; last request cpu: 0.00 +; last request memory: 0 +; +; Note: There is a real-time FPM status monitoring sample web page available +; It's available in: ${prefix}/share/fpm/status.html +; +; Note: The value must start with a leading slash (/). The value can be +; anything, but it may not be a good idea to use the .php extension or it +; may conflict with a real PHP file. +; Default Value: not set +pm.status_path = $FPM_DEFAULT_POOL_STATUS_PATH + +; The ping URI to call the monitoring page of FPM. If this value is not set, no +; URI will be recognized as a ping page. This could be used to test from outside +; that FPM is alive and responding, or to +; - create a graph of FPM availability (rrd or such); +; - remove a server from a group if it is not responding (load balancing); +; - trigger alerts for the operating team (24/7). +; Note: The value must start with a leading slash (/). The value can be +; anything, but it may not be a good idea to use the .php extension or it +; may conflict with a real PHP file. +; Default Value: not set +ping.path = $FPM_DEFAULT_POOL_PING_PATH + +; This directive may be used to customize the response of a ping request. The +; response is formatted as text/plain with a 200 response code. +; Default Value: pong +ping.response = $FPM_DEFAULT_POOL_PING_RESPONSE + +; The access log file +; Default: not set +access.log = $FPM_DEFAULT_POOL_ACCESS_LOG +; The access log format. +; The following syntax is allowed +; %%: the '%' character +; %C: %CPU used by the request +; it can accept the following format: +; - %{user}C for user CPU only +; - %{system}C for system CPU only +; - %{total}C for user + system CPU (default) +; %d: time taken to serve the request +; it can accept the following format: +; - %{seconds}d (default) +; - %{miliseconds}d +; - %{mili}d +; - %{microseconds}d +; - %{micro}d +; %e: an environment variable (same as $_ENV or $_SERVER) +; it must be associated with embraces to specify the name of the env +; variable. Some exemples: +; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e +; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e +; %f: script filename +; %l: content-length of the request (for POST request only) +; %m: request method +; %M: peak of memory allocated by PHP +; it can accept the following format: +; - %{bytes}M (default) +; - %{kilobytes}M +; - %{kilo}M +; - %{megabytes}M +; - %{mega}M +; %n: pool name +; %o: output header +; it must be associated with embraces to specify the name of the header: +; - %{Content-Type}o +; - %{X-Powered-By}o +; - %{Transfert-Encoding}o +; - .... +; %p: PID of the child that serviced the request +; %P: PID of the parent of the child that serviced the request +; %q: the query string +; %Q: the '?' character if query string exists +; %r: the request URI (without the query string, see %q and %Q) +; %R: remote IP address +; %s: status (response code) +; %t: server time the request was received +; it can accept a strftime(3) format: +; %d/%b/%Y:%H:%M:%S %z (default) +; %T: time the log has been written (the request has finished) +; it can accept a strftime(3) format: +; %d/%b/%Y:%H:%M:%S %z (default) +; %u: remote user +; +; Default: "%R - %u %t \"%m %r\" %s" +;access.format = $FPM_DEFAULT_POOL_ACCESS_FORMAT + +; The log file for slow requests +; Default Value: not set +; Note: slowlog is mandatory if request_slowlog_timeout is set +slowlog = $FPM_DEFAULT_POOL_SLOW_LOG + +; The timeout for serving a single request after which the worker process will +; be killed. This option should be used when the 'max_execution_time' ini option +; does not stop script execution for some reason. A value of '0' means 'off'. +; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) +; Default Value: 0 +request_terminate_timeout = $FPM_DEFAULT_POOL_TERMINATE_TIMEOUT + +EOF + + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + if [ "$_HTTPD_USER" != $FPM_DEFAULT_POOL_LISTEN_OWNER ]; then + echononl "\tAdd apache user to group \"$FPM_DEFAULT_POOL_LISTEN_GROUP\"" + usermod -a -G $FPM_DEFAULT_POOL_LISTEN_GROUP $_HTTPD_USER + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + fi + + echononl "\tCreate log directory for PHP-FPM \"${FPM_LOG_DIR}\"" + mkdir -p $FPM_LOG_DIR + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + echononl "\tConfigure logrotation for \"${FPM_LOG_DIR}\"" + if [ ! -f "/etc/logrotate.d/php-${MAJOR_VERSION}-fpm" ]; then + cat < /etc/logrotate.d/php-${MAJOR_VERSION}-fpm +$FPM_LOG_DIR/*log { + daily + rotate 7 + start 0 + compress + delaycompress + missingok + notifempty +} +EOF + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + else + echo_skipped + fi + +fi + + + +## - PHP Extensions +## - +echo "" +echo "" +echo -e "\t---" +echo -e "\t--- Install PHP PECL extensions" +echo -e "\t---" +echo "" + + +## ----- +## - Install geoip +## ----- + +echononl "\tInstalling libgeoip1 libgeoip-dev geoip-bin .." +if ! dpkg -l libgeoip-dev | grep -e "^ii" | grep libgeoip-dev > /dev/null 2>&1 ; then + apt-get -q -y install libgeoip1 libgeoip-dev geoip-bin > /dev/null 2>&1 + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + fi +else + echo_skipped +fi + +echononl "\tInstall geoip via pecl.." +${PREFIX_PHP}/bin/pecl install geoip > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tphp.ini: extension=geoip.so .." +_extension="geoip.so" +perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\n#" $PHP_INI_FILE +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +## ----- +## - END: Install geoip +## ----- + + +## ----- +## - Install APC +## ----- + +echononl "\tInstall APC via pecl.." +printf "\n" | ${PREFIX_PHP}/bin/pecl install apc > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tphp.ini: extension=APC .." +_extension="apc.so" +perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\n#" $PHP_INI_FILE +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## ----- +## - END: Install APC +## ----- + + +## ----- +## - Install uploadprogress +## ----- + +echononl "\tInstall uploadprogress via pecl.." +printf "\n" | ${PREFIX_PHP}/bin/pecl install uploadprogress > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tphp.ini: extension=uploadprogress .." +_extension="uploadprogress.so" +perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\n#" $PHP_INI_FILE +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## ----- +## - END: Install uploadprogress +## ----- + + +## ----- +## - Install solr +## ----- + +echononl "\tInstall solr via pecl.." +printf "\n" | ${PREFIX_PHP}/bin/pecl install solr > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tphp.ini: extension=solr .." +_extension="solr.so" +perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\n#" $PHP_INI_FILE +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +## ----- +## - END: Install solr +## ----- + + + +## ----- +## - Install imagick +## ----- + +echononl "\tInstalling libmagickcore-dev libmagickwand-dev .." +_install="" +if ! dpkg -l libmagickwand-dev 2>/dev/null | grep -e "^ii" | grep libmagickwand-dev > /dev/null 2>&1 ; then + _install="libmagickwand-dev" +fi +if ! dpkg -l libmagickcore-dev 2>/dev/null | grep -e "^ii" | grep libmagickcore-dev > /dev/null 2>&1 ; then + _install="$_install libmagickcore-dev" +fi +if [ -n "$_install" ];then + apt-get -q -y install libmagickcore-dev libmagickwand-dev > /dev/null 2>&1 + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + fi +else + echo_skipped +fi + +_MagickWand_config=`which MagickWand-config` +if [ -z "$_MagickWand_config" ]; then + + echononl "\tUpdate file name database (updatedb).." + updatedb > /dev/null 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + _MagickWand_config=`locate MagickWand-config | grep -e "/MagickWand-config$" | head -n 1` + if [ -n "$_MagickWand_config" ]; then + echononl "\tSymlink /usr/bin/MagickWand-config --> $_MagickWand_config" + ln -s /usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16/MagickWand-config /usr/bin/ + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + else + warn "Cannot find \"MagickWand_config\" - but is needed for \"imagick\"." + + fi +fi + +echononl "\tInstall imagick via pecl.." +printf "\n" | ${PREFIX_PHP}/bin/pecl install imagick > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tphp.ini: extension=imagick.so .." +_extension="imagick.so" +perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\n#" $PHP_INI_FILE +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +## ----- +## - END: Install imagick +## ----- + + +## ----- +## - Install xdebug +## ----- + +echononl "\tInstall xdebug via pecl.." +printf "\n" | ${PREFIX_PHP}/bin/pecl install xdebug > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +if $WITHOUT_APACHE_MOD_PHP ; then + zend_extension_xdebug=`find /usr/local/php-${MAJOR_VERSION}/lib/php/extensions -name xdebug.so -print` +else + #zend_extension_xdebug=`locate xdebug.so | grep ${PREFIX_PHP}/lib/php/extensions` + zend_extension_xdebug=`find ${PREFIX_PHP}/lib/php/extensions -name xdebug.so -print` +fi + + +echononl "\tphp.ini: zend_extension = \"/abs/path/to/xdebug.so\" .." +perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nzend_extension = $zend_extension_xdebug\n#" $PHP_INI_FILE +#sed -i "s/^/\nzend_extension = ${zend_extension_xdebug}\n\n/" $PHP_INI_FILE +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + + +#echononl "\tphp.ini: extension=xdebug .." +#_extension="xdebug" +#perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\n#" $PHP_INI_FILE +#if [ "$?" = "0" ]; then +# echo_ok +#else +# echo_failed +#fi + +## ----- +## - END: Install xdebug +## ----- + + +## ----- +## - Enable ldap.so +## ----- + +echononl "\tphp.ini: extension=ldap .." +_extension="ldap.so" +perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\n#" $PHP_INI_FILE +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +## ----- +## - END: Enable ldap.so +## ----- + + + +echo "" +echo "" +echo -e "\t---" +echo -e "\t--- Install PHP PEAR extensions" +echo -e "\t---" +echo "" + +echononl "\tInstall Mail via pear.." +${PREFIX_PHP}/bin/pear install Mail > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tInstall Mail_Mime via pear.." +${PREFIX_PHP}/bin/pear install Mail_Mime > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tInstall Net_Socket via pear.." +${PREFIX_PHP}/bin/pear install Net_Socket > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tInstall Net_SMTP via pear.." +${PREFIX_PHP}/bin/pear install Net_SMTP > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + + + +## - Configure php.ini (base) +## - +echo "" +echo "" +echo -e "\t---" +echo -e "\t--- Configure php.ini (base)" +echo -e "\t---" +echo "" + +## - set date.timezon = "Europe/Berlin" +## - +echononl "\tphp.ini: date.timezone = \"Europe/Berlin\"" +_key="date.timezone" +_val="Europe/Berlin" +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + +## - set short_open_tag = On +## - +echononl "\tphp.ini: short_open_tag = On" +_key="short_open_tag" +_val="Off" +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## - set memory_limit = $MEMORY_LIMIT +## - +echononl "\tphp.ini: memory_limit = $MEMORY_LIMIT" +_key="memory_limit" +_val=$MEMORY_LIMIT +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## - set max_execution_time = $MAX_EXECUTION_TIME +## - +echononl "\tphp.ini: max_execution_time = $MAX_EXECUTION_TIME" +_key="max_execution_time" +_val=$MAX_EXECUTION_TIME +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## - set error_log = /var/log/apache2/php_errors.log +## - +echononl "\tphp.ini: error_log = /var/log/apache2/php_errors.log" +_key="error_log" +_val="/var/log/apache2/php_errors.log" +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi +touch $_val +chown ${HTTPD_USER}:$HTTPD_GROUP $_val + + +## - set upload_max_filesize = 16M +## - +echononl "\tphp.ini: upload_max_filesize = $UPLOAD_MAX_FILESIZE" +_key="upload_max_filesize" +_val="$UPLOAD_MAX_FILESIZE" +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## - set post_max_size = $POST_MAX_SIZE +## - +echononl "\tphp.ini: post_max_size = 128M" +_key="post_max_size" +_val="$POST_MAX_SIZE" +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## - set max_file_uploads = 50 +## - +echononl "\tphp.ini: max_file_uploads = 50" +_key="max_file_uploads" +_val=50 +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + +## ----- +## - END: Configure php.ini (base) +## ----- + + + + +cd $pwd + +cat<) +## - +#export MAKEFLAGS=-j$(expr `grep "^processor" /proc/cpuinfo | sort -u | wc -l` + 1) + +## --- Some functions +## --- +echononl(){ + echo X\\c > /tmp/shprompt$$ + if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then + echo -e -n "$*\\c" 1>&2 + else + echo -e -n "$*" 1>&2 + fi + rm /tmp/shprompt$$ +} + +fatal(){ + echo "" + echo -e "Fehler: $*" + echo "" + echo -e "\t\033[31m\033[1mInstalllation wird abgebrochen\033[m\033[m" + echo "" + exit 1 +} + +warn (){ + echo "" + echo -e "\t[ \033[33m\033[1mWarning\033[m ]: $*" + echo "" +} + + +echo_ok() { + echo -e "\033[75G[ \033[1;32mok\033[m ]" + ## echo -e " [ ok ]" +} +echo_failed(){ + echo -e "\033[75G[ \033[1;31mfailed\033[m ]" + ## echo -e " [ failed ]" +} +echo_skipped() { + echo -e "\033[75G[ \033[33m\033[1mskipped\033[m ]" +} +## --- +## --- END: functions + + +## -------------------------------------------------- + +clear +echo +echo -e "\033[21G\033[32mInstallation PHP \033[m" +echo +echo +echo + +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo "Insert PHP version number." +echo "" +echo "" +VERSION= +while [ "X$VERSION" = "X" ] +do + echononl "PHP Version [$_VERSION]: " + read VERSION + if [ "X$VERSION" = "X" ]; then + VERSION=$_VERSION + fi +done +MAJOR_VERSION=`echo $VERSION | cut -d '.' -f1,2` + +echo "" +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo "Insert User/Group for apache daemon (httpd)." +echo "" +echo "" + +HTTPD_USER= +while [ "X$HTTPD_USER" = "X" ] +do + echononl "apache user [${_HTTPD_USER}]: " + read HTTPD_USER + if [ "X$HTTPD_USER" = "X" ]; then + HTTPD_USER=$_HTTPD_USER + fi +done +if [ -z "$_HTTPD_GROUP" ]; then + if [ "$HTTPD_USER" = "nobody" ]; then + _HTTPD_GROUP="nogroup" + else + _HTTPD_GROUP=$HTTPD_USER + fi +fi +while [ "X$HTTPD_GROUP" = "X" ] +do + echononl "apache group [$_HTTPD_GROUP]: " + read HTTPD_GROUP + if [ "X$HTTPD_GROUP" = "X" ]; then + HTTPD_GROUP=$_HTTPD_GROUP + fi +done + +_PHP_FPM_USER=$HTTPD_USER +_PHP_FPM_GROUP=$HTTPD_GROUP + +echo "" +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo "Insert Path to MySQL Installation directory." +echo "" +echo "Type:" +echo -e "\t\033[33mSystem\033[m if installed from package system" +echo -e "\t\033[33mNot Installed\033[m if no MySQL installation is present" +echo "" +echo "" + +if [ -d "/usr/local/mysql/bin" ]; then + _MYSQL_INSTALL_DIR="/usr/local/mysql" +else + __mysql_bin="`which mysql`" + if [ -n "$__mysql_bin" ] ; then + _MYSQL_INSTALL_DIR="System" + else + _MYSQL_INSTALL_DIR="Not Installed" + fi +fi +MYSQL_INSTALL_DIR= +while [ "X$MYSQL_INSTALL_DIR" = "X" ] +do + echononl "MySQL Installation Directory [${_MYSQL_INSTALL_DIR}]: " + read MYSQL_INSTALL_DIR + if [ "X$MYSQL_INSTALL_DIR" = "X" ]; then + MYSQL_INSTALL_DIR=$_MYSQL_INSTALL_DIR + if [ -x "$_MYSQL_INSTALL_DIR/bin/mysql" ]; then + break + fi + fi + __to_lower=`echo $MYSQL_INSTALL_DIR | tr '[:upper:]' '[:lower:]' | tr -d ' '` + if [ "$__to_lower" = "system" ]; then + MYSQL_INSTALL_DIR="system" + break + fi + if [ "$__to_lower" = "notinstalled" ]; then + MYSQL_INSTALL_DIR="not_installed" + break + fi + if [ -x "$MYSQL_INSTALL_DIR/bin/mysql" ]; then + break + fi + echo "" + echo -e "\t\033[31mNo Mysql Instalation found at \"$MYSQL_INSTALL_DIR\" !! Try again..\033[m" + echo "" + MYSQL_INSTALL_DIR="" + +done + +echo "" +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo -e "Install php-$VERSION with apache module? [ \033[33myes/no\033[m ]" +echo "" +echo "" +OK="" +while [ "X$OK" = "X" ] +do + echononl "Install mod_apache ? [ $_APACHE_MOD_PHP ] " + read OK + __to_lower=`echo $OK | tr '[:upper:]' '[:lower:]' | tr -d ' '` + if [ "X$OK" = "X" ]; then + OK=$_APACHE_MOD_PHP + break + fi + if [ "$__to_lower" = "yes" -o "$__to_lower" = "no" ]; then + OK=$__to_lower + break + fi + echo "" + echo -e "\t\033[31mWrong entry !! Try again..\033[m" + echo "" + OK= +done +if [ "$OK" = "yes" ]; then + WITHOUT_APACHE_MOD_PHP=false + WITH_MOD_PHP=true +else + WITHOUT_APACHE_MOD_PHP=true + WITH_MOD_PHP=false +fi + + +if $WITH_MOD_PHP ; then + + echo "" + echo -e "\033[32m--\033[m" + echo "" + echo "Insert version numbers apache (httpd) apr and apr-util." + echo "" + echo "" + APACHE_VERSION= + while [ "X$APACHE_VERSION" = "X" ] + do + echononl "apache version [$_APACHE_VERSION]: " + read APACHE_VERSION + if [ "X$APACHE_VERSION" = "X" ]; then + APACHE_VERSION=$_APACHE_VERSION + fi + if [ -d /usr/local/httpd-${APACHE_VERSION}_php-${VERSION} ]; then + echo "" + echo -e "\t\033[31mApache Instalation found at \"/usr/local/httpd-${APACHE_VERSION}_php-${VERSION}\" !! Try again..\033[m" + echo "" + APACHE_VERSION= + fi + done + APACHE_BASEDIR=/usr/local/httpd-${APACHE_VERSION}_php-${VERSION} + APXS=${APACHE_BASEDIR}/bin/apxs + + PHP_VERSION_STRING="${VERSION}_httpd-${APACHE_VERSION}" + + PREFIX_PHP="/usr/local/php-$VERSION-httpd-${APACHE_VERSION}" + PHP_INI_FILE="${APACHE_BASEDIR}/conf/php.ini" + _builddir=${_srcdir}/php-${VERSION}_http-${APACHE_VERSION} + _logdir=${_srcdir}/log_php-${VERSION}_http-${APACHE_VERSION}_build + +else + + PHP_VERSION_STRING="$VERSION" + + PREFIX_PHP=/usr/local/php-$VERSION + PHP_INI_FILE="${PREFIX_PHP}/etc/php.ini" + _builddir=${_srcdir}/php-${VERSION} + _logdir=${_srcdir}/log_php-${VERSION}_build + +fi + + +echo "" +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo -e "Define PHP parameters for php.ini file" +echo "" + +## - php.ini: memory_limit +if [ -f "/usr/local/php-${MAJOR_VERSION}/etc/php.ini" ]; then + __memory_limit=$(grep -e "^\s*memory_limit" /usr/local/php-${MAJOR_VERSION}/etc/php.ini | awk '{print$3}') + if [ -n "$__memory_limit" ] ; then + _MEMORY_LIMIT=$__memory_limit + fi +fi + +if [ -f "/usr/local/php-${MAJOR_VERSION}/etc/php.ini" ]; then + __memory_limit=$(grep -e "^\s*memory_limit" /usr/local/php-${MAJOR_VERSION}/etc/php.ini | awk '{print$3}') + if [ -n "$__memory_limit" ] ; then + __MEMORY_LIMIT=$__memory_limit + fi +fi + +MEMORY_LIMIT="" +echononl "memory_limit in Megabyte !! Append \"M\"? [$_MEMORY_LIMIT] " +read MEMORY_LIMIT +if [ "X$MEMORY_LIMIT" = "X" ]; then + MEMORY_LIMIT=$_MEMORY_LIMIT +fi + +## - php.ini: max_execution_time +if [ -f "/usr/local/php-${MAJOR_VERSION}/etc/php.ini" ]; then + __max_execution_time=$(grep -e "^\s*max_execution_time" /usr/local/php-${MAJOR_VERSION}/etc/php.ini | awk '{print$3}') + if [ -n "$__max_execution_time" ] ; then + _MAX_EXECUTION_TIME=$__max_execution_time + fi +fi + +MAX_EXECUTION_TIME="" +echononl "max_execution_time (in Seconds) !! insert ONLY the number? [$_MAX_EXECUTION_TIME] " +read MAX_EXECUTION_TIME +if [ "X$MAX_EXECUTION_TIME" = "X" ]; then + MAX_EXECUTION_TIME=$_MAX_EXECUTION_TIME +fi + +## - php.ini: upload_max_filesize +if [ -f "/usr/local/php-${MAJOR_VERSION}/etc/php.ini" ]; then + __upload_max_filesize=$(grep -e "^\s*upload_max_filesize" /usr/local/php-${MAJOR_VERSION}/etc/php.ini | awk '{print$3}') + if [ -n "$__upload_max_filesize" ] ; then + _UPLOAD_MAX_FILESIZE=$__upload_max_filesize + fi +fi + +UPLOAD_MAX_FILESIZE="" +echononl "upload_max_filesize in Megabyte !! Append \"M\"? [$_UPLOAD_MAX_FILESIZE] " +read UPLOAD_MAX_FILESIZE +if [ "X$UPLOAD_MAX_FILESIZE" = "X" ]; then + UPLOAD_MAX_FILESIZE=$_UPLOAD_MAX_FILESIZE +fi + +## - php.ini: post_max_size +if [ -f "/usr/local/php-${MAJOR_VERSION}/etc/php.ini" ]; then + __post_max_size=$(grep -e "^\s*post_max_size" /usr/local/php-${MAJOR_VERSION}/etc/php.ini | awk '{print$3}') + if [ -n "$__post_max_size" ] ; then + _POST_MAX_SIZE=$__post_max_size + fi +fi + +POST_MAX_SIZE="" +echononl "post_max_size in Megabyte !! Append \"M\"? [$_POST_MAX_SIZE] " +read POST_MAX_SIZE +if [ "X$POST_MAX_SIZE" = "X" ]; then + POST_MAX_SIZE=$_POST_MAX_SIZE +fi + + +echo "" +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo -e "Set Symlinks ? [ \033[33myes/no\033[m ]" +echo "" + +echo "" +if [ ! -h /usr/local/php ] ; then + SYMLINK_PHP=true + echo "Symlink /usr/local/php -> /usr/local/php-$MAJOR_VERSION will be set." +else + OK="" + while [ "X$OK" = "X" ] + do + echononl "Set symlink /usr/local/php -> /usr/local/php-$MAJOR_VERSION ? [ $_SYMLINK_PHP ]: " + read OK + __to_lower=`echo $OK | tr '[:upper:]' '[:lower:]' | tr -d ' '` + if [ "X$OK" = "X" ]; then + OK=$_SYMLINK_PHP + break + fi + if [ "$__to_lower" = "yes" -o "$__to_lower" = "no" ]; then + OK=$__to_lower + break + fi + echo "" + echo -e "\t\033[31mWrong entry !! Try again..\033[m" + echo "" + OK= + done + if [ "$OK" = "yes" ]; then + SYMLINK_PHP=true + else + SYMLINK_PHP=false + fi +fi + +echo "" +if [ ! -h /usr/local/php-${MAJOR_VERSION} ] ; then + SYMLINK_PHP_MAJOR_VERSION=true + echo "Symlink /usr/local/php-$MAJOR_VERSION -> `basename $PREFIX_PHP` will be set." +else + OK="" + while [ "X$OK" = "X" ]; do + echononl "Set symlink /usr/local/php-$MAJOR_VERSION -> `basename $PREFIX_PHP` ? [ $_SYMLINK_PHP_MAJOR_VERSION ]: " + read OK + __to_lower=`echo $OK | tr '[:upper:]' '[:lower:]' | tr -d ' '` + if [ "X$OK" = "X" ]; then + OK=$_SYMLINK_PHP_MAJOR_VERSION + break + fi + if [ "$__to_lower" = "yes" -o "$__to_lower" = "no" ]; then + OK=$__to_lower + break; + fi + echo "" + echo -e "\t\033[31mWrong entry !! Try again..\033[m" + echo "" + OK= + done + if [ "$OK" = "yes" ]; then + SYMLINK_PHP_MAJOR_VERSION=true + else + SYMLINK_PHP_MAJOR_VERSION=false + fi + +fi + + + +echo "" +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo -e "Install support of PHP-FPM (FastCGI Process Manager) [ \033[33myes/no\033[m ]" +echo "" +echo "" +OK="" +while [ "X$OK" = "X" ] +do + echononl "Install FPM support ? [ $_PHP_FPM_SUPPORT ] " + read OK + __to_lower=`echo $OK | tr '[:upper:]' '[:lower:]' | tr -d ' '` + if [ "X$OK" = "X" ]; then + OK=$_PHP_FPM_SUPPORT + break + fi + if [ "$__to_lower" = "yes" -o "$__to_lower" = "no" ]; then + OK=$__to_lower + break + fi + echo "" + echo -e "\t\033[31mWrong entry !! Try again..\033[m" + echo "" + OK= +done +if [ "$OK" = "yes" ]; then + WITH_PHP_FPM_SUPPORT=true + ACTIVATE_PHP_FPM_INIT_SCRIPT=true +else + WITH_PHP_FPM_SUPPORT=false + ACTIVATE_PHP_FPM_INIT_SCRIPT=false +fi + +if $WITH_PHP_FPM_SUPPORT && $WITH_MOD_PHP ; then + if [ -f "/etc/init.d/php-${VERSION}-fpm" ];then + echo "" + OK="" + while [ "X$OK" = "X" ]; do + echononl "Activate PHP-FPM from that installation ? [ no ] " + read OK + __to_lower=`echo $OK | tr '[:upper:]' '[:lower:]' | tr -d ' '` + if [ "X$OK" = "X" ]; then + OK="no" + break + fi + if [ "$__to_lower" = "yes" -o "$__to_lower" = "no" ]; then + OK=$__to_lower + break + fi + echo "" + echo -e "\t\033[31mWrong entry !! Try again..\033[m" + echo "" + OK= + done + if [ "$OK" = "yes" ]; then + ACTIVATE_PHP_FPM_INIT_SCRIPT=true + else + ACTIVATE_PHP_FPM_INIT_SCRIPT=false + fi + fi +fi + + +FPM_PID_FILE=/var/run/php-${MAJOR_VERSION}-fpm.pid + +FPM_LOG_DIR=/var/log/php-${MAJOR_VERSION}-fpm +FPM_ERROR_LOG=${FPM_LOG_DIR}/fpm-${MAJOR_VERSION}-error.log + +FPM_POOL_CONF_DIR=fpm.d +FPM_DEFAULT_POOL=www-${MAJOR_VERSION} + +FPM_DEFAULT_POOL_USER=$_PHP_FPM_USER +FPM_DEFAULT_POOL_GROUP=$_PHP_FPM_GROUP +FPM_DEFAULT_POOL_LISTEN=/tmp/php-${MAJOR_VERSION}-fpm.`echo ${FPM_DEFAULT_POOL} | cut -d'-' -f1`.sock +FPM_DEFAULT_POOL_LISTEN_OWNER=$_PHP_FPM_USER +FPM_DEFAULT_POOL_LISTEN_GROUP=$HTTPD_GROUP +FPM_DEFAULT_POOL_LISTEN_MODE=0660 + +FPM_DEFAULT_POOL_PM=dynamic +FPM_DEFAULT_POOL_MAX_CHILDREN=250 +FPM_DEFAULT_POOL_START_SERVER=5 +FPM_DEFAULT_POOL_MIN_SPARE=5 +FPM_DEFAULT_POOL_MAX_SPARE=10 + +FPM_DEFAULT_POOL_MAX_REQUESTS=500 + +FPM_DEFAULT_POOL_STATUS_PATH="/status-${MAJOR_VERSION}" +FPM_DEFAULT_POOL_PING_PATH="/ping-${MAJOR_VERSION}" +FPM_DEFAULT_POOL_PING_RESPONSE="pong" + +FPM_DEFAULT_POOL_ACCESS_LOG="${FPM_LOG_DIR}/${FPM_DEFAULT_POOL}-access.log" +FPM_DEFAULT_POOL_SLOW_LOG="${FPM_LOG_DIR}/${FPM_DEFAULT_POOL}-slow.log" +FPM_DEFAULT_POOL_ACCESS_FORMAT="\"%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%\"" + +FPM_DEFAULT_POOL_TERMINATE_TIMEOUT="`expr $MAX_EXECUTION_TIME + 1`s" + +FPM_ULIMIT_MAX_FILES=`su -c "ulimit -H -n" -s /bin/bash $_PHP_FPM_USER` + + +echo "" +echo "" +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo -e "\033[21G\033[32mStart PHP Installation with the following Parameters \033[m" +echo "" +echo "PHP version...................: $VERSION" +echo "PHP major version.............: $MAJOR_VERSION" +echo "" +echo "PHP configuration (php.ini)" +echo " memory_limit...............: $MEMORY_LIMIT" +echo " max_execution_time.........: $MAX_EXECUTION_TIME" +echo " upload_max_filesize........: $UPLOAD_MAX_FILESIZE" +echo " post_max_size..............: $POST_MAX_SIZE" +echo "" +echo "Apache User...................: $HTTPD_USER" +echo "Apache Group..................: $HTTPD_GROUP" +echo "" +echo "MySQL Installation directory..: $MYSQL_INSTALL_DIR" +echo "" +echo "Install with FPM support......: $WITH_PHP_FPM_SUPPORT" +if $WITH_PHP_FPM_SUPPORT && $WITH_MOD_PHP ; then + echo " Activate FPM init script...: $ACTIVATE_PHP_FPM_INIT_SCRIPT" +fi +echo "" +echo "Install with (apache) mod_php.: $WITH_MOD_PHP" +if $WITH_MOD_PHP ; then + echo " Apache Version.............: $APACHE_VERSION" +fi +if $WITH_PHP_FPM_SUPPORT ; then + echo " FPM_DEFAULT_POOL_USER......: $FPM_DEFAULT_POOL_USER" + echo " FPM_DEFAULT_POOL_GROUP.....: $FPM_DEFAULT_POOL_GROUP" + echo " FPM_DEFAULT_POOL_LISTEN....: $FPM_DEFAULT_POOL_LISTEN" + echo " FPM_ULIMIT_MAX_FILES.......: $FPM_ULIMIT_MAX_FILES" +fi +echo "" +if $SYMLINK_PHP_MAJOR_VERSION -o $SYMLINK_PHP ; then + echo "Set symlniks:" + if $SYMLINK_PHP ; then + echo " /usr/local/php -> /usr/local/php-$MAJOR_VERSION" + fi + if $SYMLINK_PHP_MAJOR_VERSION ; then + echo " /usr/local/php-$MAJOR_VERSION -> `basename $PREFIX_PHP`" + fi +fi +echo "" +echononl "Start with that configuration? [yes/no]: " +read OK +while [ "X$OK" != "Xyes" -a "X$OK" != "XYes" -a "X$OK" != "XNo" -a "X$OK" != "Xno" ] +do + echononl "wrong entry! [yes/no] :" + read OK +done +[ $OK = "Yes" -o $OK = "yes" ] || fatal "Change parameters and restart script: `basename $0`" + +echo "" +echo "" + + +## -------------------------------------------------- + +if [ -d "$_logdir" ];then + mv $_logdir $_logdir.`date +%Y%m%d-%H%M` +fi +mkdir -p $_logdir > /dev/null 2>&1 +if [ -d "$_builddir" ];then + mv $_builddir $_builddir.`date +%Y%m%d-%H%M` +fi +if [ -d "$PREFIX_PHP" ];then + mv $PREFIX_PHP $PREFIX_PHP.`date +%Y%m%d-%H%M` +fi + + +echo "" +echo "" +echo -e "\033[32m--\033[m" +echo "" +echo "Starting Installation of php-$VERSION..." +echo "" +echo "" + +## - Set Symlink +## - /usr/include/x86_64-linux-gnu/gmp.h -> /usr/include/gmp.h +## - if not exists +## - +if [ -f "/usr/include/x86_64-linux-gnu/gmp.h" -a ! -e "/usr/include/gmp.h" ]; then + echononl "\tSet Symlink /usr/include/x86_64-linux-gnu/gmp.h.." + ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + warn "Cannot set Symlink /usr/include/x86_64-linux-gnu/gmp.h -> /usr/include/gmp.h" + fi + echo "" +fi + +## - get sources.. +## - +cd $_srcdir + +echononl "\tGet source php-$VERSION.tar.bz2.." +if [ ! -f ${_srcdir}/php-$VERSION.tar.bz2 ]; then + wget http://de.php.net/distributions/php-$VERSION.tar.bz2 >> ${_logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fatal "Cannot Download php-$VERSION.tar.bz2" + fi +else + echo_skipped +fi + + +bunzip2 < ${_srcdir}/php-$VERSION.tar.bz2 | tar -xf - || exit 1 +chown -R root.root php-$VERSION || exit 1 +if ! $WITHOUT_APACHE_MOD_PHP ; then + mv php-$VERSION $_builddir +fi +cd $_builddir || exit 1 + +echo -e "\n\tgoing to configure.." +echo -e "\t(see ${_logdir}/php-configure.log for more details)" + + +# : ${_arch:=i686} +# : ${_arch:=athlon} +: ${_arch:=k8} ## --> x86-64 instructionset + +##_cflags="-O2 -march=$_arch " + +## - LDFLAGS="-s" --> Remove all symbol table and relocation information from the executable. +## F77="/usr/bin/g77-3.4" \ +## CXXCPP="/usr/bin/g++-3.4 -E" \ +## CC="/usr/bin/gcc-3.4" \ +## CXX="/usr/bin/g++-3.4" \ +## CPP="/usr/bin/cpp-3.4" \ +## CFLAGS="$_cflags" LDFLAGS="-s" \ +config_params=" + --prefix=$PREFIX_PHP \ + --with-gd \ + --with-pgsql \ + --with-pdo-pgsql \ + --with-regex=system \ + --enable-wddx \ + --enable-exif \ + --with-zlib \ + --with-openssl \ + --with-gdbm \ + --with-jpeg-dir \ + --with-png-dir \ + --with-curl \ + --enable-dba \ + --with-mcrypt \ + --with-xpm-dir \ + --with-vpx-dir \ + --with-freetype-dir \ + --enable-ftp \ + --with-gmp \ + --with-readline \ + --enable-sockets \ + --with-imap \ + --with-imap-ssl \ + --with-kerberos \ + --with-gettext \ + --with-pspell \ + --enable-soap \ + --enable-mbstring \ + --enable-zip \ + --enable-calendar \ + --enable-bcmath \ + --enable-opcache \ + --with-bz2 \ + --enable-intl \ + --enable-shmop \ + --enable-sysvmsg \ + --enable-sysvsem \ + --enable-sysvshm \ + --with-mhash \ + --enable-cgi" + +## - t1lib-dev (libt1-dev) not available in debian 8.0 (jessie) +## - +if [ -f "/etc/debian_version" ]; then + DEBIAN_MAJOR_VERSION=`cat /etc/debian_version | cut -d '.' -f1` + if [ $DEBIAN_MAJOR_VERSION -lt 8 ] ; then + config_params="$config_params \ + --with-t1lib" + fi +fi + + +if [ "$MYSQL_INSTALL_DIR" != "not_installed" ]; then + if [ "$MYSQL_INSTALL_DIR" = "system" ];then + if [ -f "/etc/mysql/my.cnf" ]; then + _mysql_socket="`cat /etc/mysql/my.cnf | grep -E \"^\s*socket\" | head -1 | awk '{print$3}'`" + if [ -S "$_mysql_socket" ]; then + config_params="$config_params \ + --with-mysql \ + --with-mysqli \ + --with-pdo-mysql \ + --with-mysql-sock" + else + config_params="$config_params \ + --with-mysql \ + --with-mysqli \ + --with-pdo-mysql " + fi + else + config_params="$config_params \ + --with-mysql \ + --with-mysqli \ + --with-pdo-mysql " + fi + else + config_params="$config_params \ + --with-mysql=$MYSQL_INSTALL_DIR \ + --with-mysqli=${MYSQL_INSTALL_DIR}/bin/mysql_config \ + --with-pdo-mysql=$MYSQL_INSTALL_DIR \ + --with-mysql-sock" + fi +fi + +if $WITHOUT_APACHE_MOD_PHP ; then + config_params="$config_params --without-apxs2 --without-apxs --with-config-file-path=${PREFIX_PHP}/etc" +else + config_params="$config_params --with-apxs2=$APXS --with-config-file-path=${APACHE_BASEDIR}/conf" +fi + +if $WITH_PHP_FPM_SUPPORT ; then + config_params="$config_params --enable-fpm" +fi + +LDFLAGS="-s" \ +./configure $config_params > ${_logdir}/php-configure.log 2>&1 || exit 1 + + +## --with-mm \ # does not work with apache v2.4 + +## --with-pgsql=/usr/local/pgsql \ + +## --with-mysql=/usr/local/mysql \ +## --with-mysqli=/usr/local/mysql/bin/mysql_config \ +## --with-pdo-mysql=/usr/local/mysql \ +## --with-mysql-sock \ + +## --with-mysql \ +## --with-mysqli \ +## --with-pdo-mysql \ +## --with-mysql-sock \ + +## --enable-force-cgi-redirect \ +## --enable-track-vars \ +## --with-tiff-dir \ +## --with-ttf \ +## --with-memcache \ +## --with-xml \ + +echo -e "\n\tgoing to compile.." +echo -e "\t(see ${_logdir}/php-make.log for more details)" +make > ${_logdir}/php-make.log 2>&1 || exit 1 + +echo -e "\n\tgoing to install.." +echo -e "\t(see ${_logdir}/php-make_install.log for more details)" +make install > ${_logdir}/php-make_install.log 2>&1 || exit 1 + + +#cp php.ini-production $PHP_INI_FILE || exit 1 +[ -f $PHP_INI_FILE ] && cp -a $PHP_INI_FILE ${$PHP_INI_FILE}-`date +"%Y-%m-%d-%H%M"` +cp php.ini-production $PHP_INI_FILE || exit 1 + + +if ! $WITHOUT_APACHE_MOD_PHP ; then + _set_php_entries="" + echo "" + echo -n "do you want to set \"LoadModule\" entries in httpd.conf ? [y/n]: " + read _set_php_entries + if [ "y" = "$_set_php_entries" -o "Y" = "$_set_php_entries" -o "Yes" = "$_set_php_entries" -o "yes" = "$_set_php_entries" ];then + sed -i -r \ + -e "s&(^\s*LoadModule php5_module.*$)&\1\n#\n AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml\n AddType application/x-httpd-php-source .phps\n#&" ${APACHE_BASEDIR}/conf/httpd.conf + #-e "s&(^\s*LoadModule php5_module.*$)&\1\n\n AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml\n AddType application/x-httpd-php-source .phps\n&" ${APACHE_BASEDIR}/conf/httpd.conf + fi +fi + +echo "" +echo "" +echo -e "\t---" +echo -e "\t--- post installation tasks" +echo -e "\t---" + +if $SYMLINK_PHP ; then + echononl "\tSet symlink /usr/local/php -> /usr/local/php-$MAJOR_VERSION" + if [ -L /usr/local/php ];then + rm -f /usr/local/php + fi + ln -s `basename $PREFIX_PHP` /usr/local/php + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi +fi + +if $SYMLINK_PHP_MAJOR_VERSION ; then + echononl "\tSet symlink /usr/local/php-$MAJOR_VERSION -> `basename $PREFIX_PHP`" + if [ -h /usr/local/php-${MAJOR_VERSION} ] ; then + rm -f /usr/local/php-${MAJOR_VERSION} + fi + ln -s `basename $PREFIX_PHP` /usr/local/php-$MAJOR_VERSION + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi +fi + + +## - special for debian. set manpath entries +## - +if [ -f /etc/manpath.config ];then + if ! grep /usr/local/php/man /etc/manpath.config > /dev/null 2<&1 ; then + echo >> /etc/manpath.config + echo "MANDATORY_MANPATH /usr/local/php/php/man /var/cache/man" >> /etc/manpath.config + echo "MANPATH_MAP /usr/local/php/bin /usr/local/php/php/man" >> /etc/manpath.config + echo "MANDB_MAP /usr/local/php/php/man /var/cache/man" >> /etc/manpath.config + fi +elif [ -f /etc/man.conf];then + if ! grep /opt/php/man /etc/man.conf > /dev/null 2<&1 ; then + echo >> /etc/man.conf + echo "MANPATH /opt/php/man /var/cache/man" >> /etc/man.conf + echo "MANPATH_MAP /opt/php/bin /opt/php/man" >> /etc/man.conf + fi +fi + + +## - Add /usr/local/php/bin to the systems PATH variable +## - +echo "" +echononl "\tAdd `dirname $PREFIX_PHP`/php/bin to the systems PATH variable" +_checkdir=`dirname $PREFIX_PHP`/php/bin +if [ -f /etc/profile ]; then + if ! grep -e "$_checkdir" /etc/profile > /dev/null 2<&1 ; then + perl -i -n -p -e "s#^([ ]*export[ ]*PATH.*$)#check_dir=$_checkdir\nif [ -d \"\\\$check_dir\" ];then\n PATH=\\\${check_dir}:\\\$PATH\nfi\n\n\1#" /etc/profile > /dev/null 2<&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + if ! echo "$PATH" | grep $_checkdir > /dev/null 2>&1 ; then + export PATH=${_checkdir}:$PATH + fi + + else + echo_skipped + fi +fi + + +## - PHP FPM +## - +echo "" +echo "" +echo -e "\t---" +echo -e "\t--- Install support for PHP-FPM" +echo -e "\t---" +echo "" + +if $WITH_PHP_FPM_SUPPORT ; then + + echononl "\tBackup existsing init script /etc/init.d/php-${PHP_VERSION_STRING}-fpm" + if [ -f "/etc/init.d/php-${PHP_VERSION_STRING}-fpm" ]; then + mv /etc/init.d/php-${PHP_VERSION_STRING}-fpm /etc/init.d/php-${PHP_VERSION_STRING}-fpm.`date +%Y%m%d-%H%M` > /dev/null 2<&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + else + echo_skipped + fi + + echononl "\tAdd init script /etc/init.d/php-${PHP_VERSION_STRING}-fpm" + cp ${_builddir}/sapi/fpm/init.d.php-fpm /etc/init.d/php-${PHP_VERSION_STRING}-fpm > /dev/null 2<&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + echononl "\tMake init script executable" + chmod 755 /etc/init.d/php-${PHP_VERSION_STRING}-fpm + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + if [ ! -h /etc/init.d/php-${MAJOR_VERSION}-fpm ]; then + echononl "\tSet Symlink /etc/init.d/php-${MAJOR_VERSION}-fpm --> /etc/init.d/php-${PHP_VERSION_STRING}-fpm" + ln -s /etc/init.d/php-${VERSION}-fpm /etc/init.d/php-${MAJOR_VERSION}-fpm > /dev/null 2<&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + else + if $ACTIVATE_PHP_FPM_INIT_SCRIPT ; then + echononl "\tSet Symlink /etc/init.d/php-${MAJOR_VERSION}-fpm --> /etc/init.d/php-${PHP_VERSION_STRING}-fpm" + rm -f /etc/init.d/php-${MAJOR_VERSION}-fpm + ln -s /etc/init.d/php-${VERSION}-fpm /etc/init.d/php-${MAJOR_VERSION}-fpm > /dev/null 2<&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + fi + fi + + echononl "\tMake php-${MAJOR_VERSION}-fpm start at boottime" + if ! grep -e "/etc/init.d/php-${MAJOR_VERSION}-fpm" /etc/rc.local > /dev/null 2>&1 ; then + sed -i -r -e "s#^([[:space:]]*exit\ +.*)#sleep 2\n/etc/init.d/php-${MAJOR_VERSION}-fpm restart > /dev/null || /bin/true\n\n\1#" /etc/rc.local + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + else + echo_skipped + fi + + _failed=false + echononl "\tAdjust /etc/init.d/php-${PHP_VERSION_STRING}-fpm" + sed -i -r -e "s&^(([ ^t]*php_fpm_PID=).*)$&## \1\n\2${FPM_PID_FILE}&g" /etc/init.d/php-${PHP_VERSION_STRING}-fpm || _failed=true + sed -i -r -e "s&^(#\ .+)php-fpm&\1php-${MAJOR_VERSION}-fpm&" /etc/init.d/php-${PHP_VERSION_STRING}-fpm || _failed=true + if ! $_failed ; then + echo_ok + else + echo_failed + fi + + + echononl "\tCreate php-fpm global configuration file" + cat < ${PREFIX_PHP}/etc/php-fpm.conf +;;;;;;;;;;;;;;;;;;;;; +; FPM Configuration ; +;;;;;;;;;;;;;;;;;;;;; + +; All relative paths in this configuration file are relative to PHP's install +; prefix (/usr/local/php-5.4.35). This prefix can be dynamically changed by using the +; '-p' argument from the command line. + +; Include one or more files. If glob(3) exists, it is used to include a bunch of +; files from a glob(3) pattern. This directive can be used everywhere in the +; file. +; Relative path can also be used. They will be prefixed by: +; - the global prefix if it's been set (-p argument) +; - /usr/local/php-5.4.35 otherwise +;include=etc/fpm.d/*.conf + +;;;;;;;;;;;;;;;;;; +; Global Options ; +;;;;;;;;;;;;;;;;;; + +[global] +; Pid file +; Note: the default prefix is /usr/local/php-5.4.35/var +; Default Value: none +pid = $FPM_PID_FILE + +; Set open file descriptor rlimit for the master process. +; Default Value: system defined value +;rlimit_files = 1024 +rlimit_files = $FPM_ULIMIT_MAX_FILES + +; Error log file +; If it's set to "syslog", log is sent to syslogd instead of being written +; in a local file. +; Note: the default prefix is /usr/local/php-5.4.35/var +; Default Value: log/php-fpm.log +error_log = $FPM_ERROR_LOG + +include=etc/${FPM_POOL_CONF_DIR}/*.conf +EOF + + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + echononl "\tCreate Configuration Directory \"${FPM_POOL_CONF_DIR}\"" + mkdir -p ${PREFIX_PHP}/etc/$FPM_POOL_CONF_DIR + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + echononl "\tCreate php-fpm configuration file for pool \"${FPM_DEFAULT_POOL}\"" + cat < ${PREFIX_PHP}/etc/${FPM_POOL_CONF_DIR}/${FPM_DEFAULT_POOL}.php-fpm.conf +;;;;;;;;;;;;;;;;;;;; +; Pool Definitions ; +;;;;;;;;;;;;;;;;;;;; + +; Multiple pools of child processes may be started with different listening +; ports and different management options. The name of the pool will be +; used in logs and stats. There is no limitation on the number of pools which +; FPM can handle. Your system will tell you anyway :) + +; Start a new pool named '$FPM_DEFAULT_POOL'. +; the variable \$pool can we used in any directive and will be replaced by the +; pool name ('$FPM_DEFAULT_POOL' here) +[$FPM_DEFAULT_POOL] + +; Unix user/group of processes +; Note: The user is mandatory. If the group is not set, the default user's group +; will be used. +user = $FPM_DEFAULT_POOL_USER +group = $FPM_DEFAULT_POOL_GROUP + +; The address on which to accept FastCGI requests. +; Valid syntaxes are: +; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on +; a specific port; +; 'port' - to listen on a TCP socket to all addresses on a +; specific port; +; '/path/to/unix/socket' - to listen on a unix socket. +; Note: This value is mandatory. +listen = $FPM_DEFAULT_POOL_LISTEN + +; Set permissions for unix socket, if one is used. In Linux, read/write +; permissions must be set in order to allow connections from a web server. Many +; BSD-derived systems allow connections regardless of permissions. +; Default Values: user and group are set as the running user +; mode is set to 0660 +listen.owner = $FPM_DEFAULT_POOL_LISTEN_OWNER +listen.group = $FPM_DEFAULT_POOL_LISTEN_GROUP +listen.mode = $FPM_DEFAULT_POOL_LISTEN_MODE + +; Choose how the process manager will control the number of child processes. +; Possible Values: +; static - a fixed number (pm.max_children) of child processes; +; dynamic - the number of child processes are set dynamically based on the +; following directives. With this process management, there will be +; always at least 1 children. +; pm.max_children - the maximum number of children that can +; be alive at the same time. +; pm.start_servers - the number of children created on startup. +; pm.min_spare_servers - the minimum number of children in 'idle' +; state (waiting to process). If the number +; of 'idle' processes is less than this +; number then some children will be created. +; pm.max_spare_servers - the maximum number of children in 'idle' +; state (waiting to process). If the number +; of 'idle' processes is greater than this +; number then some children will be killed. +; ondemand - no children are created at startup. Children will be forked when +; new requests will connect. The following parameter are used: +; pm.max_children - the maximum number of children that +; can be alive at the same time. +; pm.process_idle_timeout - The number of seconds after which +; an idle process will be killed. +; Note: This value is mandatory. +pm = $FPM_DEFAULT_POOL_PM + +; The number of child processes to be created when pm is set to 'static' and the +; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. +; This value sets the limit on the number of simultaneous requests that will be +; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. +; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP +; CGI. The below defaults are based on a server without much resources. Don't +; forget to tweak pm.* to fit your needs. +; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' +; Note: This value is mandatory. +pm.max_children = $FPM_DEFAULT_POOL_MAX_CHILDREN + +; The number of child processes created on startup. +; Note: Used only when pm is set to 'dynamic' +; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 +pm.start_servers = $FPM_DEFAULT_POOL_START_SERVER + +; The desired minimum number of idle server processes. +; Note: Used only when pm is set to 'dynamic' +; Note: Mandatory when pm is set to 'dynamic' +pm.min_spare_servers = $FPM_DEFAULT_POOL_MIN_SPARE + +; The desired maximum number of idle server processes. +; Note: Used only when pm is set to 'dynamic' +; Note: Mandatory when pm is set to 'dynamic' +pm.max_spare_servers = $FPM_DEFAULT_POOL_MAX_SPARE + +; The number of requests each child process should execute before respawning. +; This can be useful to work around memory leaks in 3rd party libraries. For +; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. +; Default Value: 0 +pm.max_requests = $FPM_DEFAULT_POOL_MAX_REQUESTS + +; The URI to view the FPM status page. If this value is not set, no URI will be +; recognized as a status page. It shows the following informations: +; pool - the name of the pool; +; process manager - static, dynamic or ondemand; +; start time - the date and time FPM has started; +; start since - number of seconds since FPM has started; +; accepted conn - the number of request accepted by the pool; +; listen queue - the number of request in the queue of pending +; connections (see backlog in listen(2)); +; max listen queue - the maximum number of requests in the queue +; of pending connections since FPM has started; +; listen queue len - the size of the socket queue of pending connections; +; idle processes - the number of idle processes; +; active processes - the number of active processes; + + +; total processes - the number of idle + active processes; +; max active processes - the maximum number of active processes since FPM +; has started; +; max children reached - number of times, the process limit has been reached, +; when pm tries to start more children (works only for +; pm 'dynamic' and 'ondemand'); +; Value are updated in real time. +; Example output: +; pool: www +; process manager: static +; start time: 01/Jul/2011:17:53:49 +0200 +; start since: 62636 +; accepted conn: 190460 +; listen queue: 0 +; max listen queue: 1 +; listen queue len: 42 +; idle processes: 4 +; active processes: 11 +; total processes: 15 +; max active processes: 12 +; max children reached: 0 +; +; By default the status page output is formatted as text/plain. Passing either +; 'html', 'xml' or 'json' in the query string will return the corresponding +; output syntax. Example: +; http://www.foo.bar/status +; http://www.foo.bar/status?json +; http://www.foo.bar/status?html +; http://www.foo.bar/status?xml +; +; By default the status page only outputs short status. Passing 'full' in the +; query string will also return status for each pool process. +; Example: +; http://www.foo.bar/status?full +; http://www.foo.bar/status?json&full +; http://www.foo.bar/status?html&full +; http://www.foo.bar/status?xml&full +; The Full status returns for each process: +; pid - the PID of the process; +; state - the state of the process (Idle, Running, ...); +; start time - the date and time the process has started; +; start since - the number of seconds since the process has started; +; requests - the number of requests the process has served; +; request duration - the duration in µs of the requests; +; request method - the request method (GET, POST, ...); +; request URI - the request URI with the query string; +; content length - the content length of the request (only with POST); +; user - the user (PHP_AUTH_USER) (or '-' if not set); +; script - the main script called (or '-' if not set); +; last request cpu - the %cpu the last request consumed +; it's always 0 if the process is not in Idle state +; because CPU calculation is done when the request +; processing has terminated; +; last request memory - the max amount of memory the last request consumed +; it's always 0 if the process is not in Idle state +; because memory calculation is done when the request +; processing has terminated; +; If the process is in Idle state, then informations are related to the +; last request the process has served. Otherwise informations are related to +; the current request being served. +; Example output: +; ************************ +; pid: 31330 +; state: Running +; start time: 01/Jul/2011:17:53:49 +0200 +; start since: 63087 +; requests: 12808 +; request duration: 1250261 +; request method: GET +; request URI: /test_mem.php?N=10000 +; content length: 0 +; user: - +; script: /home/fat/web/docs/php/test_mem.php +; last request cpu: 0.00 +; last request memory: 0 +; +; Note: There is a real-time FPM status monitoring sample web page available +; It's available in: ${prefix}/share/fpm/status.html +; +; Note: The value must start with a leading slash (/). The value can be +; anything, but it may not be a good idea to use the .php extension or it +; may conflict with a real PHP file. +; Default Value: not set +pm.status_path = $FPM_DEFAULT_POOL_STATUS_PATH + +; The ping URI to call the monitoring page of FPM. If this value is not set, no +; URI will be recognized as a ping page. This could be used to test from outside +; that FPM is alive and responding, or to +; - create a graph of FPM availability (rrd or such); +; - remove a server from a group if it is not responding (load balancing); +; - trigger alerts for the operating team (24/7). +; Note: The value must start with a leading slash (/). The value can be +; anything, but it may not be a good idea to use the .php extension or it +; may conflict with a real PHP file. +; Default Value: not set +ping.path = $FPM_DEFAULT_POOL_PING_PATH + +; This directive may be used to customize the response of a ping request. The +; response is formatted as text/plain with a 200 response code. +; Default Value: pong +ping.response = $FPM_DEFAULT_POOL_PING_RESPONSE + +; The access log file +; Default: not set +access.log = $FPM_DEFAULT_POOL_ACCESS_LOG +; The access log format. +; The following syntax is allowed +; %%: the '%' character +; %C: %CPU used by the request +; it can accept the following format: +; - %{user}C for user CPU only +; - %{system}C for system CPU only +; - %{total}C for user + system CPU (default) +; %d: time taken to serve the request +; it can accept the following format: +; - %{seconds}d (default) +; - %{miliseconds}d +; - %{mili}d +; - %{microseconds}d +; - %{micro}d +; %e: an environment variable (same as $_ENV or $_SERVER) +; it must be associated with embraces to specify the name of the env +; variable. Some exemples: +; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e +; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e +; %f: script filename +; %l: content-length of the request (for POST request only) +; %m: request method +; %M: peak of memory allocated by PHP +; it can accept the following format: +; - %{bytes}M (default) +; - %{kilobytes}M +; - %{kilo}M +; - %{megabytes}M +; - %{mega}M +; %n: pool name +; %o: output header +; it must be associated with embraces to specify the name of the header: +; - %{Content-Type}o +; - %{X-Powered-By}o +; - %{Transfert-Encoding}o +; - .... +; %p: PID of the child that serviced the request +; %P: PID of the parent of the child that serviced the request +; %q: the query string +; %Q: the '?' character if query string exists +; %r: the request URI (without the query string, see %q and %Q) +; %R: remote IP address +; %s: status (response code) +; %t: server time the request was received +; it can accept a strftime(3) format: +; %d/%b/%Y:%H:%M:%S %z (default) +; %T: time the log has been written (the request has finished) +; it can accept a strftime(3) format: +; %d/%b/%Y:%H:%M:%S %z (default) +; %u: remote user +; +; Default: "%R - %u %t \"%m %r\" %s" +access.format = $FPM_DEFAULT_POOL_ACCESS_FORMAT + +; The log file for slow requests +; Default Value: not set +; Note: slowlog is mandatory if request_slowlog_timeout is set +request_slowlog_timeout = 10s +slowlog = $FPM_DEFAULT_POOL_SLOW_LOG + +; The timeout for serving a single request after which the worker process will +; be killed. This option should be used when the 'max_execution_time' ini option +; does not stop script execution for some reason. A value of '0' means 'off'. +; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) +; Default Value: 0 +request_terminate_timeout = $FPM_DEFAULT_POOL_TERMINATE_TIMEOUT + +EOF + + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + if [ "$_HTTPD_USER" != $FPM_DEFAULT_POOL_LISTEN_OWNER ]; then + echononl "\tAdd apache user to group \"$FPM_DEFAULT_POOL_LISTEN_GROUP\"" + usermod -a -G $FPM_DEFAULT_POOL_LISTEN_GROUP $_HTTPD_USER + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + fi + + echononl "\tCreate log directory for PHP-FPM \"${FPM_LOG_DIR}\"" + mkdir -p $FPM_LOG_DIR + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + echononl "\tConfigure logrotation for \"${FPM_LOG_DIR}\"" + if [ ! -f "/etc/logrotate.d/php-${MAJOR_VERSION}-fpm" ]; then + cat < /etc/logrotate.d/php-${MAJOR_VERSION}-fpm +$FPM_LOG_DIR/*log { + daily + rotate 7 + start 0 + compress + delaycompress + missingok + notifempty +} +EOF + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + else + echo_skipped + fi + +fi + + + +## - PHP Extensions +## - +echo "" +echo "" +echo -e "\t---" +echo -e "\t--- Install PHP extensions" +echo -e "\t---" +echo "" + + +## ----- +## - Install geoip +## ----- + +echononl "\tInstalling libgeoip1 libgeoip-dev geoip-bin .." +if ! dpkg -l libgeoip-dev | grep -e "^ii" | grep libgeoip-dev > /dev/null 2>&1 ; then + apt-get -q -y install libgeoip1 libgeoip-dev geoip-bin > /dev/null 2>&1 + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + fi +else + echo_skipped +fi + +echononl "\tInstall geoip via pecl.." +${PREFIX_PHP}/bin/pecl install geoip > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tphp.ini: extension=geoip.so .." +_extension="geoip.so" +perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\n#" $PHP_INI_FILE +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +## ----- +## - END: Install geoip +## ----- + + +## ----- +## - Install uploadprogress +## ----- + +echononl "\tInstall uploadprogress via pecl.." +printf "\n" | ${PREFIX_PHP}/bin/pecl install uploadprogress > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tphp.ini: extension=uploadprogress .." +_extension="uploadprogress.so" +perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\n#" $PHP_INI_FILE +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +## ----- +## - END: Install uploadprogress +## ----- + + +## ----- +## - Install solr +## ----- + +echononl "\tInstall solr via pecl.." +printf "\n" | ${PREFIX_PHP}/bin/pecl install solr > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tphp.ini: extension=solr .." +_extension="solr.so" +perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\n#" $PHP_INI_FILE +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +## ----- +## - END: Install solr +## ----- + + +## ----- +## - Install redis +## ----- + +echononl "\tInstall redis via pecl.." +printf "\n" | ${PREFIX_PHP}/bin/pecl install redis > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tphp.ini: extension=redis .." +_extension="redis.so" +perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\n#" $PHP_INI_FILE +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +## ----- +## - END: Install redis +## ----- + + +## ----- +## - Install imagick +## ----- + +echononl "\tInstalling libmagickcore-dev libmagickwand-dev .." +_install="" +if ! dpkg -l libmagickwand-dev 2>/dev/null | grep -e "^ii" | grep libmagickwand-dev > /dev/null 2>&1 ; then + _install="libmagickwand-dev" +fi +if ! dpkg -l libmagickcore-dev 2>/dev/null | grep -e "^ii" | grep libmagickcore-dev > /dev/null 2>&1 ; then + _install="$_install libmagickcore-dev" +fi +if [ -n "$_install" ];then + apt-get -q -y install libmagickcore-dev libmagickwand-dev > /dev/null 2>&1 + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + fi +else + echo_skipped +fi + +_MagickWand_config=`which MagickWand-config` +if [ -z "$_MagickWand_config" ]; then + + echononl "\tUpdate file name database (updatedb).." + updatedb > /dev/null 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + + _MagickWand_config=`locate MagickWand-config | grep -e "/MagickWand-config$" | head -n 1` + if [ -n "$_MagickWand_config" ]; then + echononl "\tSymlink /usr/bin/MagickWand-config --> $_MagickWand_config" + ln -s /usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16/MagickWand-config /usr/bin/ + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + fi + else + warn "Cannot find \"MagickWand_config\" - but is needed for \"imagick\"." + + fi +fi + +echononl "\tInstall imagick via pecl.." +printf "\n" | ${PREFIX_PHP}/bin/pecl install imagick > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tphp.ini: extension=imagick.so .." +_extension="imagick.so" +perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\n#" $PHP_INI_FILE +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +## ----- +## - END: Install imagick +## ----- + + +## ----- +## - Install xdebug +## ----- + +echononl "\tInstall xdebug via pecl.." +printf "\n" | ${PREFIX_PHP}/bin/pecl install xdebug > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + + +#echononl "\tphp.ini: extension=xdebug .." +#_extension="xdebug" +#perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\n#" $PHP_INI_FILE +#if [ "$?" = "0" ]; then +# echo_ok +#else +# echo_failed +#fi + +if $WITHOUT_APACHE_MOD_PHP ; then + zend_extension_xdebug=`find /usr/local/php-${MAJOR_VERSION}/lib/php/extensions -name xdebug.so -print` +else + #zend_extension_xdebug=`locate xdebug.so | grep ${PREFIX_PHP}/lib/php/extensions` + zend_extension_xdebug=`find ${PREFIX_PHP}/lib/php/extensions -name xdebug.so -print` +fi + +echononl "\tphp.ini: zend_extension = \"/abs/path/to/xdebug.so\" .." +perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\n;zend_extension = $zend_extension_xdebug\n#" $PHP_INI_FILE +#sed -i "s/^/\nzend_extension = ${zend_extension_xdebug}\n\n/" $PHP_INI_FILE +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tphp.ini: Create section [xdebug]" +echo "[xdebug]" >> $PHP_INI_FILE +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tphp.ini: xdebug.max_nesting_level = 150" +echo "xdebug.max_nesting_level = 150" >> $PHP_INI_FILE +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +## ----- +## - END: Install xdebug +## ----- + + + +echo "" +echo "" +echo -e "\t---" +echo -e "\t--- Install PHP PEAR extensions" +echo -e "\t---" +echo "" + +echononl "\tInstall Mail via pear.." +${PREFIX_PHP}/bin/pear install Mail > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tInstall Mail_Mime via pear.." +${PREFIX_PHP}/bin/pear install Mail_Mime > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tInstall Net_Socket via pear.." +${PREFIX_PHP}/bin/pear install Net_Socket > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + +echononl "\tInstall Net_SMTP via pear.." +${PREFIX_PHP}/bin/pear install Net_SMTP > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + + + +## - Configure php.ini (base) +## - +echo "" +echo "" +echo -e "\t---" +echo -e "\t--- Configure php.ini (base)" +echo -e "\t---" +echo "" + +## - set date.timezon = "Europe/Berlin" +## - +echononl "\tphp.ini: date.timezone = \"Europe/Berlin\"" +_key="date.timezone" +_val="Europe/Berlin" +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = \"${_val}\"#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + +## - set short_open_tag = On +## - +echononl "\tphp.ini: short_open_tag = On" +_key="short_open_tag" +_val="Off" +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## - set memory_limit = $MEMORY_LIMIT +## - +echononl "\tphp.ini: memory_limit = $MEMORY_LIMIT" +_key="memory_limit" +_val=$MEMORY_LIMIT +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## - set max_execution_time = $MAX_EXECUTION_TIME +## - +echononl "\tphp.ini: max_execution_time = $MAX_EXECUTION_TIME" +_key="max_execution_time" +_val=$MAX_EXECUTION_TIME +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## - set error_log = /var/log/apache2/php_errors.log +## - +echononl "\tphp.ini: error_log = /var/log/apache2/php_errors.log" +_key="error_log" +_val="/var/log/apache2/php_errors.log" +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi +touch $_val +chown ${HTTPD_USER}:$HTTPD_GROUP $_val + + +## - set upload_max_filesize = $UPLOAD_MAX_FILESIZE +## - +echononl "\tphp.ini: upload_max_filesize = $UPLOAD_MAX_FILESIZE" +_key="upload_max_filesize" +_val="$UPLOAD_MAX_FILESIZE" +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## - set post_max_size = $POST_MAX_SIZE +## - +echononl "\tphp.ini: post_max_size = $POST_MAX_SIZE" +_key="post_max_size" +_val="$POST_MAX_SIZE" +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## - set max_file_uploads = 50 +## - +echononl "\tphp.ini: max_file_uploads = 50" +_key="max_file_uploads" +_val=50 +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## - set always_populate_raw_post_data = -1 +## - +echononl "\tphp.ini: always_populate_raw_post_data = -1" +_key="always_populate_raw_post_data" +_val=-1 +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + +## ----- +## - END: Configure php.ini (base) +## ----- + + +## ----- +## - configure OPCache +## ----- + +echo "" + +echononl "\tUpdate file name database (updatedb).." +updatedb > /dev/null 2>&1 +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + + + +if $WITHOUT_APACHE_MOD_PHP ; then + zend_extension_opcache=`find /usr/local/php-${MAJOR_VERSION}/lib/php/extensions -name opcache.so -print` +else + #zend_extension_opcache=`locate opcache.so | grep ${PREFIX_PHP}/lib/php/extensions` + zend_extension_opcache=`find ${PREFIX_PHP}/lib/php/extensions -name opcache.so -print` +fi + +echononl "\tphp.ini: zend_extension = \"/abs/path/to/opcache.so\" .." +perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nzend_extension = ${zend_extension_opcache}\n#" $PHP_INI_FILE +#sed -i "s/^/\nzend_extension = ${zend_extension_opcache}\n\n/" $PHP_INI_FILE +if [ "$?" = "0" ]; then + echo_ok +else + echo_failed +fi + + +## - set opcache.error_log="/var/log/apache2/ +## - +echononl "\tphp.ini: opcache.error_log = /var/log/apache2/opcache_errors.log" +_key="opcache.error_log" +_val="/var/log/apache2/opcache_errors.log" +if grep -e "^\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${_key}\s*=.*)#;\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + sed -i "0,/^\([ \t]*;[ \t]*${_key}[ \t]*=.*\)/ s##\1\n${_key} = \"${_val}\"\n#" $PHP_INI_FILE + #perl -i -n -p -e "s#^(\s*;\s*${_key}\s*=.*)#\1\n${_key} = ${_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi +touch $_val +chown ${HTTPD_USER}:$HTTPD_GROUP $_val + +## - set opcache.enable=1 +## - +echononl "\tphp.ini: opcache.enable = 1 .." +opcache_key="opcache.enable" +opcache_val=1 +if grep -e "^\s*${opcache_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${opcache_key}\s*=.*)#;\1\n*${opcache_key} = ${opcache_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${opcache_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*;${opcache_key}\s*=.*)#\1\n${opcache_key} = ${opcache_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + +## - set opcache.enable_cli=0 +## - +echononl "\tphp.ini: opcache.enable_cli = 0 .." +opcache_key="opcache.enable_cli" +opcache_val=0 +if grep -e "^\s*${opcache_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${opcache_key}\s*=.*)#;\1\n*${opcache_key} = ${opcache_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${opcache_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*;${opcache_key}\s*=.*)#\1\n${opcache_key} = ${opcache_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + +## - set opcache.interned_strings_buffer=8 +## - +echononl "\tphp.ini: opcache.interned_strings_buffer = 8 .." +opcache_key="opcache.interned_strings_buffer" +opcache_val=8 +if grep -e "^\s*${opcache_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${opcache_key}\s*=.*)#;\1\n*${opcache_key} = ${opcache_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${opcache_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*;${opcache_key}\s*=.*)#\1\n${opcache_key} = ${opcache_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + +## - set opcache.max_accelerated_files=4000 +## - +echononl "\tphp.ini: opcache.max_accelerated_files = 4000 .." +opcache_key="opcache.max_accelerated_files" +opcache_val=4000 +if grep -e "^\s*${opcache_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${opcache_key}\s*=.*)#;\1\n*${opcache_key} = ${opcache_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${opcache_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*;${opcache_key}\s*=.*)#\1\n${opcache_key} = ${opcache_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + +## - set opcache.validate_timestamps=1 +## - +echononl "\tphp.ini: opcache.validate_timestamps = 1 .." +opcache_key="opcache.validate_timestamps" +opcache_val=1 +if grep -e "^\s*${opcache_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${opcache_key}\s*=.*)#;\1\n*${opcache_key} = ${opcache_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${opcache_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*;${opcache_key}\s*=.*)#\1\n${opcache_key} = ${opcache_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + +## - set opcache.revalidate_freq=60 +## - +echononl "\tphp.ini: opcache.revalidate_freq = 60 .." +opcache_key="opcache.revalidate_freq" +opcache_val=60 +if grep -e "^\s*${opcache_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${opcache_key}\s*=.*)#;\1\n*${opcache_key} = ${opcache_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${opcache_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*;${opcache_key}\s*=.*)#\1\n${opcache_key} = ${opcache_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + +## - set opcache.fast_shutdown=0 +## - +## - setting opcache.fast_shutdown=1 causes the following error in apache error_log: +## - +## - zend_mm_heap corrupted +## - +## - sometimes un conjunction with +## - +## - [Sun May 11 23:02:25.120263 2014] [core:warn] [pid 11566:tid 139746681894656] +## - AH00045: child process 28405 still did not exit, sending a SIGTERM +## - +echononl "\tphp.ini: opcache.fast_shutdown = 0 .." +opcache_key="opcache.fast_shutdown" +opcache_val=0 +if grep -e "^\s*${opcache_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*${opcache_key}\s*=.*)#;\1\n*${opcache_key} = ${opcache_val}#" $PHP_INI_FILE + _retval=$? +elif grep -e "^\s*;\s*${opcache_key}\s*=" $PHP_INI_FILE > /dev/null 2>&1 ; then + perl -i -n -p -e "s#^(\s*;${opcache_key}\s*=.*)#\1\n${opcache_key} = ${opcache_val}#" $PHP_INI_FILE + _retval=$? +fi +if [ "$_retval" = "0" ]; then + echo_ok +else + echo_failed +fi + +## ----- +## - END: configure OPCache +## ----- + + +cd $pwd + +cat<