#!/usr/bin/env bash # php ( fuer Apache 2 ) # _VERSION=5.4.45 #WITHOUT_APACHE_MOD_PHP=true _APACHE_MOD_PHP=no _APACHE_VERSION= _HTTPD_USER=www-data _srcdir=$(dirname $(realpath $0)) _pwd=`pwd` _PHP_FPM_SUPPORT=yes _SYMLINK_PHP=no _SYMLINK_PHP_MAIN_VERSION=no _MEMORY_LIMIT="512M" _MAX_EXECUTION_TIME=180 _MAX_INPUT_TIME=180 _UPLOAD_MAX_FILESIZE="128M" _POST_MAX_SIZE="128M" _SKIP_UPDATE_DB=no _CRONTAB_BAKUP_FILE="$(mktemp)" ## --- 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 ]" } is_int() { return $(test "$@" -eq "$@" > /dev/null 2>&1); } detect_os_1 () { if $(which lsb_release > /dev/null 2>&1) ; then os_dist="$(lsb_release -i | awk '{print tolower($3)}')" os_version="$(lsb_release -r | awk '{print tolower($2)}')" os_codename="$(lsb_release -c | awk '{print tolower($2)}')" if [[ "$os_dist" = "debian" ]]; then if $(echo "$os_version" | grep -q '\.') ; then os_version=$(echo "$os_version" | cut --delimiter='.' -f1) fi fi elif [[ -e "/etc/os-release" ]]; then . /etc/os-release os_dist=$ID os_version=${os_version_ID} fi # remove whitespace from os_dist and os_version os_dist="${os_dist// /}" os_version="${os_version// /}" } ## --- ## --- END: functions ## -------------------------------------------------- # - Support systemd ? # - if [[ "X$(which systemd)" = "X" ]]; then SYSTEMD_EXISTS=false else SYSTEMD_EXISTS=true fi # - Set variable # - os_dist # - os_version # - os_codename # - detect_os_1 _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 libxpm-dev libfreetype6-dev libwmf-dev libtiff-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 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 libwebp-dev libpq-dev postgresql-client libreadline-dev libncurses-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 libapr1-dev libaprutil1-dev liblua5.1-0 liblua5.1-0-dev libsctp-dev libcrypto++-dev" if [[ "$os_dist" = "debian" ]] && [[ $os_version -lt 9 ]] ; then _required_base_packages="$_required_base_packages libjasper-dev libpng12-dev" if [[ ! -d "/usr/local/mysql/" ]]; then _required_base_packages="$_required_base_packages libmysqlclient-dev" fi else _required_base_packages="$_required_base_packages libpng-dev" if [[ ! -d "/usr/local/mysql/" ]]; then _required_base_packages="$_required_base_packages default-libmysqlclient-dev" fi fi if [[ "$os_dist" = "debian" ]] && [[ $os_version -eq 7 ]] ; then _required_base_packages="$_required_base_packages libgd2-xpm-dev libdb5.1 libdb5.1++ libdb5.1++-dev libdb5.1-dev" else _required_base_packages="$_required_base_packages libgd-dev libdb5.3 libdb5.3++ libdb5.3++-dev libdb5.3-dev" fi 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 -axu | grep httpd | grep -e "^root" | grep -v grep | awk '{print$11}')" 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 ## -------------------------------------------------- ## -------------------------------------------------- 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 PHP_MAIN_VERSION=`echo $VERSION | cut -d '.' -f1,2` PHP_MAJOR_VERSION=`echo $VERSION | cut -d '.' -f1` PHP_MINOR_VERSION=`echo $VERSION | cut -d '.' -f2` PHP_PATCH_LEVEL=`echo $VERSION | cut -d '.' -f3` # - A hack, because configure don't work with systemd on version 5.4.x ## - if [[ "$PHP_MAIN_VERSION" = "5.4" ]]; then SYSTEMD_EXISTS=false fi ## - Let make use multiple cores (-j) ## - if [[ "$PHP_MAIN_VERSION" != "5.4" ]]; then export MAKEFLAGS=-j$(expr `grep "^processor" /proc/cpuinfo | sort -u | wc -l` + 1) else unset MAKEFLAGS 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-${PHP_MAIN_VERSION}/etc/php.ini" ]; then __memory_limit=$(grep -e "^\s*memory_limit" /usr/local/php-${PHP_MAIN_VERSION}/etc/php.ini | awk '{print$3}') if [ -n "$__memory_limit" ] ; then _MEMORY_LIMIT=$__memory_limit fi fi if [ -f "/usr/local/php-${PHP_MAIN_VERSION}/etc/php.ini" ]; then __memory_limit=$(grep -e "^\s*memory_limit" /usr/local/php-${PHP_MAIN_VERSION}/etc/php.ini | awk '{print$3}') if [ -n "$__memory_limit" ] ; then __MEMORY_LIMIT=$__memory_limit fi fi MEMORY_LIMIT="" while [[ "X$MEMORY_LIMIT" = "X" ]]; do echononl "memory_limit - Append unit \"K\", \"M\" or \"G\" [$_MEMORY_LIMIT] " read MEMORY_LIMIT if [ "X$MEMORY_LIMIT" = "X" ]; then MEMORY_LIMIT=$_MEMORY_LIMIT fi if is_int $MEMORY_LIMIT ; then MEMORY_LIMIT="${MEMORY_LIMIT}M" warn "No unit is given. \"M\" was appended: memory_limit: $MEMORY_LIMIT" continue fi _unit="${MEMORY_LIMIT: -1}" if [[ "$_unit" != "K" ]] && [[ "$_unit" != "M" ]] && [[ "$_unit" != "G" ]]; then warn "Wrong unit was given for memory_limit. Reenter again" MEMORY_LIMIT="" continue fi if ! is_int ${MEMORY_LIMIT::-1} ; then warn "Wrong value for memory_limit. was given. Reenter again" MEMORY_LIMIT="" fi done ## - php.ini: max_execution_time if [ -f "/usr/local/php-${PHP_MAIN_VERSION}/etc/php.ini" ]; then __max_execution_time=$(grep -e "^\s*max_execution_time" /usr/local/php-${PHP_MAIN_VERSION}/etc/php.ini | awk '{print$3}') if [ -n "$__max_execution_time" ] ; then _MAX_EXECUTION_TIME=$__max_execution_time fi fi MAX_EXECUTION_TIME="" while [[ "X$MAX_EXECUTION_TIME" = "X" ]]; do 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 if ! is_int ${MAX_EXECUTION_TIME} ; then warn "Wrong value for max_execution_time was given. Reenter again" MAX_EXECUTION_TIME="" fi done ## - php.ini: upload_max_filesize if [ -f "/usr/local/php-${PHP_MAIN_VERSION}/etc/php.ini" ]; then __upload_max_filesize=$(grep -e "^\s*upload_max_filesize" /usr/local/php-${PHP_MAIN_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-${PHP_MAIN_VERSION}/etc/php.ini" ]; then __max_input_time=$(grep -e "^\s*max_input_time" /usr/local/php-${PHP_MAIN_VERSION}/etc/php.ini | awk '{print$3}') if [ -n "$__max_input_time" ] ; then _MAX_INPUT_TIME=$__max_input_time fi fi MAX_INPUT_TIME="" while [[ "X$MAX_INPUT_TIME" = "X" ]]; do 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 if ! is_int ${MAX_INPUT_TIME} ; then warn "Wrong value for max_input_time was given. Reenter again" MAX_INPUT_TIME="" fi done ## - php.ini: upload_max_filesize if [ -f "/usr/local/php-${PHP_MAIN_VERSION}/etc/php.ini" ]; then __upload_max_filesize=$(grep -e "^\s*upload_max_filesize" /usr/local/php-${PHP_MAIN_VERSION}/etc/php.ini | awk '{print$3}') if [ -n "$__upload_max_filesize" ] ; then _UPLOAD_MAX_FILESIZE=$__upload_max_filesize fi fi UPLOAD_MAX_FILESIZE="" while [[ "X$UPLOAD_MAX_FILESIZE" = "X" ]]; do echononl "upload_max_filesize - Append unit \"K\", \"M\" or \"G\" [$_UPLOAD_MAX_FILESIZE] " read UPLOAD_MAX_FILESIZE if [ "X$UPLOAD_MAX_FILESIZE" = "X" ]; then UPLOAD_MAX_FILESIZE=$_UPLOAD_MAX_FILESIZE fi if is_int $UPLOAD_MAX_FILESIZE ; then UPLOAD_MAX_FILESIZE="${UPLOAD_MAX_FILESIZE}M" warn "No unit is given. \"M\" was appended: upload_max_filesize: $UPLOAD_MAX_FILESIZE" continue fi _unit="${UPLOAD_MAX_FILESIZE: -1}" if [[ "$_unit" != "K" ]] && [[ "$_unit" != "M" ]] && [[ "$_unit" != "G" ]]; then warn "Wrong unit was given for upload_max_filesize Reenter again" UPLOAD_MAX_FILESIZE="" continue fi if ! is_int ${UPLOAD_MAX_FILESIZE::-1} ; then warn "Wrong value for upload_max_filesize was given. Reenter again" UPLOAD_MAX_FILESIZE="" fi done ## - php.ini: post_max_size if [ -f "/usr/local/php-${PHP_MAIN_VERSION}/etc/php.ini" ]; then __post_max_size=$(grep -e "^\s*post_max_size" /usr/local/php-${PHP_MAIN_VERSION}/etc/php.ini | awk '{print$3}') if [ -n "$__post_max_size" ] ; then _POST_MAX_SIZE=$__post_max_size fi fi POST_MAX_SIZE="" while [[ "X$POST_MAX_SIZE" = "X" ]]; do echononl "post_max_size - Append unit \"K\", \"M\" or \"G\" [$_POST_MAX_SIZE] " read POST_MAX_SIZE if [ "X$POST_MAX_SIZE" = "X" ]; then POST_MAX_SIZE=$_POST_MAX_SIZE fi if is_int $POST_MAX_SIZE ; then POST_MAX_SIZE="${POST_MAX_SIZE}M" warn "No unit was given. So I apaended \"M\": post_max_size: $POST_MAX_SIZE" continue fi _unit="${POST_MAX_SIZE: -1}" if [[ "$_unit" != "K" ]] && [[ "$_unit" != "M" ]] && [[ "$_unit" != "G" ]]; then warn "Wrong unit was given for post_max_size. Reenter again" POST_MAX_SIZE="" continue fi if ! is_int ${POST_MAX_SIZE::-1} ; then warn "Wrong value for post_max_size was given. Reenter again" POST_MAX_SIZE="" fi done 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-$PHP_MAIN_VERSION will be set." else OK="" while [ "X$OK" = "X" ] do echononl "Set symlink /usr/local/php -> /usr/local/php-$PHP_MAIN_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-${PHP_MAIN_VERSION} ] ; then SYMLINK_PHP_MAIN_VERSION=true echo "Symlink /usr/local/php-$PHP_MAIN_VERSION -> `basename $PREFIX_PHP` will be set." else OK="" while [ "X$OK" = "X" ]; do echononl "Set symlink /usr/local/php-$PHP_MAIN_VERSION -> `basename $PREFIX_PHP` ? [ $_SYMLINK_PHP_MAIN_VERSION ]: " read OK __to_lower=`echo $OK | tr '[:upper:]' '[:lower:]' | tr -d ' '` if [ "X$OK" = "X" ]; then OK=$_SYMLINK_PHP_MAIN_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_MAIN_VERSION=true else SYMLINK_PHP_MAIN_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-${PHP_MAIN_VERSION}-fpm.pid FPM_SYSTEMD_FILE=/etc/systemd/system/php-${PHP_MAIN_VERSION}-fpm.service FPM_INIT_SCRIPT=/etc/init.d/php-${PHP_MAIN_VERSION}-fpm FPM_LOG_DIR=/var/log/php-${PHP_MAIN_VERSION}-fpm FPM_ERROR_LOG=${FPM_LOG_DIR}/fpm-${PHP_MAIN_VERSION}-error.log FPM_POOL_CONF_DIR=fpm.d FPM_DEFAULT_POOL=www-${PHP_MAIN_VERSION} FPM_DEFAULT_POOL_USER=$_PHP_FPM_USER FPM_DEFAULT_POOL_GROUP=$_PHP_FPM_GROUP FPM_DEFAULT_POOL_LISTEN=/tmp/php-${PHP_MAIN_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-${PHP_MAIN_VERSION}" FPM_DEFAULT_POOL_PING_PATH="/ping-${PHP_MAIN_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 -e "\033[32m--\033[m" echo "" echo -e "Skip updating file name database (used by 'locate') [ \033[33myes/no\033[m ]" echo "" echo "" SKIP_UPDATE_DB="" while [[ "X$SKIP_UPDATE_DB" = "X" ]] ; do echononl "Skip updating file name database ? [ $_SKIP_UPDATE_DB ]: " read SKIP_UPDATE_DB __to_lower="$(echo $SKIP_UPDATE_DB | tr '[:upper:]' '[:lower:]' | tr -d ' ')" if [[ "X$SKIP_UPDATE_DB" = "X" ]]; then SKIP_UPDATE_DB="$_SKIP_UPDATE_DB" break fi if [ "$__to_lower" = "yes" -o "$__to_lower" = "no" ]; then SKIP_UPDATE_DB=$__to_lower break fi echo "" echo -e "\t\033[31mWrong entry !! Try again..\033[m" echo "" SKIP_UPDATE_DB= done if [[ "$SKIP_UPDATE_DB" = "yes" ]] ; then SKIP_UPDATE_DB=true else SKIP_UPDATE_DB=false fi 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 "OS distribution...............: $os_dist" echo "OS version....................: $os_version (${os_codename})" echo "" echo "PHP version...................: $VERSION" echo "PHP main version..............: $PHP_MAIN_VERSION" echo "PHP major version.............: $PHP_MAJOR_VERSION" echo "PHP minor version.............: $PHP_MINOR_VERSION" echo "PHP patch level...............: $PHP_PATCH_LEVEL" 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_MAIN_VERSION -o $SYMLINK_PHP ; then echo "Set symlniks:" if $SYMLINK_PHP ; then echo " /usr/local/php -> /usr/local/php-$PHP_MAIN_VERSION" fi if $SYMLINK_PHP_MAIN_VERSION ; then echo " /usr/local/php-$PHP_MAIN_VERSION -> `basename $PREFIX_PHP`" fi fi echo "" echo "Skip 'updatedb'...............: $SKIP_UPDATE_DB" 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 ## - Set Symlink ## - /usr/include/x86_64-linux-gnu/curl -> /usr/include/curl ## - if not exists ## - if [[ -d "/usr/include/x86_64-linux-gnu/curl" ]] && [[ ! -e "/usr/include/curl" ]] ; then echononl "\tSet Symlink /usr/include/x86_64-linux-gnu/curl.." ln -s x86_64-linux-gnu/curl /usr/include/curl if [ "$?" = "0" ]; then echo_ok else echo_failed warn "Cannot set Symlink /usr/include/x86_64-linux-gnu/curl -> /usr/include/curl" fi echo "" fi ## - Disable crontab for user root ## - _crontab_found=false echononl "\tBackup crontab" crontab -u root -l >> $_CRONTAB_BAKUP_FILE 2> $tmp_err_msg if [ "$?" = "0" ]; then echo_ok _crontab_found=true else if [[ ! -s "$_CRONTAB_BAKUP_FILE" ]] ; then echo_skipped warn "No crontab for user 'root'found." else echo_failed error "$(cat $tmp_err_msg)" fi fi if $_crontab_found ; then echononl "\tDisable crontab for user root" crontab -r -u root >> ${_logdir}/main.log 2>&1 if [ "$?" = "0" ]; then echo_ok else echo_failed fi 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://de2.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 "\tApply patch to compile against OpenSSL 1.1.." if [[ "$os_dist" = "debian" ]] && [[ $os_version -gt 8 ]] && [[ $PHP_MAJOR_VERSION -eq 7 ]] && [[ "$PHP_MINOR_VERSION" -eq 6 ]]; then if [[ -f ${_srcdir}/PHP-5.6.31-OpenSSL-1.1.0-compatibility-20170801.patch ]] ; then patch -d $_builddir -p1 < ${_srcdir}/PHP-5.6.31-OpenSSL-1.1.0-compatibility-20170801.patch > $tmp_err_msg 2>&1 if [[ $? -eq 0 ]]; then echo_ok else echo_failed fatal "$(cat $tmp_err_msg)" fi else echo_failed fatal "Can't find patchfile '${_srcdir}/PHP-5.6.31-OpenSSL-1.1.0-compatibility-20170801.patch'" fi else echo_skipped 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-config-file-path=${PREFIX_PHP}/etc \ --with-zlib-dir \ --with-freetype-dir \ --enable-fpm \ --enable-mbstring \ --with-libxml-dir=/usr \ --enable-soap \ --enable-calendar \ --with-curl=/usr/local/curl \ --with-mcrypt \ --with-zlib \ --with-gd \ --disable-rpath \ --enable-inline-optimization \ --with-bz2 \ --with-zlib \ --enable-sockets \ --enable-sysvsem \ --enable-sysvshm \ --enable-mbregex \ --with-mhash \ --enable-zip \ --with-pcre-regex \ --with-mysql \ --with-pdo-mysql \ --with-mysqli \ --with-jpeg-dir=/usr \ --with-png-dir=/usr \ --enable-gd-native-ttf \ --enable-cgi \ --with-pear \ --enable-memcache \ --with-openssl=/usr/local/openssl \ --with-imap=/usr/local/imap-2007f \ --with-kerberos \ --with-imap-ssl \ --with-libdir=lib/x86_64-linux-gnu" # - [x]: works # - [-]; does not work # - # - [x] --with-gd # - [x] --with-mysql-sock # - [x] --enable-wddx # - [x] --with-gdbm # - [x] --enable-dba # - [x] --with-xpm-dir # - [x] --enable-ftp # - [x] --with-gmp # - [x] --with-readline # - [x] --with-gettext # - [x] --with-pspell # - [x] --enable-bcmath # - [x] --enable-intl # - [x] --enable-shmop # - [x] --enable-sysvmsg # - [x] --enable-pcntl # - [x] --with-ldap # - [x] --with-xsl # - [-] --with-vpx-dir # - [x] --with-pgsql # - [x] --with-pdo-pgsql config_params="$config_params \ --with-gd \ --with-mysql-sock \ --enable-wddx \ --with-gdbm \ --enable-dba \ --with-xpm-dir \ --enable-ftp \ --with-gmp \ --with-readline \ --with-gettext \ --with-pspell \ --enable-bcmath \ --enable-intl \ --with-pgsql \ --with-pdo-pgsql" # - Does not work: echo "LDFLAGS=\"-Wl,-rpath=/usr/local/openssl/lib,-rpath=/usr/local/curl/lib\" \\ ./configure $config_params" > ${_logdir}/php-configure.log echo "" >> ${_logdir}/php-configure.log LDFLAGS="-Wl,-rpath=/usr/local/openssl/lib,-rpath=/usr/local/curl/lib" \ ./configure $config_params >> ${_logdir}/php-configure.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.." echo "LDFLAGS=\"-Wl,-rpath=/usr/local/openssl/lib,-rpath=/usr/local/curl/lib\" make" > ${_logdir}/php-make.log LDFLAGS="-Wl,-rpath=/usr/local/openssl/lib,-rpath=/usr/local/curl/lib" 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 [[ "$PHP_MAIN_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-$PHP_MAIN_VERSION" if [ -L /usr/local/php ];then rm -f /usr/local/php fi ln -s php-$PHP_MAIN_VERSION /usr/local/php if [ "$?" = "0" ]; then echo_ok else echo_failed fi fi if $SYMLINK_PHP_MAIN_VERSION ; then echononl "\tSet symlink /usr/local/php-$PHP_MAIN_VERSION -> `basename $PREFIX_PHP`" if [ -h /usr/local/php-${PHP_MAIN_VERSION} ] ; then rm -f /usr/local/php-${PHP_MAIN_VERSION} fi ln -s `basename $PREFIX_PHP` /usr/local/php-$PHP_MAIN_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/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-${PHP_MAIN_VERSION}-fpm.service > /dev/null 2>&1 ; then echononl "\tStop service php-${PHP_MAIN_VERSION}-fpm" systemctl stop php-${PHP_MAIN_VERSION}-fpm.service > /dev/null 2>&1 if [ "$?" = "0" ]; then echo_ok else echo_failed error "Stopping Service \"php-${PHP_MAIN_VERSION}-fpm\" failed!" fi echononl "\tDisable service php-${PHP_MAIN_VERSION}-fpm" systemctl disable php-${PHP_MAIN_VERSION}-fpm.service > /dev/null 2>&1 if [ "$?" = "0" ]; then echo_ok else echo_failed error "Disabling Service \"php-${PHP_MAIN_VERSION}-fpm\" failed!" fi fi # if systemctl is-enabled php-${PHP_MAIN_VERSION}-fpm.service echononl "\tRemove existing service file \"php-${PHP_MAIN_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-${PHP_MAIN_VERSION}-fpm.service (PrivateTmp=false)" sed -i -r -e "s#(Description.*)#\1 v${PHP_MAIN_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-${PHP_MAIN_VERSION}-fpm.service occured!" else echo_ok fi echononl "\tReload systemd.." systemctl daemon-reload > /dev/null 2>&1 if [ "$?" = "0" ]; then echo_ok else echo_failed error "Reloading systemd.. failed!" fi echononl "\tEnable Service \"php-${PHP_MAIN_VERSION}-fpm.service\".." systemctl enable "php-${PHP_MAIN_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 "${PHP_MAIN_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 "${PHP_MAIN_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 "${PHP_MAIN_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-${PHP_MAIN_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-${PHP_MAIN_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-${PHP_MAIN_VERSION}-fpm" ]; then cat < /etc/logrotate.d/php-${PHP_MAIN_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).." if $SKIP_UPDATE_DB ; then echo_skipped else updatedb > /dev/null 2>&1 if [ "$?" = "0" ]; then echo_ok else echo_failed fi fi ## - PHP Extensions ## - echo "" echo "" echo -e "\t---" echo -e "\t--- Install PHP extensions" echo -e "\t---" echo "" ## ----- ## - Update Channel 'pecl.php.net' ## ----- echononl "\tUpdate Channel 'pecl.php.net' .." ${PREFIX_PHP}/bin/pecl channel-update pecl.php.net > /dev/null 2>&1 if [[ $? -eq 0 ]] ; then echo_ok else echo_failed fi ## ----- ## - END: Update Channel 'pecl.php.net' ## ----- ## ----- ## - 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.." if [[ $PHP_MAJOR_VERSION -lt 7 ]] ; then 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 else echo_skipped warn "Pecl extension 'uploadprogress' is only available for PHP versions < 7 - version 7 also excluded." 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 uri_template - !! only versions <= 5.6 ## ----- echononl "\tInstall uri_template via pecl.." if [[ $PHP_MAJOR_VERSION -lt 7 ]] ; then printf "\n" | ${PREFIX_PHP}/bin/pecl install uri_template > /dev/null 2>&1 if [ "$?" = "0" ]; then echo_ok echononl "\tphp.ini: extension=uri_template.so .." _extension="uri_template.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 echo_skipped warn "Pecl extension 'uri_template' is only available for PHP versions < 7 - version 7 also excluded." fi ## ----- ## - Install APCu ## ----- echononl "\tInstall APCu via pecl.." if [[ $PHP_MAJOR_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 [[ $PHP_MAJOR_VERSION -lt 7 ]] ; then printf "no --disable-memcached-sasl\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=memcached.so .." _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 "\tRemove broken link '/usr/bin/MagickWand-config'" if [[ -h "/usr/bin/MagickWand-config" ]]; then rm /usr/bin/MagickWand-config if [[ $? -eq 0 ]]; then echo_ok else echo_failed fi else echo_skipped fi 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 mcrypt ## ----- ## - since php version 7.2: mcrypt was moved to PECL ## - if ([[ "$PHP_MAJOR_VERSION" -eq 7 ]] && [[ "$PHP_MINOR_VERSION" -ge 2 ]]) \ || [[ "$PHP_MAJOR_VERSION" -gt 7 ]] ; then echononl "\tInstall mcrypt via pecl.." _success=true printf "\n" | ${PREFIX_PHP}/bin/pecl install mcrypt > /dev/null 2>&1 if [[ $? -eq 0 ]]; then echo_ok else echo_failed echononl "\tTry to install mcrypt verision 1.0.1" printf "\n" | ${PREFIX_PHP}/bin/pecl install mcrypt-1.0.1 > /dev/null 2>&1 if [[ $? -eq 0 ]]; then echo_ok else echo_failed _success=false fi fi echononl "\tphp.ini: extension=mcrypt.so .." if $_success ; then _extension="mcrypt.so" perl -i -n -p -e "s#^(\s*\[PHP\]\s*)#\1\nextension=${_extension}\n#" $PHP_INI_FILE if [[ $? -eq 0 ]] ; then echo_ok else echo_failed fi else echo_skipped fi fi ## ----- ## - END: Install mcrypt ## ----- ## ----- ## - 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 [[ "$PHP_MAIN_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 echononl "\tInstall (beta) xdebug-2.6.0beta1 via pecl.." ${PREFIX_PHP}/bin/pecl install xdebug-2.6.0beta1 > /dev/null 2>&1 if [ "$?" = "0" ]; then echo_ok else echo_failed fi fi #if $WITHOUT_APACHE_MOD_PHP ; then # zend_extension_xdebug=`find /usr/local/php-${PHP_MAIN_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.." if [[ "$PHP_MAIN_VERSION" = "5.4" ]]; then ${PREFIX_PHP}/bin/pear install Net_Socket-1.0.14 > /dev/null 2>&1 else ${PREFIX_PHP}/bin/pear install Net_Socket > /dev/null 2>&1 fi if [ "$?" = "0" ]; then echo_ok else echo_failed fi echononl "\tInstall Net_SMTP via pear.." if [[ "$PHP_MAIN_VERSION" = "5.4" ]]; then ${PREFIX_PHP}/bin/pear install Net_SMTP-1.7.2 > /dev/null 2>&1 else ${PREFIX_PHP}/bin/pear install Net_SMTP > /dev/null 2>&1 fi if [ "$?" = "0" ]; then echo_ok else echo_failed fi echononl "\tInstall Net_Sieve via pear.." if [[ "$PHP_MAIN_VERSION" = "5.4" ]]; then ${PREFIX_PHP}/bin/pear install Net_Sieve-1.4.1 > /dev/null 2>&1 else ${PREFIX_PHP}/bin/pear install Net_Sieve > /dev/null 2>&1 fi 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.." if [[ "$PHP_MAIN_VERSION" = "5.4" ]]; then ${PREFIX_PHP}/bin/pear install Auth_SASL-1.0.6 > /dev/null 2>&1 else ${PREFIX_PHP}/bin/pear install Auth_SASL > /dev/null 2>&1 fi 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 if [[ ! -d "$(dirname "$_val")" ]] ; then echononl "\tCretae directory '$(dirname "$_val")'.." mkdir "$(dirname "$_val")" > /dev/null 2>&1 if [[ $? -eq 0 ]] ; then echo_ok else echo_failed fi 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 ## - set expose_php = Off ## - _key="expose_php" _val="Off" echononl "\tphp.ini: $_key = $_val" 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 if [[ ! -d "$(dirname "$_val")" ]] ; then echononl "\tCretae directory '$(dirname "$_val")'.." mkdir "$(dirname "$_val")" > /dev/null 2>&1 if [[ $? -eq 0 ]] ; then echo_ok else echo_failed fi 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=1 ## - echononl "\tphp.ini: opcache.enable_cli = 1 .." opcache_key="opcache.enable_cli" 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.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 = 10000 .." opcache_key="opcache.max_accelerated_files" opcache_val=10000 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.memory_consumption=128 ## - echononl "\tphp.ini: opcache.memory_consumption = 1 .." opcache_key="opcache.memory_consumption" opcache_val=128 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.save_comments=1 ## - echononl "\tphp.ini: opcache.save_comments = 1 .." opcache_key="opcache.save_comments" 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=1 ## - echononl "\tphp.ini: opcache.revalidate_freq = 1 .." opcache_key="opcache.revalidate_freq" 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.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 ## ----- ## ----- ## - Reenable crontab ## ----- echo echononl "\tReenable crontab for user root .." crontab -u root $_CRONTAB_BAKUP_FILE > $tmp_err_msg 2>&1 if [ "$?" = "0" ]; then echo_ok else echo_failed error "$(cat $tmp_err_msg)" fi echononl "Remove crontab backup file .." rm -f $_CRONTAB_BAKUP_FILE > $tmp_err_msg 2>&1 if [ "$?" = "0" ]; then echo_ok else echo_failed error "$(cat $tmp_err_msg)" fi ## ----- ## - End: Reenable crontab ## ----- ## ----- ## - Start PHP-FPM Engine if requested ## ----- echo "" echononl "\tStarting PHP-FPM Engine (v${PHP_MAIN_VERSION}).." if $ACTIVATE_PHP_FPM_INIT_SCRIPT ; then if $SYSTEMD_EXISTS ; then systemctl start php-${PHP_MAIN_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<