#!/usr/bin/env bash # php ( fuer Apache 2 ) # _VERSION=5.5.30 #WITHOUT_APACHE_MOD_PHP=true _APACHE_MOD_PHP=no _APACHE_VERSION=2.4.17 _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 && $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<