Support PHP installed from Debian Packages System.

This commit is contained in:
Christoph 2017-11-06 04:24:52 +01:00
parent 7427ebec6b
commit 186d3b94d5
3 changed files with 136 additions and 31 deletions

View File

@ -47,7 +47,7 @@ IPV6=""
# - Note: it's not the 'DocumentRoot' directory, but the directory where # - Note: it's not the 'DocumentRoot' directory, but the directory where
# - the 'DocumentRoot' Directory lives. # - the 'DocumentRoot' Directory lives.
# - # -
# - Defaults to '/var/www/webmail/$WEBSITE_NAME' # - Defaults to '/var/www/$WEBSITE_NAME'
# - # -
#WEBSITE_BASEDIR="" #WEBSITE_BASEDIR=""
@ -100,6 +100,15 @@ IPV6=""
# - # -
#CERT_ChainFile="" #CERT_ChainFile=""
# - Is PHP installed from debian package system ?
# -
# - Boolean, possible values are 'true', 'false'
# -
# - Defaults to 'false'
#
#PHP_DEBIAN_INSTALLATION=""
# - Type of PHP installation. # - Type of PHP installation.
# - # -
# - Possible values are: 'php_fpm' , 'fcgid' , 'mod_php # - Possible values are: 'php_fpm' , 'fcgid' , 'mod_php

View File

@ -157,6 +157,7 @@ MAIN_DOMAIN=${_tmp_string##*.}
[[ -n "$IPV6" ]] || fatal "IPv4 Address (IPV6) not present!" [[ -n "$IPV6" ]] || fatal "IPv4 Address (IPV6) not present!"
[[ -n "$APACHE_DEBIAN_INSTALLATION" ]] || APACHE_DEBIAN_INSTALLATION=false [[ -n "$APACHE_DEBIAN_INSTALLATION" ]] || APACHE_DEBIAN_INSTALLATION=false
[[ -n "$PHP_DEBIAN_INSTALLATION" ]] || PHP_DEBIAN_INSTALLATION=false
httpd_binary="`which httpd`" httpd_binary="`which httpd`"
if [ -z "$httpd_binary" ]; then if [ -z "$httpd_binary" ]; then
@ -305,7 +306,10 @@ fi
# - # -
echononl "\tGet major version of latest installed PHP version" echononl "\tGet major version of latest installed PHP version"
php_latest_ver="" php_latest_ver=""
if [[ -n "$php_major_versions" ]]; then if $PHP_DEBIAN_INSTALLATION ; then
echo_skipped
else
if [[ -n "$php_major_versions" ]]; then
for _ver in $php_major_versions ; do for _ver in $php_major_versions ; do
if [[ -z "$php_latest_ver" ]] ; then if [[ -z "$php_latest_ver" ]] ; then
php_latest_ver=$_ver php_latest_ver=$_ver
@ -316,9 +320,10 @@ if [[ -n "$php_major_versions" ]]; then
fi fi
done done
echo_ok echo_ok
else else
echo_skipped echo_skipped
warn "Getting major version of latest installed PHP version failed! - No installed PHP versiond found!" warn "Getting major version of latest installed PHP version failed! - No installed PHP versiond found!"
fi
fi fi
echo "" echo ""
@ -445,9 +450,36 @@ fi
## - ## -
## - !! Take care to do this for all php installations (PHP 5.5/5.6/..) ## - !! Take care to do this for all php installations (PHP 5.5/5.6/..)
## - ## -
for _version in $php_major_versions ; do echo -e "\n\n\t\033[37m\033[1mInstall modules for PHP Version ${_version}..\033[m\n"
if $PHP_DEBIAN_INSTALLATION ; then
echo -e "\n\n\t\033[37m\033[1mInstall modules for PHP Version ${_version}..\033[m\n" for _module in $needed_php_pear_modules ; do
echononl "\tInstall Module '$_module'.."
if ! pear list | grep -q "$_module" 2> /dev/null ; then
pear install $_module > $log_file 2>&1
if [[ "$?" = "0" ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
if [[ "$_module" = "Net_IDNA2" ]]; then
echononl "\tInstall (beta) Net_IDNA2-0.1.1 .."
pear install channel://pear.php.net/Net_IDNA2-0.1.1 > $log_file 2>&1
if [ "$?" = "0" ]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
fi
fi
fi
else
echo_skipped
fi
done
else
for _version in $php_major_versions ; do
for _module in $needed_php_pear_modules ; do for _module in $needed_php_pear_modules ; do
echononl "\tInstall Module '$_module'.." echononl "\tInstall Module '$_module'.."
@ -473,7 +505,8 @@ for _version in $php_major_versions ; do
echo_skipped echo_skipped
fi fi
done done
done done
fi
echo -e "\n\n\t\033[37m\033[1mInstall (global) composer..\033[m\n" echo -e "\n\n\t\033[37m\033[1mInstall (global) composer..\033[m\n"
@ -639,10 +672,15 @@ fi
echononl "\tInstall PHP dependencies.." echononl "\tInstall PHP dependencies.."
#/usr/local/php-${php_latest_ver}/bin/php /usr/local/bin/composer install --no-dev if $PHP_DEBIAN_INSTALLATION ; then
su www-data -c"cd ${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION} su ${HTTP_USER} -c"cd ${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}
php /usr/local/bin/composer install --no-dev" -s /bin/bash \
> $log_file 2>&1
else
su ${HTTP_USER} -c"cd ${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}
/usr/local/php-${php_latest_ver}/bin/php /usr/local/bin/composer install --no-dev" -s /bin/bash \ /usr/local/php-${php_latest_ver}/bin/php /usr/local/bin/composer install --no-dev" -s /bin/bash \
> $log_file 2>&1 > $log_file 2>&1
fi
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
echo_ok echo_ok
else else
@ -1253,7 +1291,16 @@ elif [[ "$PHP_TYPE" = "php_fpm" ]]; then
DocumentRoot "${WEBSITE_BASEDIR}/htdocs/" DocumentRoot "${WEBSITE_BASEDIR}/htdocs/"
<FilesMatch \.php$> <FilesMatch \.php$>
EOF
if $PHP_DEBIAN_INSTALLATION ; then
cat <<EOF >> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file
SetHandler "proxy:unix:/var/run/php5-fpm.sock|fcgi://127.0.0.1"
EOF
else
cat <<EOF >> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file
SetHandler "proxy:unix:/tmp/php-${php_latest_ver}-fpm.www.sock|fcgi://127.0.0.1" SetHandler "proxy:unix:/tmp/php-${php_latest_ver}-fpm.www.sock|fcgi://127.0.0.1"
EOF
cat <<EOF >> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file
</FilesMatch> </FilesMatch>
<IfModule dir_module> <IfModule dir_module>
@ -1506,7 +1553,16 @@ elif [[ "$PHP_TYPE" = "php_fpm" ]]; then
DocumentRoot "${WEBSITE_BASEDIR}/htdocs/" DocumentRoot "${WEBSITE_BASEDIR}/htdocs/"
<FilesMatch \.php$> <FilesMatch \.php$>
EOF
if $PHP_DEBIAN_INSTALLATION ; then
cat <<EOF >> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file
SetHandler "proxy:unix:/var/run/php5-fpm.sock|fcgi://127.0.0.1"
EOF
else
cat <<EOF >> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file
SetHandler "proxy:unix:/tmp/php-${php_latest_ver}-fpm.www.sock|fcgi://127.0.0.1" SetHandler "proxy:unix:/tmp/php-${php_latest_ver}-fpm.www.sock|fcgi://127.0.0.1"
EOF
cat <<EOF >> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file
</FilesMatch> </FilesMatch>
<IfModule dir_module> <IfModule dir_module>

View File

@ -354,19 +354,23 @@ fi
# - Determin PHP of all installed versions # - Determin PHP of all installed versions
# - # -
echononl "\tGet major version of all installed PHP versions" echononl "\tGet major version of all installed PHP versions"
php_major_versions="$(find /usr/local/ -maxdepth 1 -mindepth 1 -type l -name "php-*" -print | cut -d "-" -f2 | sort)" if $PHP_DEBIAN_INSTALLATION ; then
if [[ -z "$php_major_versions" ]]; then echo_skipped
else
php_major_versions="$(find /usr/local/ -maxdepth 1 -mindepth 1 -type l -name "php-*" -print | cut -d "-" -f2 | sort)"
if [[ -z "$php_major_versions" ]]; then
echo_failed echo_failed
error "Getting version numbers of installed PHP versions failed! No installed PHP versiond found!" error "Getting version numbers of installed PHP versions failed! No installed PHP versiond found!"
else else
echo_ok echo_ok
fi
fi fi
# - Stop all PHP FPM engines # - Stop all PHP FPM engines
# - # -
echononl " Stop PHP FPM engine v${_ver}.."
if [[ -n "$php_major_versions" ]]; then if [[ -n "$php_major_versions" ]]; then
for _ver in $php_major_versions ; do for _ver in $php_major_versions ; do
echononl " Stop PHP FPM engine v${_ver}.."
if [[ -f "/etc/init.d/php-${_ver}-fpm" ]]; then if [[ -f "/etc/init.d/php-${_ver}-fpm" ]]; then
/etc/init.d/php-${_ver}-fpm stop > $log_file 2>&1 /etc/init.d/php-${_ver}-fpm stop > $log_file 2>&1
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
@ -387,6 +391,24 @@ if [[ -n "$php_major_versions" ]]; then
echo_skipped echo_skipped
fi fi
done done
else
if $PHP_DEBIAN_INSTALLATION ; then
if [[ -f "/etc/init.d/php5-fpm" ]] ; then
/etc/init.d/php5-fpm stop > $log_file 2>&1
elif [[ -f "/etc/init.d/php7-fpm" ]] ; then
/etc/init.d/php7-fpm stop > $log_file 2>&1
else
echo_skipped
fi
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
fi
else
echo_skipped
fi
fi fi
echo -e "\n\n \033[37m\033[1mUgrade Roundcube Webmail..\033[m\n" echo -e "\n\n \033[37m\033[1mUgrade Roundcube Webmail..\033[m\n"
@ -524,6 +546,24 @@ if [[ -n "$php_major_versions" ]]; then
echo_skipped echo_skipped
fi fi
done done
else
if $PHP_DEBIAN_INSTALLATION ; then
if [[ -f "/etc/init.d/php5-fpm" ]] ; then
/etc/init.d/php5-fpm start > $log_file 2>&1
elif [[ -f "/etc/init.d/php7-fpm" ]] ; then
/etc/init.d/php7-fpm start > $log_file 2>&1
else
echo_skipped
fi
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
fi
else
echo_skipped
fi
fi fi
# - Start Apache Webserver # - Start Apache Webserver