From 79b141353bb8e32c2adacff9bf532f542427d11e Mon Sep 17 00:00:00 2001 From: Christoph Date: Tue, 24 Oct 2023 22:29:16 +0200 Subject: [PATCH] mod_php_install.sh: support php 5.6 at debian 12 (bookworm). --- mod_php_install.sh | 579 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 573 insertions(+), 6 deletions(-) diff --git a/mod_php_install.sh b/mod_php_install.sh index fa57a2e..e38d550 100755 --- a/mod_php_install.sh +++ b/mod_php_install.sh @@ -7,6 +7,8 @@ _VERSION= _FREETYPE_VERSION="2.10.4" _ICU4C_VERSION="57-2" _LIBXML2_VERSION="2.9.4" +_PYTHON2_VERSION="2.7.16" +_OPENSSL1_VERSION="1.1.1w" #WITHOUT_APACHE_MOD_PHP=true _APACHE_MOD_PHP=no @@ -408,14 +410,22 @@ else unset MAKEFLAGS fi -if [[ "$PHP_MAIN_VERSION" = "5.6" ]] && [[ $os_version -gt 9 ]]; then - #if [[ -e "/usr/local/libxml2" ]]; then +if [[ "$PHP_MAIN_VERSION" = "5.6" ]] && [[ $os_version -gt 11 ]]; then + + warn "For php version 5.6 at debian 12 and above, you need manual installation of + +\t freetype (libfreetype6-dev) +\t libxml2 +\t icu4c (libicu) +\t openssl v 1.1.1 " + +elif [[ "$PHP_MAIN_VERSION" = "5.6" ]] && [[ $os_version -gt 9 ]]; then + warn "For php version 5.6 at debian 10 and above, you need manual installation of -\t freetype (libfreetype6-dev) -\t libxml2 +\t freetype (libfreetype6-dev) +\t libxml2 \t icu4c (libicu)" - #fi fi echo "" @@ -1843,6 +1853,8 @@ fi _install_freetype=false _install_icu4c=false _install_libxml2=false +_install_python2=false +_install_openssl1=false if ([[ "$PHP_MAJOR_VERSION" -eq 7 ]] && [[ "$PHP_MINOR_VERSION" -lt 4 ]]) \ || [[ "$PHP_MAJOR_VERSION" -lt 7 ]] ; then @@ -1940,6 +1952,66 @@ if ([[ "$PHP_MAJOR_VERSION" -eq 7 ]] && [[ "$PHP_MINOR_VERSION" -lt 4 ]]) \ _install_libxml2=true + if [[ "$os_dist" = "debian" ]] && [[ $os_version -gt 11 ]] ; then + + echo "" + echo "" + echo -e "\033[32m--\033[m" + echo "" + echo "The libxml2 library, which we need to install separately, requires python 2." + echo -e "" + echo -e "Which version of libxml2 should be installed?" + echo "" + PYTHON2_VERSION= + if [[ -n "$_PYTHON2_VERSION" ]]; then + echononl "Python 2 Version [${_PYTHON2_VERSION}]: " + read PYTHON2_VERSION + if [[ "X$PYTHON2_VERSION" = "X" ]] ; then + PYTHON2_VERSION="$_PYTHON2_VERSION" + fi + else + echononl "Python 2 Version: " + read PYTHON2_VERSION + while [[ "X$PYTHON2_VERSION" = "X" ]]; do + echo -e "\n \033[33m\033[1Python 2 Version must not be empty!\033[m\n" + echononl "Python 2 Version : " + read PYTHON2_VERSION + done + fi + + _install_python2=true + + echo "" + echo "" + echo -e "\033[32m--\033[m" + echo "" + echo "We need to install openssl version 1" + echo -e "" + echo -e "Which version of openssl should be installed?" + echo "" + OPENSSL1_VERSION= + if [[ -n "$_OPENSSL1_VERSION" ]]; then + echononl "OpenSSL Version [${_OPENSSL1_VERSION}]: " + read OPENSSL1_VERSION + if [[ "X$OPENSSL1_VERSION" = "X" ]] ; then + OPENSSL1_VERSION="$_OPENSSL1_VERSION" + fi + else + echononl "OpenSSL Version: " + read OPENSSL1_VERSION + while [[ "X$OPENSSL1_VERSION" = "X" ]]; do + echo -e "\n \033[33m\033[1OpenSSL Version must not be empty!\033[m\n" + echononl "OpenSSL Version: " + read OPENSSL1_VERSION + done + fi + + _install_openssl1=true + + fi + + + fi # if [[ "$PHP_MAJOR_VERSION" -lt 7 ]] fi # if [[ "$os_dist" = "debian" ]] && [[ $os_version -eq 10 ]] @@ -2119,6 +2191,16 @@ if $_install_libxml2 ; then echo " libxml2 version ..................: $LIBXML2_VERSION" fi echo "" +echo "Install extern python 2..............: $_install_python2" +if $_install_python2 ; then + echo " python 2 version..................: $PYTHON2_VERSION" +fi +echo "" +echo "Install extern OpenSSL...............: $_install_openssl1" +if $_install_python2 ; then + echo " OpenSSL version...................: $OPENSSL1_VERSION" +fi +echo "" echo "Skip 'updatedb'......................: $SKIP_UPDATE_DB" echo "" echo "" @@ -2737,6 +2819,228 @@ EOF fi +if $_install_python2 && [[ ! -d /usr/local/python-$PYTHON2_VERSION ]]; then + + ## - Install python 2' + ## - + echo "" + echo "" + echo -e "\t---" + echo -e "\t--- Install python 2" + echo -e "\t---" + echo "" + + # https://www.python.org/ftp/python/2.7.16/Python-2.7.16.tgz + python2_archive="Python-${PYTHON2_VERSION}.tgz" + python2_download_url="https://www.python.org/ftp/python/${PYTHON2_VERSION}" + + _src_dir_python2="/usr/local/src/python2" + _build_dir_python2="${_src_dir_python2}/Python-${PYTHON2_VERSION}" + + echononl "\tCreate source directory '$_src_dir_python2'.." + if [[ ! -d "$_src_dir_python2" ]]; then + mkdir "$_src_dir_python2" >> ${_logdir}/main.log 2>&1 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "Cannot create directory '$_src_dir_python2'" + + echo "" + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interupted by user" + fi + else + echo_skipped + fi + + cd "$_src_dir_python2" + + echononl "\tGet source $python2_archive .." + if [[ ! -f ${_src_dir_python2}/$python2_archive ]]; then + wget -O "${_src_dir_python2}/$python2_archive" \ + ${python2_download_url} \ + >> ${_logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Cannot Download '$python2_archive'" + + echo "" + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interupted by user" + fi + else + echo_skipped + fi + + _backup_dir="$_build_dir_python2" + echononl "\tBackup existing directory '${_backup_dir}'.." + if [[ -d "${_backup_dir}" ]]; then + mv "${_backup_dir}" "${_backup_dir}.$_backup_date" > /dev/null 2> $tmp_err_msg + if [[ $? -eq 0 ]] ; then + echo_ok + else + echo_failed + error "$(cat $tmp_err_msg)" + + echo "" + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interupted by user" + fi + else + echo_skipped + fi + + echononl "\tUnpack archive \"$python2_archive\".." + gunzip < "${python2_archive}" | tar -xf - 2> $tmp_err_msg + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "$(cat $tmp_err_msg)" + + echo "" + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interupted by user" + fi + + cd "$_build_dir_python2" + + config_params="--prefix=/usr/local/python-${PYTHON2_VERSION}" + + echononl "\tGoing to configure python ${PYTHON2_VERSION} .." + ./configure $config_params >> ${_logdir}/python2-configure.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Configuring python2 failed!\n\t see ${_logdir}/python2-configure.log for more details" + + echo "" + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interupted by user" + fi + + echononl "\tGoing to compile python v${PYTHON2_VERSION} .." + make > ${_logdir}/python2-make.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Compiling python2 failed!\n\t see ${_logdir}/python2-make.log for more details" + + echo "" + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interupted by user" + fi + + _backup_dir="/usr/local/python2-${PYTHON2_VERSION}" + echononl "\tBackup existing directory '${_backup_dir}'.." + if [[ -d "${_backup_dir}" ]]; then + mv "${_backup_dir}" "${_backup_dir}.$_backup_date" > /dev/null 2> $tmp_err_msg + if [[ $? -eq 0 ]] ; then + echo_ok + else + echo_failed + error "$(cat $tmp_err_msg)" + + echo "" + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interupted by user" + fi + else + echo_skipped + fi + + echononl "\tGoing to install python v${PYTHON2_VERSION}.." + make install > ${_logdir}/python2-make_install.log 2>&1 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "Installing python 2 failed!\n\t see ${_logdir}/python2-make_install.log for more details" + + echo "" + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interupted by user" + fi + + echononl "\tSet symlink /usr/local/python2 -> /usr/local/python-$PYTHON2_VERSION .." + if [ -L /usr/local/python2 ];then + rm -f /usr/local/python2 + fi + + ln -s python-$PYTHON2_VERSION /usr/local/python2 > $tmp_err_msg 2>&1 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "$(cat $tmp_err_msg)" + + echo "" + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interupted by user" + fi + +fi + + if $_install_libxml2 && [[ ! -d /usr/local/libxml2-$LIBXML2_VERSION ]]; then ## - Install libxml2' @@ -2849,6 +3153,9 @@ if $_install_libxml2 && [[ ! -d /usr/local/libxml2-$LIBXML2_VERSION ]]; then cd "$_build_dir_libxml2" config_params="--prefix=/usr/local/libxml2-$LIBXML2_VERSION" + if $_install_python2 ; then + config_params="${config_params} --with-python=/usr/local/python2" + fi echononl "\tGoing to configure libxml2-$LIBXML2_VERSION .." ./configure $config_params >> ${_logdir}/libxml2-configure.log 2>&1 if [ "$?" = "0" ]; then @@ -2956,6 +3263,259 @@ if $_install_libxml2 && [[ ! -d /usr/local/libxml2-$LIBXML2_VERSION ]]; then fi +if $_install_openssl1 && [[ ! -d /usr/local/openssl-$OPENSSL1_VERSION ]]; then + + ## - Install OpenSSL 1' + ## - + echo "" + echo "" + echo -e "\t---" + echo -e "\t--- Install OpenSSL 1" + echo -e "\t---" + echo "" + + _NAME="openssl" + + _VERSION="${OPENSSL1_VERSION}" + + _archive_file="openssl-${_VERSION}.tgz" + _download_url="https://www.openssl.org/source/openssl-${_VERSION}.tar.gz" + + _src_dir="/usr/local/src/openssl" + _build_dir="${_src_dir}/openssl-${_VERSION}" + + _install_dir="/usr/local/openssl-${_VERSION}" + + echononl "\tCreate source directory '$_src_dir'.." + if [[ ! -d "$_src_dir" ]]; then + mkdir "$_src_dir" >> ${_logdir}/main.log 2>&1 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "Cannot create directory '$_src_dir'" + + echo "" + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interupted by user" + fi + else + echo_skipped + fi + + cd "$_src_dir" + + echononl "\tGet source $_archive_file .." + if [[ ! -f ${_src_dir}/$_archive_file ]]; then + wget -O "${_src_dir}/$_archive_file" \ + ${_download_url} \ + >> ${_logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Cannot Download '$_archive_file'" + + echo "" + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interupted by user" + fi + else + echo_skipped + fi + + _backup_dir="$_build_dir" + echononl "\tBackup existing directory '${_backup_dir}'.." + if [[ -d "${_backup_dir}" ]]; then + mv "${_backup_dir}" "${_backup_dir}.$_backup_date" > /dev/null 2> $tmp_err_msg + if [[ $? -eq 0 ]] ; then + echo_ok + else + echo_failed + error "$(cat $tmp_err_msg)" + + echo "" + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interupted by user" + fi + else + echo_skipped + fi + + echononl "\tUnpack archive \"$_archive_file\".." + gunzip < "${_archive_file}" | tar -xf - 2> $tmp_err_msg + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "$(cat $tmp_err_msg)" + + echo "" + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interupted by user" + fi + + cd "$_build_dir" + + config_params="--prefix=${_install_dir}" + + echononl "\tGoing to configure ${_NAME} ${_VERSION} .." + + if [[ -x "./config" ]] ; then + + config_params="--prefix=${_install_dir} --openssldir=${_install_dir}" + + ./config ${config_params} > ${_logdir}/${_NAME}-configure.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Configuring (Configure) ${_NAME} failed!\n\t see ${_logdir}/${_NAME}-configure.log for more details" + + echo "" + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interupted by user" + fi + else + + ./configure $config_params >> ${_logdir}/${_NAME}-configure.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Configuring ${_NAME} failed!\n\t see ${_logdir}/${_NAME}-configure.log for more details" + + echo "" + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interupted by user" + fi + + fi + + echononl "\tGoing to compile ${_NAME} ${_VERSION} .." + make > ${_logdir}/${_NAME}-make.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + error "Compiling ${_NAME} failed!\n\t see ${_logdir}/${_NAME}-make.log for more details" + + echo "" + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interupted by user" + fi + + _backup_dir="/usr/local/${_NAME}-${_VERSION}" + echononl "\tBackup existing directory '${_backup_dir}'.." + if [[ -d "${_backup_dir}" ]]; then + mv "${_backup_dir}" "${_backup_dir}.$_backup_date" > /dev/null 2> $tmp_err_msg + if [[ $? -eq 0 ]] ; then + echo_ok + else + echo_failed + error "$(cat $tmp_err_msg)" + + echo "" + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interupted by user" + fi + else + echo_skipped + fi + + echononl "\tGoing to install ${_NAME} v${_VERSION}.." + make install > ${_logdir}/${_NAME}-make_install.log 2>&1 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "Installing ${_NAME} failed!\n\t see ${_logdir}/${_NAME}-make_install.log for more details" + + echo "" + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interupted by user" + fi + + echononl "\tSet symlink /usr/local/${_NAME} -> /usr/local/${_NAME}-${_VERSION} .." + if [ -L /usr/local/${_NAME} ];then + rm -f /usr/local/${_NAME} + fi + + ln -s ${_NAME}-${_VERSION} /usr/local/${_NAME} > $tmp_err_msg 2>&1 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "$(cat $tmp_err_msg)" + + echo "" + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interupted by user" + fi + +fi + + ## - Set Symlink ## - /usr/include/x86_64-linux-gnu/gmp.h -> /usr/include/gmp.h @@ -3283,7 +3843,6 @@ config_params=" --with-mysqli=mysqlnd --enable-exif --with-zlib - --with-openssl --with-gdbm --with-curl --enable-dba @@ -3314,6 +3873,14 @@ config_params=" --enable-cgi --with-xmlrpc" +if $_install_openssl1 ; then + config_params="${config_params} + --with-openssl=/usr/local/openssl" +else + config_params="${config_params} + --with-openssl" +fi + # --with-t1lib \ # Note: