Compare commits

..

14 Commits

Author SHA1 Message Date
5ec756adec handle_domain_on_webserver.sh: change default MySQL credentials. 2024-07-05 16:00:47 +02:00
363e1176ff create_vhost.sh: Log directory in case of suexec.. 2024-04-29 17:48:03 +02:00
1488743e63 create_vhost.sh: change how determin httpd binary. 2024-04-24 16:44:22 +02:00
068c241353 Add script 'add_proxy_parameter_to_vhost_configuration.sh'. 2024-04-24 16:33:39 +02:00
5c9eae7f3e create_vhost.sh: Add Prosy parameters to vhost configuration. 2024-04-24 16:32:59 +02:00
832fe0d2d3 Add file '504-Gateway-Timeout-Error-AH01075.odt'. 2024-04-21 17:17:17 +02:00
62575a0908 create_vhost.sh: add proxy settings that fix default event mpm worker. 2024-04-21 17:06:14 +02:00
0c91a68052 handle_domain_on_webserver.sh: ignore folder 'MAINTENANCE'. 2024-01-12 14:21:51 +01:00
85c142f978 create_vhost.sh: only create 'phpinfo.php' if site supports PHP. 2023-12-28 17:49:56 +01:00
80df4e6dfc create_summary_websites.sh: Add support for PHP version 8.3; Many changes in script output. 2023-12-24 02:49:51 +01:00
98b9cfb4ed Redesign of code.. 2023-12-23 16:32:26 +01:00
a573c27a46 create_summary_websites.sh: add support fot PHP 8.2 2023-07-13 22:19:02 +02:00
eaaaa72544 Merge branch 'master' of https://git.oopen.de/script/apache2 2023-03-19 01:57:27 +01:00
1170d6559e create_vhost.sh: chnage owner of 'DocumentRoot'/'Web Base directory' only if web vase directory does not exist. 2023-03-19 01:56:59 +01:00
7 changed files with 859 additions and 108 deletions

Binary file not shown.

View File

@ -0,0 +1,465 @@
#!/usr/bin/env bash
script_name="$(basename $(realpath $0))"
working_dir="$(dirname $(realpath $0))"
conf_file="${working_dir}/conf/${script_name%%.*}.conf"
tmp_log_file="$(mktemp)"
backup_date="$(date +%Y-%m-%d-%H%M)"
# -------------
# - Variable settings
# -------------
declare -a vhost_php_fpm_file_arr=()
apache_needs_restart=false
if [[ -f "/usr/local/apache2/conf/httpd.conf" ]]; then
_HTTPD_CONF_FILE="/usr/local/apache2/conf/httpd.conf"
elif [[ -f "/etc/apache2/apache2.conf" ]]; then
_HTTPD_CONF_FILE="/etc/apache2/apache2.conf"
else
_HTTPD_CONF_FILE=''
fi
if [[ -f "${_HTTPD_CONF_FILE}" ]] && $(grep -q -i -E "^\s*Timeout\s+" "${_HTTPD_CONF_FILE}") ; then
_TIMEOUT="$(grep -i -E "^\s*timeout\s+" "${_HTTPD_CONF_FILE}"| awk '{print$2}' | head -1)"
else
_TIMEOUT=60
fi
if [[ -f "${_HTTPD_CONF_FILE}" ]] && $(grep -q -i -E "^\s*ProxyTimeout\s+" "${_HTTPD_CONF_FILE}") ; then
PROXY_TIMEOUT="$(grep -i -E "^\s*ProxyTimeout\s+" "${_HTTPD_CONF_FILE}"| awk '{print$2}' | head -1)"
else
PROXY_TIMEOUT=${_TIMEOUT}
fi
# -------------
# --- Some functions
# -------------
clean_up() {
# Perform program exit housekeeping
rm -f $tmp_log_file
exit $1
}
# - Check if a given array (parameter 2) contains a given string (parameter 1)
# -
containsElement () {
local e
for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done
return 1
}
stringContain() {
[ -z "${2##*$1*}" ] && [ -z "$1" -o -n "$2" ]
}
# - Remove leading/trailling whitespaces
# -
trim() {
local var="$*"
var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
echo -n "$var"
}
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 ""
if [[ -n "$*" ]] ; then
echo -e " [ \033[31m\033[1mFatal\033[m ]: $*"
echo ""
fi
echo -e " \033[31m\033[1mScript will be interrupted.\033[m\033[m"
echo ""
clean_up 1
}
error(){
echo ""
echo -e " [ \033[31m\033[1mFehler\033[m ]: $*"
echo ""
}
warn (){
echo ""
echo -e " [ \033[33m\033[1mWarning\033[m ]: $*"
echo ""
}
info (){
echo ""
echo -e " [ \033[32m\033[1mInfo\033[m ]: $*"
echo ""
}
echo_done() {
echo -e "\033[80G[ \033[32mdone\033[m ]"
}
echo_ok() {
echo -e "\033[80G[ \033[32mok\033[m ]"
}
echo_warning() {
echo -e "\033[80G[ \033[33m\033[1mwarn\033[m ]"
}
echo_failed(){
echo -e "\033[80G[ \033[1;31mfailed\033[m ]"
}
echo_skipped() {
echo -e "\033[80G[ \033[37mskipped\033[m ]"
}
trap clean_up SIGHUP SIGINT SIGTERM
# - Try to find apache vhost configuration directory
# -
if [[ -d "/usr/local/apache2/conf/vhosts" ]]; then
if [[ -d "/usr/local/apache2/conf/vhosts/0" ]]; then
_apache_vhost_dir="/usr/local/apache2/conf/vhosts/0"
else
_apache_vhost_dir="/usr/local/apache2/conf/vhosts"
fi
elif [[ -d "/etc/apache2/sites-enabled" ]]; then
_apache_vhost_dir="/etc/apache2/sites-enabled"
fi
clear
echo ""
echo -e "\033[32mRunning script \033[1m"$(basename $0)"\033[m .."
echo ""
echo ""
echo ""
echo -e "\033[32m--\033[m"
echo ""
echo "Insert Apache VHost directory.."
echo ""
echo ""
apache_vhost_dir=
if [ -z "$_apache_vhost_dir" ]; then
echononl "Apache VHost directory: "
read apache_vhost_dir
while [[ "X$apache_vhost_dir" = "X" ]] ; do
echo -e "\n\t\033[33m\033[1mEingabe erforderlich.\033[m\n"
echononl "Apache VHost directory: "
read apache_vhost_dir
done
else
echononl "Apache VHost directory [${_apache_vhost_dir}]: "
read apache_vhost_dir
if [[ "X$apache_vhost_dir" = "X" ]] ; then
apache_vhost_dir="$_apache_vhost_dir"
fi
fi
index_subdir_apache_vhost_dir="$(expr ${#apache_vhost_dir} + 1)"
if [[ "$(basename $apache_vhost_dir)" = 'sites-enabled' ]]; then
apache_vhost_base_dir="$(dirname $apache_vhost_dir)/sites-available"
elif [[ "$(basename $apache_vhost_dir)" =~ vhost ]]; then
apache_vhost_base_dir="$apache_vhost_dir"
elif [[ "$(basename $(dirname $apache_vhost_dir))" =~ vhost ]]; then
apache_vhost_base_dir="$(dirname $apache_vhost_dir)"
fi
declare -i _num=1
while IFS='' read -r -d '' fq_name ; do
dirname="$(basename "$fq_name")"
[[ "$dirname" = "DELETED" ]] && continue
[[ "$dirname" = "BAK" ]] && continue
[[ "$dirname" = "MAINTENANCE" ]] && continue
[[ "$dirname" =~ ^Moved ]] && continue
if [[ $_num -eq 1 ]]; then
_apache_additional_vhost_dirs="$(basename "$dirname")"
else
_apache_additional_vhost_dirs="$_apache_additional_vhost_dirs $(basename "$dirname")"
fi
((_num++))
done < <(find $apache_vhost_dir -mindepth 1 -maxdepth 1 -type d -print0)
echo ""
echo ""
echo -e "\033[32m--\033[m"
echo ""
echo "If there are additional apache vhost directories, enter them here .."
echo ""
echo -e "\033[33m\033[1mNotice\033[m:"
echo -e " only first level subdiirectories of \033[1m$apache_vhost_dir\033[m"
echo -e " are posible values."
echo ""
echo "Blank seperated list of directories"
echo ""
echo -e "Type:"
echo -e " \033[33m\033[1mNone\033[m\033[15Gfor no further vhost directoties"
echo -e " \033[33m\033[1m<RETURN>\033[m\033[15Gto accept the default inside the square brackets"
echo ""
apache_additional_vhost_dirs=
if [ -z "$_apache_additional_vhost_dirs" ]; then
echononl "Additional Apache VHost directory [None]: "
read apache_additional_vhost_dirs
if [[ -z "trim($apache_additional_vhost_dirs)" ]] ; then
apache_additional_vhost_dirs="None"
elif [[ "${apache_additional_vhost_dirs,,}" = 'none' ]] ; then
apache_additional_vhost_dirs="None"
fi
else
echononl "Additional Apache VHost directories [${_apache_additional_vhost_dirs}]: "
read apache_additional_vhost_dirs
if [[ "${apache_additional_vhost_dirs,,}" = 'none' ]] ; then
apache_additional_vhost_dirs="None"
elif [[ -z "$(trim $apache_additional_vhost_dirs)" ]] ; then
apache_additional_vhost_dirs="$_apache_additional_vhost_dirs"
fi
fi
if [[ -n "$apache_additional_vhost_dirs" ]] && [[ "$apache_additional_vhost_dirs" != "None" ]]; then
declare -a apache_additional_vhost_dir_arr=()
for _dir in $apache_additional_vhost_dirs ; do
if [[ -d "${apache_vhost_dir}/$_dir" ]] ; then
apache_additional_vhost_dir_arr+=("$_dir")
else
warn "$_dir is not a subdirectory of ${apache_vhost_dir}.\n\n \033[33m\033[1mIgnoring directory $_dir\033[m.."
fi
done
fi
echo ""
echo "apache_additional_vhost_dirs: $apache_additional_vhost_dirs"
echo ""
echo ""
echo -e " Apache Vhosts Directory................: \033[1m$apache_vhost_dir\033[m"
if [[ ${#apache_additional_vhost_dir_arr[@]} -gt 0 ]] ; then
declare -i counter=1
echo -en " Additional VHost Directories...........:\033[1m"
for _dir in ${apache_additional_vhost_dir_arr[@]} ; do
if [[ $counter -eq 1 ]] ; then
echo -e " \033[1m$_dir\033[m"
else
echo -e " \033[1m$_dir\033[m"
fi
counter=$((counter+1))
done
echo ""
fi
echo ""
echo ""
echo -e -n "\033[1mContinue with above settings? [y/n]:\033[m "
read OK
while [[ "X${OK}X" = "XX" ]] ; do
echo ""
echo -e -n "\033[1mContinue with above settings? [y/n]:\033[m "
read OK
done
if [[ "${OK,,}" != 'yes' ]] && [[ "${OK,,}" != 'y' ]]; then
fatal "Abort by user request."
else
echo ""
fi
echononl " Backup existing VHost Configuration directory"
if [[ -d "$apache_vhost_base_dir" ]]; then
cp -a "$apache_vhost_base_dir" "${apache_vhost_base_dir}.$backup_date" > $tmp_log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "$(cat $tmp_log_file)"
fi
else
echo_skipped
fi
echo ""
echononl " Create vhost file array.."
for _pgp_fpm_file in $(ls ${apache_vhost_dir}/*.php-fpm) ; do
vhost_php_fpm_file_arr+=("${_pgp_fpm_file}")
done
if [[ ${#apache_additional_vhost_dir_arr[@]} -gt 0 ]] ; then
for _dir in ${apache_additional_vhost_dir_arr[@]} ; do
for _pgp_fpm_file in $(ls ${apache_vhost_dir}/${_dir}/*.php-fpm) ; do
vhost_php_fpm_file_arr+=("${_pgp_fpm_file}")
done
done
fi
if [[ ${#vhost_php_fpm_file_arr[@]} -gt 0 ]] ; then
echo_ok
else
echo_skipped
warn "No vhost configuration file found!"
clean_up 1
fi
_found_unchanged_part_follows_pipe=false
echononl " Replace SetHandler part that follows the pipe.."
for vhost_php_fpm_file in ${vhost_php_fpm_file_arr[@]} ; do
$(grep -q -E "^\s*SetHandler\s+.*fcgi://php/" "${vhost_php_fpm_file}" 2> /dev/null) && continue
_found_unchanged_part_follows_pipe=true
apache_needs_restart=true
perl -i -n -p -e "s#fcgi://127.0.0.1#fcgi://php/#" ${vhost_php_fpm_file}
done
if $_found_unchanged_part_follows_pipe ; then
echo_ok
else
echo_skipped
fi
echo ""
regex_file_match_end="[[:space:]]*</FilesMatch>"
if [[ ${#vhost_php_fpm_file_arr[@]} -gt 0 ]] ; then
for vhost_php_fpm_file in ${vhost_php_fpm_file_arr[@]} ; do
echononl " Change vhost file \033[1m${vhost_php_fpm_file}\033[m"
if $(grep -q -E "^\s*<Proxy\s+\"fcgi://php/\">" "${vhost_php_fpm_file}" 2> /dev/null) ; then
echo_skipped
continue
fi
apache_needs_restart=true
mv "${vhost_php_fpm_file}" "/tmp"
> "${vhost_php_fpm_file}"
_found=false
while IFS= read -r line || [[ -n "$line" ]]; do
echo "${line}" >> "${vhost_php_fpm_file}"
if ! $_found && [[ $line =~ $regex_file_match_end ]] ; then
cat <<EOF >> "${vhost_php_fpm_file}"
# Define a matching worker.
# The part that is matched to the SetHandler is the part that
# follows the pipe. If you need to distinguish, "localhost; can
# be anything unique.
#
<Proxy "fcgi://php/">
# Recycle connections to the fastcgi dispatcher (PHP FPM).
#
# Use persistent connections to reduce the constant overhead of setting
# up new connections
#
ProxySet enablereuse=on
# max - the most proxied request per server
#
# max = pm.max_children / max number of servers
# = pm.max_children / (MaxRequestWorkers / ThreadsPerChild)
#
ProxySet max=16
# Forces the module to flush every chunk of data received from the FCGI backend
# as soon as it receives it, without buffering.
#
ProxySet flushpackets=on
# connectiontimeout
#
# Connect timeout in seconds. The number of seconds Apache httpd waits for the
# creation of a connection to the backend to complete. By adding a postfix of ms,
# the timeout can be also set in milliseconds.
#
ProxySet connectiontimeout=5
# timeout
#
# Socket timeout in seconds. The number of seconds Apache httpd waits for data
# sent by / to the backend.
#
#ProxySet timeout=${PROXY_TIMEOUT}
fi
</Proxy>
EOF
_found=true
fi
done <"/tmp/$(basename "${vhost_php_fpm_file}")"
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "$(cat $tmp_log_file)"
fi
done
fi
if $apache_needs_restart ; then
echo ""
echo -e "\033[32m------\033[m"
echo -e "Restart Apache Webservice"
echo -e "\033[32m------\033[m"
OK=""
echo ""
echo "Type 'y' to continue 'n' or any other key to skip removal of Domains"
echo
echo -e -n "\033[1mRestart Apache Webservice [y/n]:\033[m "
read OK
while [[ "X${OK}X" = "XX" ]] ; do
echo ""
echo -e -n "\033[1mRestart Apache Webservice [y/n]:\033[m "
read OK
done
if [[ "${OK,,}" = 'yes' ]] || [[ "${OK,,}" = 'y' ]]; then
echo ""
echononl " Graceful restart Apache Webservice.."
apachectl graceful
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "$(cat $tmp_log_file)"
echo "Error: $(cat $tmp_log_file)" >> $main_log
fi
fi # if [[ "${OK,,}" = 'yes' ]] || [[ "${OK,,}" = 'y' ]]; then
fi # if $apache_needs_restart
echo ""
clean_up 0

View File

@ -2,16 +2,34 @@
## - Configuration File for Script "create_summary_websites.sh"
## ===================================================================
# - DST_PATH_PHP
# - WEB_DOCROOT
# -
# - Websites DocumentRoot
# -
# - DocumentRoot of the website, which holds the statistioc files.
# -
#WEB_DOCROOT="/var/www/web-01.oopen.de/htdocs"
# - DST_PATH_STATS
# -
# - Destination Path for statistics
# -
DST_PATH_PHP="/var/www/html/dummy/htdocs/website-stats"
# - Defaults to: ${WEB_DOCROOT}/website-stats
#
#DST_PATH_STATS="${WEB_DOCROOT}/website-stats"
# - DST_DIR_CSV
# -
# - Destination Path for generated csv-files
# -
# - Defaults to: ${DST_PATH_PHP}/csv-files-website-stats
# - Defaults to: ${DST_PATH_STATS}/csv-files-website-stats
# -
DST_DIR_CSV="${DST_PATH_PHP}/csv-files-website-stats"
#DST_DIR_CSV="${DST_PATH_STATS}/csv-files-website-stats"
# - WEB_DIR_CSV
# -
# - Destination Path for generated csv-files
# -
# - Defaults to: /website-stats/csv-files-website-stats
# -
#WEB_DIR_CSV="/website-stats/csv-files-website-stats"

View File

@ -110,10 +110,11 @@ DNS_MASTER_SERVER=""
# - $ mysql --login-path=local ...
# -
# - Example
# - mysql_credential_args="--login-path=local"
# - mysql_credential_args="--defaults-file=/etc/mysql/debian.cnf" (Debian default)
# - mysql_credential_args="--defaults-file=/usr/local/mysql/sys-maint.cnf"
# - MYSQL_CREDENTIAL_ARGS="--login-path=local"
# - MYSQL_CREDENTIAL_ARGS="--defaults-file=/etc/mysql/debian.cnf" (Debian default)
# - MYSQL_CREDENTIAL_ARGS="--defaults-file=/usr/local/mysql/sys-maint.cnf"
# - MYSQL_CREDENTIAL_ARGS="-u root -S /run/mysqld/mysqld.sock"
# -
# - Defaults to '--login-path=local'
# - Defaults to '-u root -S /run/mysqld/mysqld.sock'
# -
#MYSQL_CREDENTIAL_ARGS="--login-path=local"
#MYSQL_CREDENTIAL_ARGS="-u root -S /run/mysqld/mysqld.sock"

View File

@ -12,7 +12,7 @@ declare -a apache_vhost_dir_arr
declare -a _all_vhost_files_arr
declare -a _all_document_root_dirs_arr
PHP_VERIONS_SUPPORTED="5.3 5.4 5.5 5.6 7.0.7.1 7.2 7.3 7.4 8.0 8.1"
PHP_VERIONS_SUPPORTED="5.3 5.4 5.5 5.6 7.0.7.1 7.2 7.3 7.4 8.0 8.1 8.2 8.3"
declare -i number_websites_53=0
declare -i number_websites_54=0
@ -25,6 +25,8 @@ declare -i number_websites_73=0
declare -i number_websites_74=0
declare -i number_websites_80=0
declare -i number_websites_81=0
declare -i number_websites_82=0
declare -i number_websites_83=0
declare -i number_redirected=0
declare -i number_parked=0
declare -i number_mod_php=0
@ -59,6 +61,8 @@ clean_up() {
rm -f $_tmp_filename_php_74
rm -f $_tmp_filename_php_80
rm -f $_tmp_filename_php_81
rm -f $_tmp_filename_php_82
rm -f $_tmp_filename_php_83
rm -f $_tmp_filename_not_considered
rm -f $_tmp_filename_no_php_assigned
exit $1
@ -110,29 +114,27 @@ if [[ -f "$conf_file" ]]; then
fi
if [[ -z "$DST_PATH_PHP" ]]; then
if [[ -d "/var/www/html/dummy/htdocs" ]] ; then
DST_PATH_PHP="/var/www/html/dummy/htdocs"
elif [[ -d "/var/www/html/dummy" ]] ; then
DST_PATH_PHP="/var/www/html/dummy"
elif [[ -d "/var/www/default" ]] ; then
DST_PATH_PHP="$DST_PATH_PHP"
fi
else
if [[ ! -d "$DST_PATH_PHP" ]]; then
mkdir "$DST_PATH_PHP" > /dev/null 2>&1
if [[ $? -ne 0 ]]; then
fatal "Creation of directory '$DST_PATH_PHP' failed!"
fi
if [[ -z "$WEB_DOCROOT" ]]; then
fatal "Missing value for variable 'WEB_DOCROOT'!"
fi
if [[ -z "$DST_PATH_STATS" ]]; then
DST_PATH_STATS="${WEB_DOCROOT}/website-stats"
fi
if [[ ! -d "$DST_PATH_STATS" ]]; then
mkdir "$DST_PATH_STATS" > /dev/null 2>&1
if [[ $? -ne 0 ]]; then
fatal "Creation of directory '$DST_PATH_STATS' failed!"
fi
fi
if [[ -z "$DST_PATH_PHP" ]]; then
fatal "Destination Path for statistics (parameter 'DST_PATH_PHP') not found!"
if [[ -z "$DST_PATH_STATS" ]]; then
fatal "Destination Path for statistics (parameter 'DST_PATH_STATS') not found!"
fi
if [[ -z "$DST_DIR_CSV" ]] ; then
DST_DIR_CSV="${DST_PATH_PHP}/csv-files-website-stats"
DST_DIR_CSV="${DST_PATH_STATS}/csv-files-website-stats"
fi
if [[ ! -d "$DST_DIR_CSV" ]]; then
@ -142,9 +144,13 @@ if [[ ! -d "$DST_DIR_CSV" ]]; then
fi
fi
if [[ -z "${WEB_DIR_CSV}" ]]; then
WEB_DIR_CSV="/website-stats/csv-files-website-stats"
fi
_tmp_filename_summary=$(mktemp)
filename_summary="${DST_DIR_CSV}/WEBSITES_SUMMARY.csv"
cat <<EOF > ${DST_PATH_PHP}/websites_summary.php
cat <<EOF > ${DST_PATH_STATS}/websites_summary.php
<?php
header('Content-Type:application/csv ; charset=utf-8');
header("Content-Disposition: attachment; filename=\"$(basename $filename_summary)\"");
@ -158,7 +164,7 @@ echo ";" >> $filename_summary
_tmp_filename_redirected=$(mktemp)
filename_redirected="${DST_DIR_CSV}/WEBSITES_REDIRECTED.csv"
cat <<EOF > ${DST_PATH_PHP}/websites_redirected.php
cat <<EOF > ${DST_PATH_STATS}/websites_redirected.php
<?php
header('Content-Type:application/csv ; charset=utf-8');
header("Content-Disposition: attachment; filename=\"$(basename $filename_redirected)\"");
@ -172,7 +178,7 @@ echo ";" >> $filename_redirected
_tmp_filename_parked=$(mktemp)
filename_parked="${DST_DIR_CSV}/WEBSITES_PARKED.csv"
cat <<EOF > ${DST_PATH_PHP}/websites_parked.php
cat <<EOF > ${DST_PATH_STATS}/websites_parked.php
<?php
header('Content-Type:application/csv ; charset=utf-8');
header("Content-Disposition: attachment; filename=\"$(basename $filename_parked)\"");
@ -186,7 +192,7 @@ echo ";" >> $filename_parked
_tmp_filename_mod_php=$(mktemp)
filename_mod_php="${DST_DIR_CSV}/WEBSITES_MOD_PHP.csv"
cat <<EOF > ${DST_PATH_PHP}/websites_mod_php.php
cat <<EOF > ${DST_PATH_STATS}/websites_mod_php.php
<?php
header('Content-Type:application/csv ; charset=utf-8');
header("Content-Disposition: attachment; filename=\"$(basename $filename_mod_php)\"");
@ -200,7 +206,7 @@ echo ";" >> $filename_mod_php
_tmp_filename_php_fpm=$(mktemp)
filename_php_fpm="${DST_DIR_CSV}/WEBSITES_PHP_FPM.csv"
cat <<EOF > ${DST_PATH_PHP}/websites_php_fpm.php
cat <<EOF > ${DST_PATH_STATS}/websites_php_fpm.php
<?php
header('Content-Type:application/csv ; charset=utf-8');
header("Content-Disposition: attachment; filename=\"$(basename $filename_php_fpm)\"");
@ -214,7 +220,7 @@ echo ";" >> $filename_php_fpm
_tmp_filename_php_fcgid=$(mktemp)
filename_php_fcgid="${DST_DIR_CSV}/WEBSITES_PHP_FCGID.csv"
cat <<EOF > ${DST_PATH_PHP}/websites_php_fcgid.php
cat <<EOF > ${DST_PATH_STATS}/websites_php_fcgid.php
<?php
header('Content-Type:application/csv ; charset=utf-8');
header("Content-Disposition: attachment; filename=\"$(basename $filename_php_fcgid)\"");
@ -228,7 +234,7 @@ echo ";" >> $filename_php_fcgid
_tmp_filename_php_53=$(mktemp)
filename_php_53="${DST_DIR_CSV}/WEBSITES_PHP_53.csv"
cat <<EOF > ${DST_PATH_PHP}/websites_php_53.php
cat <<EOF > ${DST_PATH_STATS}/websites_php_53.php
<?php
header('Content-Type:application/csv ; charset=utf-8');
header("Content-Disposition: attachment; filename=\"$(basename $filename_php_53)\"");
@ -242,7 +248,7 @@ echo ";" >> $filename_php_53
_tmp_filename_php_54=$(mktemp)
filename_php_54="${DST_DIR_CSV}/WEBSITES_PHP_54.csv"
cat <<EOF > ${DST_PATH_PHP}/websites_php_54.php
cat <<EOF > ${DST_PATH_STATS}/websites_php_54.php
<?php
header('Content-Type:application/csv ; charset=utf-8');
header("Content-Disposition: attachment; filename=\"$(basename $filename_php_54)\"");
@ -256,7 +262,7 @@ echo ";" >> $filename_php_54
_tmp_filename_php_55=$(mktemp)
filename_php_55="${DST_DIR_CSV}/WEBSITES_PHP_55.csv"
cat <<EOF > ${DST_PATH_PHP}/websites_php_55.php
cat <<EOF > ${DST_PATH_STATS}/websites_php_55.php
<?php
header('Content-Type:application/csv ; charset=utf-8');
header("Content-Disposition: attachment; filename=\"$(basename $filename_php_55)\"");
@ -270,7 +276,7 @@ echo ";" >> $filename_php_55
_tmp_filename_php_56=$(mktemp)
filename_php_56="${DST_DIR_CSV}/WEBSITES_PHP_56.csv"
cat <<EOF > ${DST_PATH_PHP}/websites_php_56.php
cat <<EOF > ${DST_PATH_STATS}/websites_php_56.php
<?php
header('Content-Type:application/csv ; charset=utf-8');
header("Content-Disposition: attachment; filename=\"$(basename $filename_php_56)\"");
@ -284,7 +290,7 @@ echo ";" >> $filename_php_56
_tmp_filename_php_70=$(mktemp)
filename_php_70="${DST_DIR_CSV}/WEBSITES_PHP_70.csv"
cat <<EOF > ${DST_PATH_PHP}/websites_php_70.php
cat <<EOF > ${DST_PATH_STATS}/websites_php_70.php
<?php
header('Content-Type:application/csv ; charset=utf-8');
header("Content-Disposition: attachment; filename=\"$(basename $filename_php_70)\"");
@ -298,7 +304,7 @@ echo ";" >> $filename_php_70
_tmp_filename_php_71=$(mktemp)
filename_php_71="${DST_DIR_CSV}/WEBSITES_PHP_71.csv"
cat <<EOF > ${DST_PATH_PHP}/websites_php_71.php
cat <<EOF > ${DST_PATH_STATS}/websites_php_71.php
<?php
header('Content-Type:application/csv ; charset=utf-8');
header("Content-Disposition: attachment; filename=\"$(basename $filename_php_71)\"");
@ -312,7 +318,7 @@ echo ";" >> $filename_php_71
_tmp_filename_php_72=$(mktemp)
filename_php_72="${DST_DIR_CSV}/WEBSITES_PHP_72.csv"
cat <<EOF > ${DST_PATH_PHP}/websites_php_72.php
cat <<EOF > ${DST_PATH_STATS}/websites_php_72.php
<?php
header('Content-Type:application/csv ; charset=utf-8');
header("Content-Disposition: attachment; filename=\"$(basename $filename_php_72)\"");
@ -326,7 +332,7 @@ echo ";" >> $filename_php_72
_tmp_filename_php_73=$(mktemp)
filename_php_73="${DST_DIR_CSV}/WEBSITES_PHP_73.csv"
cat <<EOF > ${DST_PATH_PHP}/websites_php_73.php
cat <<EOF > ${DST_PATH_STATS}/websites_php_73.php
<?php
header('Content-Type:application/csv ; charset=utf-8');
header("Content-Disposition: attachment; filename=\"$(basename $filename_php_73)\"");
@ -340,7 +346,7 @@ echo ";" >> $filename_php_73
_tmp_filename_php_74=$(mktemp)
filename_php_74="${DST_DIR_CSV}/WEBSITES_PHP_74.csv"
cat <<EOF > ${DST_PATH_PHP}/websites_php_74.php
cat <<EOF > ${DST_PATH_STATS}/websites_php_74.php
<?php
header('Content-Type:application/csv ; charset=utf-8');
header("Content-Disposition: attachment; filename=\"$(basename $filename_php_74)\"");
@ -354,7 +360,7 @@ echo ";" >> $filename_php_74
_tmp_filename_php_80=$(mktemp)
filename_php_80="${DST_DIR_CSV}/WEBSITES_PHP_80.csv"
cat <<EOF > ${DST_PATH_PHP}/websites_php_80.php
cat <<EOF > ${DST_PATH_STATS}/websites_php_80.php
<?php
header('Content-Type:application/csv ; charset=utf-8');
header("Content-Disposition: attachment; filename=\"$(basename $filename_php_80)\"");
@ -368,7 +374,7 @@ echo ";" >> $filename_php_80
_tmp_filename_php_81=$(mktemp)
filename_php_81="${DST_DIR_CSV}/WEBSITES_PHP_81.csv"
cat <<EOF > ${DST_PATH_PHP}/websites_php_81.php
cat <<EOF > ${DST_PATH_STATS}/websites_php_81.php
<?php
header('Content-Type:application/csv ; charset=utf-8');
header("Content-Disposition: attachment; filename=\"$(basename $filename_php_81)\"");
@ -380,10 +386,38 @@ EOF
echo "Website; ;PHP Version; ;PHP Engine; ;Database; ;CMS; ;DocumentRoot; ;VHost file; ;Server Alias(es)" > $filename_php_81
echo ";" >> $filename_php_81
_tmp_filename_php_82=$(mktemp)
filename_php_82="${DST_DIR_CSV}/WEBSITES_PHP_82.csv"
cat <<EOF > ${DST_PATH_STATS}/websites_php_82.php
<?php
header('Content-Type:application/csv ; charset=utf-8');
header("Content-Disposition: attachment; filename=\"$(basename $filename_php_82)\"");
header('Pragma: no-cache');
header('Expires: 0');
readfile("$filename_php_82");
?>
EOF
echo "Website; ;PHP Version; ;PHP Engine; ;Database; ;CMS; ;DocumentRoot; ;VHost file; ;Server Alias(es)" > $filename_php_82
echo ";" >> $filename_php_82
_tmp_filename_php_83=$(mktemp)
filename_php_83="${DST_DIR_CSV}/WEBSITES_PHP_83.csv"
cat <<EOF > ${DST_PATH_STATS}/websites_php_83.php
<?php
header('Content-Type:application/csv ; charset=utf-8');
header("Content-Disposition: attachment; filename=\"$(basename $filename_php_83)\"");
header('Pragma: no-cache');
header('Expires: 0');
readfile("$filename_php_83");
?>
EOF
echo "Website; ;PHP Version; ;PHP Engine; ;Database; ;CMS; ;DocumentRoot; ;VHost file; ;Server Alias(es)" > $filename_php_83
echo ";" >> $filename_php_83
_tmp_filename_not_considered=$(mktemp)
filename_not_considered="${DST_DIR_CSV}/VHOST_FILES_NOT_CONSIDERED.csv"
cat <<EOF > ${DST_PATH_PHP}/vhost_files_not_considered.php
cat <<EOF > ${DST_PATH_STATS}/vhost_files_not_considered.php
<?php
header('Content-Type:application/csv ; charset=utf-8');
header("Content-Disposition: attachment; filename=\"$(basename $filename_not_considered)\"");
@ -398,7 +432,7 @@ echo ";" >> $filename_not_considered
_tmp_filename_no_php_assigned=$(mktemp)
filename_no_php_assigned="${DST_DIR_CSV}/WEBSITES_NO_PHP_FOUND.csv"
cat <<EOF > ${DST_PATH_PHP}/websites_no_php_found.php
cat <<EOF > ${DST_PATH_STATS}/websites_no_php_found.php
<?php
header('Content-Type:application/csv ; charset=utf-8');
header("Content-Disposition: attachment; filename=\"$(basename $filename_no_php_assigned)\"");
@ -1059,6 +1093,20 @@ for _vhost_file in ${_all_vhost_files_arr[@]} ; do
fi
if [[ "$_php_version" =~ ^8.2 ]]; then
echo "$_server_name;;$_php_version;;$_php_engine;;$database;;$site_cms;;$_documentroot;;$_vhost_file;;$server_aliases" >> $_tmp_filename_php_82
((number_websites_82++))
fi
if [[ "$_php_version" =~ ^8.3 ]]; then
echo "$_server_name;;$_php_version;;$_php_engine;;$database;;$site_cms;;$_documentroot;;$_vhost_file;;$server_aliases" >> $_tmp_filename_php_83
((number_websites_83++))
fi
elif ! $_vhost_file_not_considered ; then
_redirect_site=""
_redirect_site=$(grep -E "^\s*RewriteRule" $_vhost_file 2> /dev/null | awk '{print$3}' | sed 's/"//g' | sed 's/\/$//' | sed 's/https\?:\/\///g' | sed 's/\$1//g' | sort -u)
@ -1099,6 +1147,7 @@ cat $_tmp_filename_php_73 | sort >> $filename_php_73
cat $_tmp_filename_php_74 | sort >> $filename_php_74
cat $_tmp_filename_php_80 | sort >> $filename_php_80
cat $_tmp_filename_php_81 | sort >> $filename_php_81
cat $_tmp_filename_php_82 | sort >> $filename_php_82
cat $_tmp_filename_not_considered | sort >> $filename_not_considered
cat $_tmp_filename_no_php_assigned | sort >> $filename_no_php_assigned
@ -1107,89 +1156,170 @@ cat $_tmp_filename_no_php_assigned | sort >> $filename_no_php_assigned
# - Create summary file index.php
# -----
cat <<EOF > ${DST_PATH_PHP}/index.php
if [[ -f "${DST_PATH_STATS}/index.php" ]]; then
rm "${DST_PATH_STATS}/index.php"
fi
cat <<EOF > ${DST_PATH_STATS}/index.html
<html>
<head>
<title>Statistics websites $(hostname -f)</title>
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
</head>
<body>
<h4>$(hostname -f)</h4>
<ul>
<li><a href="websites_summary.php">full summary of all hosted websites</a>: $number_overall</li>
EOF
if [[ $number_overall -gt 0 ]]; then
cat <<EOF >> ${DST_PATH_STATS}/index.html
<li><a href="${WEB_DIR_CSV}/$(basename $filename_summary)">full summary of all hosted websites</a>: $number_overall</li>
EOF
else
cat <<EOF >> ${DST_PATH_STATS}/index.html
<li>full summary of all hosted websites: $number_overall</li>
EOF
fi
cat <<EOF >> ${DST_PATH_STATS}/index.html
<br />
<li><a href="websites_redirected.php">redirected websites</a>: $number_redirected</li>
<li><a href="websites_parked.php">parked websites</a>: $number_parked</li>
EOF
if [[ $number_redirected -gt 0 ]]; then
cat <<EOF >> ${DST_PATH_STATS}/index.html
<li><a href="${WEB_DIR_CSV}/$(basename $filename_redirected)">redirected websites</a>: $number_redirected</li>
EOF
else
cat <<EOF >> ${DST_PATH_STATS}/index.html
<li>redirected websites: $number_redirected</li>
EOF
fi
if [[ $number_parked -gt 0 ]]; then
cat <<EOF >> ${DST_PATH_STATS}/index.html
<li><a href="${WEB_DIR_CSV}/$(basename $filename_parked)">parked websites</a>: $number_parked</li>
EOF
else
cat <<EOF >> ${DST_PATH_STATS}/index.html
<li>parked websites: $number_parked</li>
EOF
fi
cat <<EOF >> ${DST_PATH_STATS}/index.html
<br />
<li><a href="websites_mod_php.php">websites mod_php</a>: $number_mod_php</li>
<li><a href="websites_php_fpm.php">websites PHP-FPM</a>: $number_php_fpm</li>
<li><a href="websites_php_fcgid.php">websites FastCGI</a>: $number_php_fcgid</li>
EOF
if [[ $number_mod_php -gt 0 ]]; then
cat <<EOF >> ${DST_PATH_STATS}/index.html
<li><a href="${WEB_DIR_CSV}/$(basename $filename_mod_php)">websites mod_php</a>: $number_mod_php</li>
EOF
else
cat <<EOF >> ${DST_PATH_STATS}/index.html
<li>websites mod_php: $number_mod_php</li>
EOF
fi
if [[ $number_php_fpm -gt 0 ]]; then
cat <<EOF >> ${DST_PATH_STATS}/index.html
<li><a href="${WEB_DIR_CSV}/$(basename $filename_php_fpm)">websites PHP-FPM</a>: $number_php_fpm</li>
EOF
else
cat <<EOF >> ${DST_PATH_STATS}/index.html
<li>websites PHP-FPM: $number_php_fpm</li>
EOF
fi
if [[ $number_php_fcgid -gt 0 ]]; then
cat <<EOF >> ${DST_PATH_STATS}/index.html
<li><a href="${WEB_DIR_CSV}/$(basename $filename_php_fcgid)">websites FastCGI</a>: $number_php_fcgid</li>
EOF
else
cat <<EOF >> ${DST_PATH_STATS}/index.html
<li>websites FastCGI: $number_php_fcgid</li>
EOF
fi
cat <<EOF >> ${DST_PATH_STATS}/index.html
<br />
<li><a href="websites_no_php_found.php">websites no PHP assigned</a>: $number_no_php_assigned</li>
EOF
if [[ $number_no_php_assigned -gt 0 ]]; then
cat <<EOF >> ${DST_PATH_STATS}/index.html
<li><a href="${WEB_DIR_CSV}/$(basename $filename_no_php_assigned)">websites no PHP assigned</a>: $number_no_php_assigned</li>
EOF
else
cat <<EOF >> ${DST_PATH_STATS}/index.html
<li>websites no PHP assigned: $number_no_php_assigned</li>
EOF
fi
cat <<EOF >> ${DST_PATH_STATS}/index.html
</ul>
<hr width="100" align="left">
<ul>
<li><a href="vhost_files_not_considered.php">vhost_files not considered</a>: $number_not_considered</li>
<li><a href="${WEB_DIR_CSV}/$(basename $filename_not_considered)">vhost_files not considered</a>: $number_not_considered</li>
</ul>
<hr width="100" align="left">
<h5>PHP versions supported by this script:<br />&nbsp;&nbsp;&nbsp; $PHP_VERIONS_SUPPORTED</h5>
<ul>
EOF
if [[ $number_websites_53 -gt 0 ]]; then
cat <<EOF >> ${DST_PATH_PHP}/index.php
<li><a href="websites_php_53.php">websites PHP v5.3</a>: $number_websites_53</li>
cat <<EOF >> ${DST_PATH_STATS}/index.html
<li><a href="${WEB_DIR_CSV}/$(basename $filename_php_74)">websites PHP v5.3</a>: $number_websites_53</li>
EOF
fi
if [[ $number_websites_54 -gt 0 ]]; then
cat <<EOF >> ${DST_PATH_PHP}/index.php
<li><a href="websites_php_54.php">websites PHP v5.4</a>: $number_websites_54</li>
cat <<EOF >> ${DST_PATH_STATS}/index.html
<li><a href="${WEB_DIR_CSV}/$(basename $filename_php_54)">websites PHP v5.4</a>: $number_websites_54</li>
EOF
fi
if [[ $number_websites_55 -gt 0 ]]; then
cat <<EOF >> ${DST_PATH_PHP}/index.php
<li><a href="websites_php_55.php">websites PHP v5.5</a>: $number_websites_55</li>
cat <<EOF >> ${DST_PATH_STATS}/index.html
<li><a href="${WEB_DIR_CSV}/$(basename $filename_php_55)">websites PHP v5.5</a>: $number_websites_55</li>
EOF
fi
if [[ $number_websites_56 -gt 0 ]]; then
cat <<EOF >> ${DST_PATH_PHP}/index.php
<li><a href="websites_php_56.php">websites PHP v5.6</a>: $number_websites_56</li>
cat <<EOF >> ${DST_PATH_STATS}/index.html
<li><a href="${WEB_DIR_CSV}/$(basename $filename_php_56)">websites PHP v5.6</a>: $number_websites_56</li>
EOF
fi
if [[ $number_websites_70 -gt 0 ]]; then
cat <<EOF >> ${DST_PATH_PHP}/index.php
<li><a href="websites_php_70.php">websites PHP v7.0</a>: $number_websites_70</li>
cat <<EOF >> ${DST_PATH_STATS}/index.html
<li><a href="${WEB_DIR_CSV}/$(basename $filename_php_70)">websites PHP v7.0</a>: $number_websites_70</li>
EOF
fi
if [[ $number_websites_71 -gt 0 ]]; then
cat <<EOF >> ${DST_PATH_PHP}/index.php
<li><a href="websites_php_71.php">websites PHP v7.1</a>: $number_websites_71</li>
cat <<EOF >> ${DST_PATH_STATS}/index.html
<li><a href="${WEB_DIR_CSV}/$(basename $filename_php_71)">websites PHP v7.1</a>: $number_websites_71</li>
EOF
fi
if [[ $number_websites_72 -gt 0 ]]; then
cat <<EOF >> ${DST_PATH_PHP}/index.php
<li><a href="websites_php_72.php">websites PHP v7.2</a>: $number_websites_72</li>
cat <<EOF >> ${DST_PATH_STATS}/index.html
<li><a href="${WEB_DIR_CSV}/$(basename $filename_php_72)">websites PHP v7.2</a>: $number_websites_72</li>
EOF
fi
if [[ $number_websites_73 -gt 0 ]]; then
cat <<EOF >> ${DST_PATH_PHP}/index.php
<li><a href="websites_php_73.php">websites PHP v7.3</a>: $number_websites_73</li>
cat <<EOF >> ${DST_PATH_STATS}/index.html
<li><a href="${WEB_DIR_CSV}/$(basename $filename_php_73)">websites PHP v7.3</a>: $number_websites_73</li>
EOF
fi
if [[ $number_websites_74 -gt 0 ]]; then
cat <<EOF >> ${DST_PATH_PHP}/index.php
<li><a href="websites_php_74.php">websites PHP v7.4</a>: $number_websites_74</li>
cat <<EOF >> ${DST_PATH_STATS}/index.html
<li><a href="${WEB_DIR_CSV}/$(basename $filename_php_74)">websites PHP v7.4</a>: $number_websites_74</li>
EOF
fi
if [[ $number_websites_80 -gt 0 ]]; then
cat <<EOF >> ${DST_PATH_PHP}/index.php
<li><a href="websites_php_80.php">websites PHP v8.0</a>: $number_websites_80</li>
cat <<EOF >> ${DST_PATH_STATS}/index.html
<li><a href="${WEB_DIR_CSV}/$(basename $filename_php_80)">websites PHP v8.0</a>: $number_websites_80</li>
EOF
fi
if [[ $number_websites_81 -gt 0 ]]; then
cat <<EOF >> ${DST_PATH_PHP}/index.php
<li><a href="websites_php_81.php">websites PHP v8.1</a>: $number_websites_81</li>
cat <<EOF >> ${DST_PATH_STATS}/index.html
<li><a href="${WEB_DIR_CSV}/$(basename $filename_php_81)">websites PHP v8.1</a>: $number_websites_81</li>
EOF
fi
cat <<EOF >> ${DST_PATH_PHP}/index.php
if [[ $number_websites_82 -gt 0 ]]; then
cat <<EOF >> ${DST_PATH_STATS}/index.html
<li><a href="${WEB_DIR_CSV}/$(basename $filename_php_82)">websites PHP v8.2</a>: $number_websites_82</li>
EOF
fi
if [[ $number_websites_83 -gt 0 ]]; then
cat <<EOF >> ${DST_PATH_STATS}/index.html
<li><a href="${WEB_DIR_CSV}/$(basename $filename_php_83)">websites PHP v8.3</a>: $number_websites_83</li>
EOF
fi
cat <<EOF >> ${DST_PATH_STATS}/index.html
</ul>
</body>
</html>

View File

@ -207,14 +207,25 @@ shopt -u extglob
# - Determin httpd binary
# -
_httpd_binary="`which httpd`"
## - Determin httpd binary
## -
_httpd_binary="$(ps -axu | grep httpd \
| grep -e "^root" \
| grep -v grep \
| grep -v vim \
| grep -v bash \
| awk '{print$11}' | head -1)"
if [ -z "$_httpd_binary" ]; then
_httpd_binary="$(ps -axu | grep httpd | grep -e "^root" | grep -v grep | awk '{print$11}')"
_httpd_binary="$(which httpd)"
if [ -z "$_httpd_binary" ]; then
if [ -x "/usr/local/apache2/bin/httpd" ]; then
_httpd_binary="/usr/local/apache2/bin/httpd"
fi
fi
fi
# - Determin websever user/group
@ -294,6 +305,34 @@ WEBSITES_ROOT_DIR=""
CREATE_SYMLINK_WEB_BASE_DIR=false
# ---
# - Determin timeout value
# ---
if [[ -f "/usr/local/apache2/conf/httpd.conf" ]]; then
_HTTPD_CONF_FILE="/usr/local/apache2/conf/httpd.conf"
elif [[ -f "/etc/apache2/apache2.conf" ]]; then
_HTTPD_CONF_FILE="/etc/apache2/apache2.conf"
else
_HTTPD_CONF_FILE=''
fi
if [[ -f "${_HTTPD_CONF_FILE}" ]] && $(grep -q -i -E "^\s*Timeout\s+" "${_HTTPD_CONF_FILE}") ; then
_TIMEOUT="$(grep -i -E "^\s*timeout\s+" "${_HTTPD_CONF_FILE}"| awk '{print$2}' | head -1)"
else
_TIMEOUT=60
fi
if [[ -f "${_HTTPD_CONF_FILE}" ]] && $(grep -q -i -E "^\s*ProxyTimeout\s+" "${_HTTPD_CONF_FILE}") ; then
PROXY_TIMEOUT="$(grep -i -E "^\s*ProxyTimeout\s+" "${_HTTPD_CONF_FILE}"| awk '{print$2}' | head -1)"
else
PROXY_TIMEOUT=${_TIMEOUT}
fi
# ---
# - END: Determin timeout value
# ---
# ---
# - Read Configuration File (if exists)
# -
@ -813,7 +852,9 @@ if [ -z "$_existing_vhost_config_file" ]; then
done
if [[ -n "$(trim $COMMON_LOGFILE_DIR)" ]]; then
if $_suEXEC ; then
__log_dir=${_web_base_dir}/logs
elif [[ -n "$(trim $COMMON_LOGFILE_DIR)" ]]; then
__log_dir="$COMMON_LOGFILE_DIR"
else
__log_dir=${_web_base_dir}/logs
@ -1927,7 +1968,7 @@ if [ "$_type" = "PHP-FPM" ]; then
tcp_host=127.0.0.1
tcp_port=9000
_proxy_match="^/(.*\.php(/.*)?)\$ unix:$unix_socket|fcgi://$tcp_host:$tcp_port$_doc_root"
_set_handler_fpm="\"proxy:unix:$unix_socket|fcgi://$tcp_host\""
_set_handler_fpm="\"proxy:unix:${unix_socket}|fcgi://php/\""
unix_socket_owner="$(stat -c '%U' $unix_socket)"
unix_socket_group="$(stat -c '%G' $unix_socket)"
else
@ -2401,6 +2442,7 @@ if [ ! -d "$_web_base_dir" ]; then
mkdir $_web_base_dir
if [ "$?" = "0" ]; then
echo_ok
web_base_directory_already_exists=false
else
echo_failed
error "Cannot create web base directory \"$_web_base_dir\"."
@ -2408,22 +2450,27 @@ if [ ! -d "$_web_base_dir" ]; then
fi
else
echo_skipped
web_base_directory_already_exists=true
fi
echononl "\tChange owner of Web Base directory \"$_web_base_dir\".."
if $_suEXEC ; then
chown -R ${suEXEC_user}:$suEXEC_group $_web_base_dir
elif [[ "$_type" = "PHP-FPM" ]]; then
chown -R ${unix_socket_owner}:${unix_socket_group} $_web_base_dir
if $web_base_directory_already_exists ; then
echo_skipped
else
chown -R ${web_user}:${web_group} $_web_base_dir
fi
if [ "$?" = "0" ]; then
echo_ok
else
echo_failed
error "Cannot change owner of web base directory \"$_web_base_dir\""
fatal
if $_suEXEC ; then
chown -R ${suEXEC_user}:$suEXEC_group $_web_base_dir
elif [[ "$_type" = "PHP-FPM" ]]; then
chown -R ${unix_socket_owner}:${unix_socket_group} $_web_base_dir
else
chown -R ${web_user}:${web_group} $_web_base_dir
fi
if [ "$?" = "0" ]; then
echo_ok
else
echo_failed
error "Cannot change owner of web base directory \"$_web_base_dir\""
fatal
fi
fi
if $CREATE_SYMLINK_WEB_BASE_DIR ; then
@ -2462,19 +2509,23 @@ else
fi
echononl "\tChange owner of \"DocumentRoot\" directory.."
if $_suEXEC ; then
chown -R ${suEXEC_user}:$suEXEC_group $_doc_root
elif [[ "$_type" = "PHP-FPM" ]]; then
chown -R ${unix_socket_owner}:${unix_socket_group} $_doc_root
if $web_base_directory_already_exists ; then
echo_skipped
else
chown -R ${web_user}:${web_group} $_doc_root
fi
if [ "$?" = "0" ]; then
echo_ok
else
echo_failed
error "Cannot change owner of directory \"$_doc_root\""
fatal
if $_suEXEC ; then
chown -R ${suEXEC_user}:$suEXEC_group $_doc_root
elif [[ "$_type" = "PHP-FPM" ]]; then
chown -R ${unix_socket_owner}:${unix_socket_group} $_doc_root
else
chown -R ${web_user}:${web_group} $_doc_root
fi
if [ "$?" = "0" ]; then
echo_ok
else
echo_failed
error "Cannot change owner of directory \"$_doc_root\""
fatal
fi
fi
echononl "\tCreate Logfile directory.."
@ -3020,6 +3071,49 @@ elif [ "$_type" = "PHP-FPM" ]; then
SetHandler $_set_handler_fpm
</FilesMatch>
# Define a matching worker.
# The part that is matched to the SetHandler is the part that
# follows the pipe. If you need to distinguish, "localhost; can
# be anything unique.
#
<Proxy "fcgi://php/">
# Recycle connections to the fastcgi dispatcher (PHP FPM).
#
# Use persistent connections to reduce the constant overhead of setting
# up new connections
#
ProxySet enablereuse=on
# max - the most proxied request per server
#
# max = pm.max_children / max number of servers
# = pm.max_children / (MaxRequestWorkers / ThreadsPerChild)
#
ProxySet max=16
# Forces the module to flush every chunk of data received from the FCGI backend
# as soon as it receives it, without buffering.
#
ProxySet flushpackets=on
# connectiontimeout
#
# Connect timeout in seconds. The number of seconds Apache httpd waits for the
# creation of a connection to the backend to complete. By adding a postfix of ms,
# the timeout can be also set in milliseconds.
#
ProxySet connectiontimeout=5
# timeout
#
# Socket timeout in seconds. The number of seconds Apache httpd waits for data
# sent by / to the backend.
#
#ProxySet timeout=${PROXY_TIMEOUT}
</Proxy>
<IfModule dir_module>
DirectoryIndex index.php index.html index.htm
</IfModule>
@ -3123,6 +3217,48 @@ EOF
SetHandler $_set_handler_fpm
</FilesMatch>
# Define a matching worker.
# The part that is matched to the SetHandler is the part that
# follows the pipe. If you need to distinguish, "localhost; can
# be anything unique.
#
<Proxy "fcgi://php/">
# Recycle connections to the fastcgi dispatcher (PHP FPM).
#
# Use persistent connections to reduce the constant overhead of setting
# up new connections
#
ProxySet enablereuse=on
# max - the most proxied request per server
#
# max = pm.max_children / max number of servers
# = pm.max_children / (MaxRequestWorkers / ThreadsPerChild)
#
ProxySet max=16
# Forces the module to flush every chunk of data received from the FCGI backend
# as soon as it receives it, without buffering.
#
ProxySet flushpackets=on
# connectiontimeout
#
# Connect timeout in seconds. The number of seconds Apache httpd waits for the
# creation of a connection to the backend to complete. By adding a postfix of ms,
# the timeout can be also set in milliseconds.
#
ProxySet connectiontimeout=5
# timeout
#
# Socket timeout in seconds. The number of seconds Apache httpd waits for data
# sent by / to the backend.
#
ProxySet timeout=30
</Proxy>
<IfModule dir_module>
DirectoryIndex index.php index.html index.htm
</IfModule>
@ -3311,7 +3447,7 @@ else
fi
echononl "\tCreate \"phpinfo.php\" file.."
if $CREATE_PHPINFO_FILE ; then
if $CREATE_PHPINFO_FILE && [ "$_type" = "PHP-FPM" -o "$_type" = "FCGID" ]; then
if [ ! -f "${_doc_root}/phpinfo.php" ]; then
cat <<EOF > ${_doc_root}/phpinfo.php
<html>

View File

@ -207,7 +207,7 @@ if $delete_mode ; then
[[ -n "$SCRIPT_remove_master_domain" ]] || SCRIPT_remove_master_domain="/root/bin/bind/bind_remove_domain_on_master.sh"
[[ -n "$SCRIPT_remove_slave_domain" ]] || SCRIPT_remove_slave_domain="/root/bin/bind/bind_remove_domain_on_slave.sh"
[[ -n "$MYSQL_CREDENTIAL_ARGS" ]] || MYSQL_CREDENTIAL_ARGS="--login-path=local"
[[ -n "$MYSQL_CREDENTIAL_ARGS" ]] || MYSQL_CREDENTIAL_ARGS="-u root -S /run/mysqld/mysqld.sock"
fi
@ -346,6 +346,7 @@ while IFS='' read -r -d '' fq_name ; do
dirname="$(basename "$fq_name")"
[[ "$dirname" = "DELETED" ]] && continue
[[ "$dirname" = "BAK" ]] && continue
[[ "$dirname" = "MAINTENANCE" ]] && continue
[[ "$dirname" =~ ^Moved ]] && continue
if [[ $_num -eq 1 ]]; then
_apache_additional_vhost_dirs="$(basename "$dirname")"