#!/usr/bin/env bash log_file="$(mktemp)" ## --- ## --- Some functions ## --- usage() { echo [ -n "$1" ] && echo -e "Error: $1\n" cat< If set, logfiles for the new site will go there. -n If set, project name will be used as name of the websites base directory. Otherwise . or .. will be used. -p Only used if type is fcgi ("-t FCGID"). If given, a common existing configuration directory will be used for FCGI configurations. if not given, a site-specific configuration directory will be created. -t One of "PHP-FPM", "FCGID" or "MOD_PHP" If not give, the site url will be requested. -S Only used if type is php-fpm ("-t PHP-FPM"). -q Don't print summary before starting creation the vhost entry is set -u i.e. www.oopen.de If not give, the site url will be requested. -V If set, vhost configuration will be stored there. -v i.e 5.6 If not give, the PHP version will be requested. EOF 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 } # - 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 "$*\\c" 1>&2 else echo -e -n "$*" 1>&2 fi rm /tmp/shprompt$$ } fatal(){ echo "" if [ "X$*" != "X" ]; then echo -e "\t[ \033[31m\033[1mError\033[m ]: $*" echo "" fi echo -e "\t\033[31m\033[1mExiting installation now..\033[m" echo "" rm -f $log_file exit 1 } info (){ echo "" echo -e "\t[ \033[32m\033[1mInfo\033[m ]: $*" echo "" } warn (){ echo "" echo -e "\t[ \033[33m\033[1mWarning\033[m ]: $*" echo "" } error (){ echo "" echo -e "\t[ \033[31m\033[1mError\033[m ]: $*" echo "" } echo_ok() { echo -e "\033[85G[ \033[32mok\033[m ]" ## echo -e " [ ok ]" } echo_failed(){ echo -e "\033[85G[ \033[1;31mfailed\033[m ]" ## echo -e " [ failed ]" } echo_skipped() { echo -e "\033[85G[ \033[30m\033[1mskipped\033[m ]" } ## --- ## --- END: functions ## --- # --- # - Try to determin some server settings # --- _base_webserver_info_needed=false _pass_apache_base_dir=false _pass_web_user=false _pass_server_admin=false # - Determine the installed different PHP major versions # - __major_php_verisons="" _php_installation_dirs=`find /usr/local -mindepth 1 -maxdepth 1 -type l -name "*php-*" -print | sort` for dir in $_php_installation_dirs ; do _major_version="${dir##*-}" __major_php_verisons="$__major_php_verisons $_major_version" done _major_php_verisons=`echo "$__major_php_verisons" | sed 's/^ *//'` # - Determin IP Addresses # - if ifconfig | grep -i -q -E "inet [address|Adresse]:" ; then __ipv4="`ifconfig | grep -e \"^\s*inet Adresse\" | grep -v \"127.0.0.1\" | awk '{print$2}' | cut -d\":\" -f2 | sort | head -1`" __ipv6="`ifconfig | grep -e \"^\s*inet6-Adresse\" | awk '{print$2}' | grep -v -e \"^::1/\" | grep -v -e \"^fe80\" | cut -d\"/\" -f1 | sort | head -1`" else __ipv4="`ifconfig | grep -e \"^\s*inet \" | grep -v \"127.0.0.1\" | awk '{print$2}' | sort | head -1`" __ipv6="`ifconfig | grep -e \"^\s*inet6 \" | awk '{print$2}' | grep -v \"^::1\" | grep -v -e \"^fe80\" | sort | head -1`" fi # - 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 # - Determin websever user/group # - 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 _base_webserver_info_needed=true else _pass_web_user=true fi # - Determin ServerRoot Directory # - apache_base_dir=`$_httpd_binary -t -D DUMP_RUN_CFG | grep ServerRoot | awk '{print$2}' | tr -d '"'` if [ "`realpath /usr/local/apache2`" = "$apache_base_dir" ]; then apache_base_dir="/usr/local/apache2" _apache_base_dir_realpath="`realpath $apache_base_dir`" elif [ -z "$apache_base_dir" ]; then if [ -d "`realpath /usr/local/apache2`" ];then apache_base_dir="/usr/local/apache2" _apache_base_dir_realpath="`realpath $apache_base_dir`" fi else _apache_base_dir_realpath=$apache_base_dir fi if [ -z "$apache_base_dir" ];then _base_webserver_info_needed=true else _pass_apache_base_dir=true fi # - Determin (default) ServerAdmin E-Mail Address" # - if [ -f "${apache_base_dir}/conf/httpd.conf" ]; then server_admin="`cat ${apache_base_dir}/conf/httpd.conf | grep ServerAdmin | grep -v -e \"^\s*#\" | awk '{print$2}'`" fi if [ -z "$server_admin" ];then _base_webserver_info_needed=true else _pass_server_admin=true fi # --- # - Set Default Values # ---- # - Needed for PHP-FPM environment # - _tcp_host=127.0.0.1 _tcp_port=9000 __CUSTOM_IPV4_LOG=ipv4_requests.log __CUSTOM_IPV6_LOG=ipv6_requests.log _suEXEC=false _auto="" site_url="" _type="" _COMMON_FCGID_CONFIG_PATH="" major_php_verison="" _print_summary=true _symlink_web_base_dir="" CREATE_PHPINFO_FILE=true USE_PROJECT_NAME=false PROJECT_NAME="" COMMON_LOGFILE_DIR="" VHOST_DIR="" WEBSITES_ROOT_DIR="" CREATE_SYMLINK_WEB_BASE_DIR=false # --- # - Read Configuration File (if exists) # - # - Note: previously Default Settings will be overwriten # --- script_base_dir="$(realpath $(dirname $0))" conf_file="${script_base_dir}/conf/create_vhost_php.conf" echo "" echononl "\tInclude Configuration file.." if [[ ! -f $conf_file ]]; then echo_skipped else source $conf_file > $log_file 2>&1 if [[ $? -eq 0 ]]; then echo_ok else echo_failed error "$(cat $log_file)" fi fi # --- # - Read in Commandline arguments # - # - Note: previously Settings (also those from configuration file) will be overwriten # --- while getopts aChl:n:p:sS:t:u:V:v: opt ; do case $opt in a) _auto="auto" ;; C) CREATE_PHPINFO_FILE="false" ;; h) usage ;; l) COMMON_LOGFILE_DIR="$OPTARG" ;; n) USE_PROJECT_NAME=true PROJECT_NAME="$OPTARG" ;; p) if [ -n "$OPTARG" -a -d "$OPTARG" ]; then _COMMON_FCGID_CONFIG_PATH=$OPTARG fi ;; q) _print_summary=false ;; S) if [ -n "$OPTARG" -a -S "$OPTARG" ]; then unix_socket=$OPTARG connection="unix_socket" _connection_msg="Unix Socket" fi ;; t) if [ "$OPTARG" = "PHP-FPM" -o "$OPTARG" = "FCGID" -o "$OPTARG" = "MOD_PHP" ]; then _type=$OPTARG fi ;; u) site_url=$OPTARG ;; V) VHOST_BASE_DIR="$OPTARG" ;; v) for _version in $_major_php_verisons ; do if [ "$OPTARG" = "$_version" ]; then major_php_verison=$OPTARG fi done ;; \?) usage esac done echo echo "_auto..............: $_auto" echo "site_url...........: $site_url" echo "_type..............: $_type" echo "COMMON_LOGFILE_DIR.: $COMMON_LOGFILE_DIR" echo "PROJECT_NAME.......: $PROJECT_NAME" echo "fcgi_common_path...: $_COMMON_FCGID_CONFIG_PATH" echo "unix_socket........: $unix_socket" echo "major_php_verison..: $major_php_verison" echo "_print_summary.....: $_print_summary" echo ## -------------------------------------------------- #clear echo echo echo -e "\033[21G\033[32mCreate PHP configuration on webserver \"`hostname -f`\"..\033[m" #echo "" echo "" echo -e "\033[32m--\033[m" echo "" if [ -z "$site_url" ]; then echo "Insert Site (i.e. www.oopen.de)." echo "" echo "" site_url= echononl "Site URL: " read site_url while [ "X$site_url" = "X" ] ; do echo -e "\n\t\033[33m\033[1mEingabe erforderlich.\033[m\n" echononl "Site URL: " read site_url done else echo "Create Configuration for site \"$site_url\".." fi if $USE_PROJECT_NAME && [[ -z "$PROJECT_NAME" ]]; then echo "" echo -e "\033[32m--\033[m" echo "" echo "Insert Project Name." echo "" echo "" PROJECT_NAME= echononl "Project Name: " read PROJECT_NAME while [[ -z "$(trim $PROJECT_NAME)" ]] ; do echo -e "\n\t\033[33m\033[1mEingabe erforderlich.\033[m\n" echononl "Project Name: " read PROJECT_NAME done fi echo "" echo -e "\033[32m--\033[m" echo "" if [ "$_type" != "PHP-FPM" -a "$_type" != "FCGID" -a "$_type" != "MOD_PHP" ];then echo "Select PHP implementation configure for ?" echo "" echo "[1] PHP-FPM (FastCGI Process Manager)" echo "[2] mod_fcgid (Apache FastCGI implementation)" echo "[3] mod_php (Apache PHP Module)" echo "[4] suEXEC ( using mod_fcgid)" echo "" echononl "Your choice: " while [ "$_type" != "PHP-FPM" -a "$_type" != "FCGID" -a "$_type" != "MOD_PHP" ];do read OPTION case $OPTION in 1) _type="PHP-FPM" _type_msg="PHP-FPM (FastCGI Process Manager)" _new_extension=php-fpm ;; 2) _type="FCGID" _type_msg="mod_fcgid (Apache FastCGI implementation)" _new_extension=mod_fcgid ;; 3) _type="MOD_PHP" _type_msg="mod_php (Apache PHP Module)" _new_extension=mod_php ;; 4) _type="FCGID" _suEXEC=true _type_msg="suEXEC (using mod_fcgid)" _new_extension=suexec ;; *) echo "" echo -e "\t\033[1;33mFalsche Eingabe ! [ 1 = PHP-FPM ; 2 = mod_fcgid , 3 = mod_php ]\033[m" echo "" echononl "Your choice: " ;; esac done else if [ "$_type" = "PHP-FPM" ];then _type_msg="PHP-FPM (FastCGI Process Manager)" _new_extension=php-fpm elif [ "$_type" = "FCGID" ]; then if $_suEXEC ; then _type_msg="suEXEC (using mod_fcgid)" _new_extension=suexec else _type_msg="mod_fcgid (Apache FastCGI implementation)" _new_extension=mod_fcgid fi elif [ "$_type" = "MOD_PHP" ]; then _type_msg="mod_php (Apache PHP Module)" _new_extension=mod_php fi echo "Configure PHP implementation for \"$_type\"" fi if $_base_webserver_info_needed ; then if ! $_pass_apache_base_dir ; then echo "" echo "" echo -e "\033[32m--\033[m" echo "" echo "Apache ServerRoot directory." echo "" echo "" apache_base_dir= while [ "X$apache_base_dir" = "X" ] ; do echononl "Apache ServerRoot Directory [$_apache_base_dir]: " read apache_base_dir if [ "X$apache_base_dir" = "X" ]; then apache_base_dir=$_apache_base_dir fi done _apache_base_dir_realpath=`realpath $apache_base_dir 2> /dev/null` if [ ! -d "$_apache_base_dir_realpath" ]; then fatal "Cannot find directory \"$apache_base_dir\"!" fi if [ ! -d "${_apache_base_dir_realpath}/conf/vhosts" ]; then fatal "Cannot find vhost directory. tried \"${_apache_base_dir_realpath}/conf/vhosts\"" fi fi if ! $_pass_server_admin ; then echo "" echo "" echo -e "\033[32m--\033[m" echo "" echo "Insert email address for server admin." echo "" echo "" server_admin= while [ "X$server_admin" = "X" ] ; do #echo -e "\n\t\033[33m\033[1mEingabe erforderlich!\033[m\n" echononl "Email Admin [$_server_admin]: " read server_admin if [ "X$server_admin" = "X" ]; then server_admin=$_server_admin fi done fi if ! $_pass_web_user ; then echo "" echo "" echo -e "\033[32m--\033[m" echo "" echo "Insert User/Group for apache daemon (httpd)." echo "" echo "" web_user= while [ "X$web_user" = "X" ] do echononl "apache user [${_web_user}]: " read web_user if [ "X$web_user" = "X" ]; then web_user=$_web_user fi done if [ "$web_user" = "nobody" ]; then _web_group="nogroup" else _web_group=$web_user fi while [ "X$web_group" = "X" ] do echononl "apache group [$_web_group]: " read web_group if [ "X$web_group" = "X" ]; then web_group=$_web_group fi done fi fi # if $_base_webserver_info_needed ; then ## - Looking for existent VHost Configuration ## - #_vhost_config=`grep -l -r -E "(ServerName|ServerAlias)\s+.*$site_url" ${_apache_base_dir_realpath}/conf/vhosts* 2> /dev/null` _vhost_config=`grep -l -r -E "(ServerName|ServerAlias)\s+$site_url" ${_apache_base_dir_realpath}/conf/vhosts* 2> /dev/null` _existing_vhost_config_file="" if [ -n "$_vhost_config" ]; then declare -i _count=0 for _config_file in $_vhost_config ; do if [ -z "$_config_file" ]; then continue fi [[ "$_config_file" =~ /DELETED/ ]] && continue _extension="${_config_file##*.}" if [ "$_extension" = "swp" ] ; then continue fi if [ "$_extension" = "$_new_extension" ]; then error "Found configuration file \"$_config_file\".\n\n\t It seems, $_type configuration is already done." fatal fi if [ "$_extension" = "conf" ]; then _existing_vhost_config_file=`realpath $_config_file` _new_vhost_config_file=${_config_file}.$_new_extension _new_vhost=false break else _name="${_config_file%.*}" if [ "`realpath $_name`" = "$_config_file" ]; then _existing_vhost_config_file="$_config_file" _new_vhost_config_file=${_name}.$_new_extension _new_vhost=false break fi fi let _count++ done fi if [ -z "$_existing_vhost_config_file" ]; then echo "" echo "" echo -e "\033[33m--\033[m" echo"" echo -e "\033[21G\033[33mNo configuration file found for site \"$site_url\"..\033[m" echo "" echo -e "\033[1;33m--\033[m" echo "" echo "" OK="" echononl "Create a new $_type vhost entry? [yes/no]: " read OK while [ "X$OK" != "Xyes" -a "X$OK" != "XYes" -a "X$OK" != "Xno" -a "X$OK" != "XNo" ]; do echononl "falsche Angabe! [yes/no]: " read OK done [ $OK = "yes" -o $OK = "Yes" ] || fatal Abbruch durch Benutzer _new_vhost=true _config_file_found=false _HOST=`echo $site_url | cut -s -d"." -f 1` _DOMAIN=`echo $site_url | cut -s -d"." -f 2` _TDL=`echo $site_url | cut -s -d"." -f 3` if [ -z "$_TDL" ]; then _TDL=$_DOMAIN _DOMAIN=$_HOST fi if [[ -n "$(trim $WEBSITES_ROOT_DIR)" ]]; then _server_website_root_dir="$WEBSITES_ROOT_DIR" else if [ -d "/var/www/html/projekte" ]; then __server_website_root_dir="/var/www/html/projekte" elif [ -d "/var/www" ]; then __server_website_root_dir="/var/www" fi fi echo "" if [ "$_HOST" = "www" ]; then echo -e "\033[21G\033[32mCreate vhost configuration \"${_DOMAIN}.${_TDL}.conf.$_new_extension\"\033[m" else echo -e "\033[21G\033[32mCreate vhost configuration \"${site_url}.conf.$_new_extension\"\033[m" fi echo "" echo -e "\033[21GInsert needed Information for VHost Configuration.." echo "" if [[ -z "$_server_website_root_dir" ]]; then echo "" echo -e "\033[32m--\033[m" echo "" echo "Servers root directory for websites (i.e. /var/www).." echo "" echo "" _server_website_root_dir= while [ "X$_server_website_root_dir" = "X" ] ; do echononl "Root Directory for websites [$__server_website_root_dir]: " read _doc_root if [ "X$_server_website_root_dir" = "X" ]; then _server_website_root_dir=$__server_website_root_dir fi if [ -n "$_server_website_root_dir" -a ! -d "$_server_website_root_dir" ]; then echo -e "\n\t\033[1;33mDirectory \"$_server_website_root_dir\" does not exist.\n\tTry again..\033[m\n" _server_website_root_dir="" fi done fi if $USE_PROJECT_NAME ; then __web_base_dir=${_server_website_root_dir}/$PROJECT_NAME else if [ "$_HOST" = "www" ]; then __web_base_dir=${_server_website_root_dir}/${_DOMAIN}.$_TDL else __web_base_dir=${_server_website_root_dir}/${site_url} fi fi _server_name=$site_url if [ "$_HOST" = "www" ]; then _server_alias=${_DOMAIN}.$_TDL else _server_alias="" fi #_doc_root="$document_root" echo "" echo -e "\033[32m--\033[m" echo "" echo "Insert Website Base Directory (the directory containing" echo "the Document Root Directory .." echo "" echo "" _web_base_dir= while [ "X$_web_base_dir" = "X" ] ; do echononl "Web Base Directory [$__web_base_dir]: " read _web_base_dir if [ "X$_web_base_dir" = "X" ]; then _web_base_dir=$__web_base_dir fi done __document_root=${_web_base_dir}/htdocs if $CREATE_SYMLINK_WEB_BASE_DIR ; then __symlink_web_base_dir=`basename $_web_base_dir | cut -d '.' -f 1` if [[ "$__symlink_web_base_dir" != "$(basename $_web_base_dir)" ]] ; then echo "" echo -e "\033[32m--\033[m" echo "" echo "It is possible to create a symlink for \"`basename $_web_base_dir`\". You can do" echo "that here bygiving a name for the symlink." echo "" echo -e "Type \"\033[33mNone\033[m\" if no symlink is wanted." echo "" echo "" echononl "Create Symlink for `basename $_web_base_dir`? [$__symlink_web_base_dir]: " read _symlink_web_base_dir if [ "X$_symlink_web_base_dir" = "Xnone" -o "X$_symlink_web_base_dir" = "XNone" ]; then CREATE_SYMLINK_WEB_BASE_DIR=false else CREATE_SYMLINK_WEB_BASE_DIR=true fi if [ "X$_symlink_web_base_dir" = "X" ]; then _symlink_web_base_dir=$__symlink_web_base_dir fi if [ "$_symlink_web_base_dir" = "`basename $_web_base_dir`" ]; then warn "Given name for symlink is equal to `basename $_web_base_dir`.\n\t No symlink will be created.." CREATE_SYMLINK_WEB_BASE_DIR=false fi else CREATE_SYMLINK_WEB_BASE_DIR=false fi fi echo "" echo -e "\033[32m--\033[m" echo "" echo "Insert Document Root Directory.." echo "" echo "" _doc_root= while [ "X$_doc_root" = "X" ] ; do echononl "Document Root Directory [$__document_root]: " read _doc_root if [ "X$_doc_root" = "X" ]; then _doc_root=$__document_root fi if [ "`dirname $_doc_root`" != "$_web_base_dir" ]; then echo -e "\n\t\033[1;33mDocument Root Directory must be a subdirectory of \"$_web_base_dir\".\n\tTry again..\033[m\n" _doc_root= fi done if [[ -n "$(trim $COMMON_LOGFILE_DIR)" ]]; then _log_dir="$COMMON_LOGFILE_DIR" else __log_dir=${_web_base_dir}/logs fi if [[ -z "$_log_dir" ]]; then echo "" echo "" echo -e "\033[32m--\033[m" echo "" echo "Insert Directory where logfiles should stay.." echo "" echo "" _log_dir= while [ "X$_log_dir" = "X" ] ; do echononl "Log Directory [$__log_dir]: " read _log_dir if [ "X$_log_dir" = "X" ]; then _log_dir=$__log_dir fi done fi if [ "$_HOST" = "www" ]; then _combined_custom_log="$_log_dir/${_DOMAIN}-access.log" _error_log="$_log_dir/${_DOMAIN}-error.log" else _combined_custom_log="$_log_dir/${site_url}-access.log" _error_log="$_log_dir/${site_url}-error.log" fi _custom_ipv4_log="" echo if [ -n "$__CUSTOM_IPV4_LOG" ]; then echo -e "Additional Logfiles - Type \"\033[33mNone\033[m\" if not present" echononl "\tAdditional Logfile for IPv4 requests [${__CUSTOM_IPV4_LOG}]: " read _custom_ipv4_log if [ "X$_custom_ipv4_log" = "X" ]; then _custom_ipv4_log=$__CUSTOM_IPV4_LOG fi if [ "X$_custom_ipv4_log" = "XNone" ]; then _custom_ipv4_log="" fi else echo "Additional Logfiles - Leave empty if not present" echononl "\tAdditional Logfile for IPv4 requests: " read _custom_ipv4_log fi if [ -n "$_custom_ipv4_log" ]; then if [ "`dirname $_custom_ipv4_log`" = "." ]; then _custom_ipv4_log=/var/log/apache2/$_custom_ipv4_log fi fi _custom_ipv6_log="" echo "" if [ -n "$__CUSTOM_IPV6_LOG" ]; then echo -e "Additional Logfiles - Type \"\033[33mNone\033[m\" if not present" echononl "\tAdditional Logfile for IPv6 requests [${__CUSTOM_IPV6_LOG}]: " read _custom_ipv6_log if [ "X$_custom_ipv6_log" = "X" ]; then _custom_ipv6_log=$__CUSTOM_IPV6_LOG fi if [ "X$_custom_ipv6_log" = "XNone" ]; then _custom_ipv6_log="" fi else echo "Additional Logfiles - Leave empty if not present" echononl "\tAdditional Logfile for IPv6 requests : " read _custom_ipv6_log fi if [ -n "$_custom_ipv6_log" ]; then #echo "dirname $_custom_ipv6_log: `dirname $_custom_ipv6_log`" if [ "`dirname $_custom_ipv6_log`" = "." ]; then _custom_ipv6_log=/var/log/apache2/$_custom_ipv6_log fi fi if [[ -n "$(trim $VHOST_BASE_DIR)" ]]; then _vhost_base_dir="$VHOST_BASE_DIR" else __vhost_base_dir=${apache_base_dir}/conf/vhosts fi if [[ -z "$_vhost_base_dir" ]]; then echo "" echo "" echo -e "\033[32m--\033[m" echo "" echo "Insert Directory where the vhost configuration file should stay.." echo "" echo "" _vhost_base_dir= while [ "X$_vhost_base_dir" = "X" ] ; do echononl "VHost Base Directory [$__vhost_base_dir]: " read _vhost_base_dir if [ "X$_vhost_base_dir" = "X" ]; then _vhost_base_dir=$__vhost_base_dir fi if [ ! -d "$_vhost_base_dir" ];then echo -e "\n\t\033[1;33mDirectory \"${_vhost_base_dir}\" not found! Try again..\033[m\n" _vhost_base_dir="" fi done fi if [ "$_HOST" = "www" ]; then _new_vhost_config_file=${_vhost_base_dir}/${_DOMAIN}.${_TDL}.conf.$_new_extension else _new_vhost_config_file=${_vhost_base_dir}/${site_url}.conf.$_new_extension fi echo "" echo "" echo -e "\033[32m--\033[m" echo "" echo "Insert the IP-Addresses where the webserver should listen for that site." echo "" echo "" echo "" _ipv4= while [ "X$_ipv4" = "X" ] do if [ -z "$__ipv4" ]; then echononl "IPv4 address: " read _ipv4 if [ "X$_ipv4" = "X" ]; then echo -e "\n\t\033[33m\033[1mEingabe erforderlich!\033[m\n" fi else echononl "IPv4 address [$__ipv4]: " read _ipv4 if [ "X$_ipv4" = "X" ]; then _ipv4=$__ipv4 fi fi done _ipv6= while [ "X$_ipv6" = "X" ] do if [ -z "$__ipv6" ]; then echononl "IPv6 address: " read _ipv6 if [ "X$_ipv6" = "X" ]; then warn "Disable support for IPv6.." _ipv6="disabled" #echononl "Must NOT be empty. Insert again: " fi else echononl "IPv6 address [$__ipv6]: " read _ipv6 if [ "X$_ipv6" = "X" ]; then _ipv6=$__ipv6 fi fi done echo "" echo "" echo -e "\033[32m--\033[m" echo "" echo "Insert more hostnames (ServerAlias) for this site..." echo "" server_aliases= if [ "$_HOST" = "www" ]; then while [ "X$server_aliases" = "X" ]; do echo -e "Type \"\033[33mskip\033[m\" to omit ServerAlias\n" echononl "More hostnames: [$_server_alias]: " read server_aliases if [ "skip" = "$server_aliases" ]; then server_aliases= break fi if [ "X$server_aliases" = "X" ];then server_aliases=$_server_alias fi done else echo -e "Leave empty to omit ServerAlias\n" echononl "More hostnames: " read server_aliases fi for _alias in $server_aliases ; do containsElement "$_alias" "${_server_aliases_arr[@]}" && continue _server_aliases_arr+=("$_alias") done echo "" echo "" echo -e "\033[33m--\033[m" echo"" echo -e "\033[21G\033[33mListen on SSL connectons (HTTPS) for \"$site_url\" ?\033[m" echo "" echo -e "\033[1;33m--\033[m" echo "" echo "" OK="" echononl "Enable SSL? [yes]: " read OK while [ "X$OK" != "Xyes" -a "X$OK" != "XYes" -a "X$OK" != "Xno" -a "X$OK" != "XNo" -a "X$OK" != "X" ]; do echononl "falsche Angabe! [yes]: " read OK done if [ "$OK" = "yes" -o "$OK" = "Yes" -o "X$OK" = "X" ]; then _https=true else _https=false fi if $_https ; then _ommit_ssl_chain_file=false if [ -f "${apache_base_dir}/conf/server-bundle.crt" ]; then __ssl_cert_file="${apache_base_dir}/conf/server-bundle.crt" _ommit_ssl_chain_file=true elif [ -f "${apache_base_dir}/conf/server.crt" ]; then __ssl_cert_file="${apache_base_dir}/conf/server.crt" fi if [ -f "${apache_base_dir}/conf/server.key" ]; then __ssl_key_file="${apache_base_dir}/conf/server.key" fi if ! $_ommit_ssl_chain_file ; then if [ -f "${apache_base_dir}/conf/server-ca-bundle.crt" ]; then __ssl_chain_file="${apache_base_dir}/conf/server-ca-bundle.crt" elif [ -f "${apache_base_dir}/conf/StartSSL_SUB_CLASS2.pem" ]; then __ssl_chain_file="${apache_base_dir}/conf/StartSSL_SUB_CLASS2.pem" elif [ -f "${apache_base_dir}/conf/sub.class2.server.ca.pem" ]; then __ssl_chain_file="${apache_base_dir}/conf/sub.class2.server.ca.pem" elif [ -f "${apache_base_dir}/conf/SSL123_CA_Bundle_SHA2_root_SHA1.pem" ]; then __ssl_chain_file="${apache_base_dir}/conf/SSL123_CA_Bundle_SHA2_root_SHA1.pem" elif [ -f "${apache_base_dir}/conf/SSL123_CA_Bundle.pem" ]; then __ssl_chain_file="${apache_base_dir}/conf/SSL123_CA_Bundle.pem" fi fi #clear echo "" echo -e "\033[21G\033[32mCreate vhost configuration \"${_DOMAIN}.${_TDL}.conf.$_new_extension\"\033[m" echo "" echo -e "\033[21GInsert Parameters needed for SSL.." echo "" echo -e "\033[1;32m--\033[m" echo "" echo -e "Input SSL Key file.." echo "" echo "" _ssl_key_file= while [ "X$_ssl_key_file" = "X" ] ; do if [ -z "$__ssl_key_file" ]; then echononl "SSL Keyfile: " read _ssl_key_file if [ "X$_ssl_key_file" = "X" ]; then echo -e "\n\t\033[33m\033[1mEingabe erforderlich!\033[m\n" continue fi else echononl "SSL Keyfile [$__ssl_key_file]:" read _ssl_key_file if [ "X$_ssl_key_file" = "X" ]; then _ssl_key_file=$__ssl_key_file fi fi done echo "" echo "" echo -e "\033[1;32m--\033[m" echo "" echo -e "Input SSL Certification file.." echo "" echo "" _ssl_cert_file= while [ "X$_ssl_cert_file" = "X" ] ; do if [ -z "$__ssl_cert_file" ]; then echononl "SSL certification file: " read _ssl_cert_file if [ "X$_ssl_cert_file" = "X" ]; then echo -e "\n\t\033[33m\033[1mEingabe erforderlich!\033[m\n" continue fi else echononl "SSL certification file [$__ssl_cert_file]:" read _ssl_cert_file if [ "X$_ssl_cert_file" = "X" ]; then _ssl_cert_file=$__ssl_cert_file fi fi done echo "" echo "" echo -e "\033[1;32m--\033[m" echo "" echo -e "Input SSL Certification Chain file.." echo "" echo "" _ssl_chain_file= if ! $_ommit_ssl_chain_file ; then #while [ "X$_ssl_chain_file" = "X" ] ; do if [ -z "$__ssl_chain_file" ]; then echononl "SSL Certification Chain file: " read _ssl_chain_file if [ "X$_ssl_chain_file" = "X" ]; then warn "No SSL Certification Chain file given. \"SSLCertificateChainFile\" Directive will be omitted!" fi else echononl "SSL Certification Chain file [$__ssl_chain_file]: " read _ssl_chain_file if [ "X$_ssl_chain_file" = "X" ]; then _ssl_chain_file=$__ssl_chain_file fi fi #done fi fi else _config_file_found=true info "Found configuration file \"`basename $_existing_vhost_config_file`\".\n" echo -e -n "\tReading configurations from that file.." _vhost_base_dir=`dirname $_existing_vhost_config_file` declare -i number_errors=0 declare -i number_warnings=0 _server_name="" _server_name_failed=false ## - Create empty array ## - _server_aliases_arr=() _server_alias="" _doc_root="" #_new_doc_root="" _doc_root_failed=false _combined_custom_log="" _combined_custom_log_failed=false _custom_ipv4_log="" _custom_ipv4_log_failed=false _custom_ipv6_log="" _custom_ipv6_log_failed=false _error_log="" _error_log_failed=false _https=false _ssl_cert_file="" _ssl_key_file="" _ssl_chain_file="" while read line ; do ## - Get ServerName ## - if echo $line | grep -e "^\s*ServerName" > /dev/null ; then _server_name_tmp=`echo $line | awk '{print$2}'` if [ -z "$_server_name" ]; then _server_name=$_server_name_tmp elif [ "$_server_name" != "$_server_name_tmp" ]; then if [ $number_errors -eq 0 ]; then echo fi error "Misconfigured ServerName" _server_name_failed=true let number_errors++ fi continue fi ## - Get ServerAlias if echo $line | grep -e "^\s*ServerAlias" > /dev/null ; then _server_alias_tmp=$(echo $line | sed -e "s/ServerAlias//" | sed "s/^\s*//" | sed "s/\s*$//") #_server_alias_tmp=`echo $line | awk '{print$2}'` if [ ${#_server_aliases_arr[@]} -eq 0 ] ; then for _alias in $_server_alias_tmp ; do _server_aliases_arr+=("$_alias") done else for _alias in $_server_alias_tmp ; do containsElement "$_alias" "${_server_aliases_arr[@]}" && continue _server_aliases_arr+=("$_alias") done fi continue fi ## - Get DocumentRoot ## - if echo $line | grep -e "^\s*DocumentRoot" > /dev/null ; then _doc_root_tmp=`echo $line | awk '{print$2}' | sed 's/"//g' | sed 's/\/$//'` if [ -z "$_doc_root" ]; then _doc_root=$_doc_root_tmp elif [ "$_doc_root" != "$_doc_root_tmp" ]; then if [ $number_errors -eq 0 ]; then echo fi error "Misconfigured DocumentRoot" _doc_root_failed=true let number_errors++ fi continue fi ## - Get CustomLog (combined) ## - if echo $line | grep -e "^\s*CustomLog" | grep "combined"> /dev/null ; then _combined_custom_log_tmp=`echo $line | awk '{print$2}' | sed 's/"//g' | sed 's/\/$//'` if [ -z "$_combined_custom_log" ]; then _combined_custom_log=$_combined_custom_log_tmp elif [ "$_combined_custom_log" != "$_combined_custom_log_tmp" ]; then if [ $number_warnings -eq 0 ]; then echo fi warn "Misconfigured CustomLog (combined)" _combined_custom_log_failed=true let number_warnings++ fi continue fi ## - Get additional CustomLog IPv4 requests ## - if echo $line | grep -e "^\s*CustomLog" | grep -i "ipv4" > /dev/null ; then _custom_ipv4_log_tmp=`echo $line | awk '{print$2}' | sed 's/"//g' | sed 's/\/$//'` if [ -n "$_custom_ipv4_log_tmp" ];then if [ -z "$_custom_ipv4_log" ]; then _custom_ipv4_log=$_custom_ipv4_log_tmp elif [ "$_custom_ipv4_log" != "$_custom_ipv4_log_tmp" ]; then if [ $number_warnings -eq 0 ]; then echo fi warn "Misconfigured CustomLog IPv4 requests" _custom_ipv4_log_failed=true let number_warnings++ fi fi continue fi ## - Get additional CustomLog IPv6 requests ## - if echo $line | grep -e "^\s*CustomLog" | grep -i "ipv6" > /dev/null ; then _custom_ipv6_log_tmp=`echo $line | awk '{print$2}' | sed 's/"//g' | sed 's/\/$//'` if [ -n "$_custom_ipv6_log_tmp" ];then if [ -z "$_custom_ipv6_log" ]; then _custom_ipv6_log=$_custom_ipv6_log_tmp elif [ "$_custom_ipv6_log" != "$_custom_ipv6_log_tmp" ]; then if [ $number_warnings -eq 0 ]; then echo fi warn "Misconfigured CustomLog IPv6 requests" _custom_ipv6_log_failed=true let number_warnings++ fi fi continue fi ## - Get ErrorLog ## - if echo $line | grep -e "^\s*ErrorLog" > /dev/null ; then _error_log_tmp=`echo $line | awk '{print$2}' | sed 's/"//g' | sed 's/\/$//'` if [ -z "$_error_log" ]; then _error_log=$_error_log_tmp elif [ "$_error_log" != "$_error_log_tmp" ]; then if [ $number_warnings -eq 0 ]; then echo fi warn "Misconfigured ErrorLog" _error_log_failed=true let number_warnings++ fi continue fi ## - HTTPS ? ## - if echo $line | grep -e "^\s*SSLEngine" > /dev/null ; then _https=true continue fi ## - GET SSLCertificateFile ## - if echo $line | grep -e "^\s*SSLCertificateFile" > /dev/null ; then _ssl_cert_file=`echo $line | awk '{print$2}' | sed 's/"//g' | sed 's/\/$//'` continue fi ## - GET SSLCertificateKeyFile ## - if echo $line | grep -e "^\s*SSLCertificateKeyFile" > /dev/null ; then _ssl_key_file=`echo $line | awk '{print$2}' | sed 's/"//g' | sed 's/\/$//'` continue fi ## - GET SSLCertificateChainFile ## - if echo $line | grep -e "^\s*SSLCertificateChainFile" > /dev/null ; then _ssl_chain_file=`echo $line | awk '{print$2}' | sed 's/"//g' | sed 's/\/$//'` continue fi ## - Get IPv4 Address ## - if echo $line | grep -e "\s* /dev/null 2>&1 ; then _ipv4=`echo $line | awk '{print$2}' | cut -d ':' -f 1` continue fi ## - Get IPv6 Address ## - if echo $line | grep -e "\s* /dev/null 2>&1 ; then _ipv6=`echo $line | awk '{print$2}' | cut -d ']' -f 1 | cut -d '[' -f 2 ` continue fi done < $_existing_vhost_config_file if ! $_server_name_failed ; then if [ -z "$_server_name" ] ; then if [ $number_errors -eq 0 ]; then echo fi error "No ServerName found" let number_errors++ #else # echo -e "\tServerName = $_server_name" fi fi #if [ ${#_server_aliases_arr[@]} -gt 0 ] ; then # echo -e "\tServerAlias = ${_server_aliases_arr[@]}" #fi if ! $_doc_root_failed ; then if [ -z "$_doc_root" ]; then if [ $number_warnings -eq 0 ]; then echo fi warn "No DocumentRoot found" let number_warnings++ else _web_base_dir=`dirname $_doc_root` #echo -e "\tDocumentRoot = $_doc_root" if [ "`basename $_web_base_dir`" = "htdocs" ]; then _web_base_dir=`dirname $_web_base_dir` fi fi fi if ! $_combined_custom_log_failed ; then _combined_custom_log_dir="`dirname $_combined_custom_log`" fi if ! $_error_log_failed ; then _error_log_dir="`dirname $_error_log`" fi if [ "$_error_log_dir" != "$_combined_custom_log_dir" ]; then if [ $number_warnings -eq 0 ]; then echo fi warn "CustomLog and ErrorLog lives in different directories" let number_warnings++ else _log_dir="$_combined_custom_log_dir" fi #if [ -n "$_web_base_dir" ];then # echo -e "\tWeb base dir = $_web_base_dir" # echo "" #fi if [ -z "$_ipv4" ];then if [ $number_warnings -eq 0 ]; then echo fi warn "Keine IPv4 Adresse gefunden." let number_warnings++ #else # echo -e "\tIPv4 = $_ipv4" fi if [ -z "$_ipv6" ];then _ipv6="disabled" if [ $number_warnings -eq 0 ]; then echo fi warn "Keine IPv6 Adresse gefunden." let number_warnings++ #else # echo -e "\tIPv6 = $_ipv6" # echo "" fi if $_https ; then #echo -e "\tHTTPS = $_https" if [ -z "$_ssl_cert_file" ]; then if [ $number_warnings -eq 0 ]; then echo fi warn "No SSLCertificateFile found, but https is on!" let number_warnings++ #else # echo -e "\tSSLCertificateFile = $_ssl_cert_file" fi if [ -z "$_ssl_key_file" ]; then if [ $number_warnings -eq 0 ]; then echo fi warn "No SSLCertificateKeyFile found, but https is on!" let number_warnings++ #else # echo -e "\tSSLCertificateKeyFile = $_ssl_key_file" fi if [ -z "$_ssl_chain_file" ]; then if [ $number_warnings -eq 0 ]; then echo fi warn "No SSLCertificateChainFile found, but https is on!" let number_warnings++ #else # echo -e "\tSSLCertificateChainFile = $_ssl_chain_file" fi fi if [ $number_warnings -eq 0 -a $number_errors -eq 0 ]; then echo_ok else if [ $number_errors -gt 0 ]; then #echo_failed error "$number_warnings Warnings - $number_errors Errors" fatal else info "Reading Parameters finisched with $number_warnings Warnings" fi fi fi if [ "$_type" = "FCGID" ]; then echo "" echo "" echo -e "\033[33m--\033[m" echo"" #echo -e "Use a common (existing) FCGID-configuration?" #echo "" #echo -e "\033[1;33m--\033[m" #echo "" #echo "" OK="" if $_suEXEC ; then echononl "suEXEC User: " read suEXEC_user while [ "X$suEXEC_user" = "X" ]; do echononl "suEXEC User is mandatory. Try again: " read suEXEC_user done echononl "suEXEC Group [$suEXEC_user]: " read suEXEC_group if [ "X$suEXEC_group" = "X" ]; then suEXEC_group=$suEXEC_user fi getent shadow $suEXEC_user > /dev/null if [ "$?" != "0" ]; then _suEXEC_passwd_1="X" _suEXEC_passwd_2="Y" while [ "$_suEXEC_passwd_1" != "$_suEXEC_passwd_2" ]; do echononl "Password for User \"$suEXEC_user\": " read -s _suEXEC_passwd_1 echo if [ "X$_suEXEC_passwd_1" = "X" ]; then echo -e "\n\t\033[33m\033[1mPassword is mandatory!\033[m\n" continue fi echononl "Repeat password for User \"$suEXEC_user\": " read -s _suEXEC_passwd_2 echo if [ "X$_suEXEC_passwd_2" = "X" ]; then echo -e "\n\t\033[33m\033[1mPasswordretry is mandatory!\033[m\n" continue fi if [ "$_suEXEC_passwd_1" != "$_suEXEC_passwd_2" ]; then echo -e "\n\t\033[33m\033[1mSorry, passwords do not match\033[m\n" else suEXEC_password=$_suEXEC_passwd_1 fi done set_suEXEC_password=true else suEXEC_password=false fi _COMMON_FCGI_CONFIG=false else if [ -n "$_COMMON_FCGID_CONFIG_PATH" -a -d "$_COMMON_FCGID_CONFIG_PATH" ] ; then if [ "$_auto" = "auto" -o "$_auto" = "full-auto" ]; then _COMMON_FCGI_CONFIG=true else echononl "Use a common (existing) FCGID-configuration? [yes]: " read OK while [ "X$OK" != "Xyes" -a "X$OK" != "XYes" -a "X$OK" != "Xno" -a "X$OK" != "XNo" -a "X$OK" != "X" ]; do echononl "falsche Angabe! [yes/no]: " read OK done if [ "$OK" = "yes" -o "$OK" = "Yes" -o "X$OK" = "X" ]; then _COMMON_FCGI_CONFIG=true else _COMMON_FCGI_CONFIG=false FCGI_Wrapper="${_web_base_dir}/conf/fcgid .php" fi fi else echononl "Use a common (existing) FCGID-configuration? [no]: " read OK while [ "X$OK" != "Xyes" -a "X$OK" != "XYes" -a "X$OK" != "Xno" -a "X$OK" != "XNo" -a "X$OK" != "X" ]; do echononl "falsche Angabe! [yes/no]: " read OK done if [ "$OK" = "yes" -o "$OK" = "Yes" ]; then _COMMON_FCGI_CONFIG=true else _COMMON_FCGI_CONFIG=false FCGI_Wrapper="${_web_base_dir}/conf/fcgid .php" fi fi fi echo if $_COMMON_FCGI_CONFIG ; then if [ -n "$_COMMON_FCGID_CONFIG_PATH" -a -d "$_COMMON_FCGID_CONFIG_PATH" -a "$_auto" = "auto" ]; then common_fcgi_config_path=$_COMMON_FCGID_CONFIG_PATH else common_fcgi_config_path= if [ -n "$_COMMON_FCGID_CONFIG_PATH" -a -d "$_COMMON_FCGID_CONFIG_PATH" ] ; then while [ "X$common_fcgi_config_path" = "X" ] ; do echononl "Path to common FCGIG configuration [$_COMMON_FCGID_CONFIG_PATH]: " read common_fcgi_config_path if [ "X$common_fcgi_config_path" = "X" ]; then common_fcgi_config_path=$_COMMON_FCGID_CONFIG_PATH fi done else while [ "X$common_fcgi_config_path" = "X" ] ; do echononl "Path to common FCGIG configuration: " read common_fcgi_config_path if [ -n "$common_fcgi_config_path" -a ! -d "$common_fcgi_config_path" ] ; then echo -e "\n\t\033[1;33mDiectory \"common_fcgi_config_path\" not found! Try again..\033[m\n" fi done fi fi FCGI_Wrapper="${common_fcgi_config_path}/conf/fcgid .php" fi fi if [ "$_type" != "MOD_PHP" ]; then #if ! $_config_file_found ; then # clear #fi echo "" #echo -e "\033[21G\033[32mCreate vhost configuration \"${_DOMAIN}.${_TDL}.conf.$_new_extension\"\033[m" echo -e "\033[21G\033[32mCreate vhost configuration \033[m\"`basename $_new_vhost_config_file`\"" echo "" if [ "$_type" = "FCGID" -a "$_COMMON_FCGI_CONFIG" = "true" ] ; then echo -e "\033[21G\033[32mUsing FCGID configuration defined in \033[m\"$common_fcgi_config_path\"" #sleep 2 else if [ "X$major_php_verison" = "X" ]; then echo -e "\033[21GInsert Parameters needed for PHP Configuration.." echo "" echo -e "\033[32m--\033[m" echo "" echo "Input PHP major version to use for $site_url (${_major_php_verisons})" echo "" echo "" major_php_verisons= while [ "X$major_php_verison" = "X" ] ; do echononl "PHP major version: " read major_php_verison if [ "X$major_php_verison" = "X" ]; then echo -e "\n\t\033[33m\033[1mEingabe erforderlich!\033[m\n" continue fi #if [ ! -d "/usr/local/php-$major_php_verison" -o ! -h "/usr/local/php-$major_php_verison" ];then if [ ! -d "/usr/local/php-$major_php_verison" ];then echo -e "\n\t\033[1;33mNo installation for PHP v$major_php_verison found! Try again..\033[m\n" major_php_verison="" fi done else echo -e "\033[21G\033[32mUsing PHP Veriosnn \033[m\"$major_php_verison\"" fi if $_suEXEC ; then FCGI_Wrapper="${_web_base_dir}/conf/fcgid-${major_php_verison} .php" fi fi else echo -e "\033[21G\033[32mUsing PHP Version from mod_php at Apache Installation" fi if [ "$_type" = "PHP-FPM" ]; then if [ "$connection" != "unix_socket" -a "$connection" != "tcp_connection" ]; then echo "" echo -e "\033[32m--\033[m" echo "" echo "Use unix socket or tcp for connection to PHP-FPM ?" echo "" echo "[1] Unix Socket" echo "[2] TCP Conection" echo "" echononl "Your choice: " while [ "$connection" != "unix_socket" -a "$connection" != "tcp_connection" ];do read OPTION case $OPTION in 1) connection="unix_socket" _connection_msg="Unix Socket" ;; 2) connection="tcp_connection" _connection_msg="TCP Conection" ;; *) echo "" echo -e "\t\033[1;33mFalsche Eingabe ! [ 1 = Unix Socket ; 2 = TCP Conection ]\033[m" echo "" echononl "Your choice: " ;; esac done fi if [ "$connection" == "unix_socket" ]; then if [ "X$unix_socket" = "X" ] ; then _unix_socket=`ls /tmp/php-${major_php_verison}*.sock 2>/dev/null` echo "" echo -e "\033[32m--\033[m" echo "" echo "" echo "Where to find the unix php-fpm socket.." echo "" echo "" unix_socket= while [ "X$unix_socket" = "X" ] ; do echononl "Unix PHP-FPM socket [$_unix_socket]: " read unix_socket if [ "X$unix_socket" = "X" ]; then unix_socket=$_unix_socket fi if [ ! -S "$unix_socket" ]; then echo -e "\n\t\033[1;33mNo Unix Socket found at \"unix_socket\"! Try again..\033[m\n" unix_socket="" fi done else echo -e "\033[21G\033[32mUsing Unix Socket \033[m\"$unix_socket\"" fi 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\"" else echo "" echo "" echo "Insert TCP Host and TCP Port for connection to PHP-FPM.." echo "" echo "" tcp_host= while [ "X$tcp_host" = "X" ] ; do echononl "TCP Host [$_tcp_host]: " read tcp_host if [ "X$tcp_host" = "X" ]; then tcp_host=$_tcp_host fi done echo "" tcp_port= while [ "X$tcp_port" = "X" ] ; do echononl "TCP port [$_tcp_port]: " read tcp_port if [ "X$tcp_port" = "X" ]; then tcp_port=$_tcp_port fi done _proxy_match="^/(.*\.php(/.*)?)\$ fcgi://$tcp_host:$tcp_port$_doc_root/\$1" _set_handler_fpm="\"proxy:fcgi://$tcp_host:$tcp_port\"" fi fi #clear if $_print_summary ; then echo "" echo "" echo -e "\033[21G\033[32mCreate environment for site \033[m$site_url\033[32m :\033[m" echo "" if [[ -n "$PROJECT_NAME" ]]; then echo "" echo -e "Project Name......................: \033[1m$PROJECT_NAME\033[m" fi echo "" echo -e "PHP environment...................: \033[33m\033[1m${_type_msg}\033[m" if [ "$_type" = "FCGID" ]; then if [ "$_type" = "FCGID" -a "$_COMMON_FCGI_CONFIG" = "true" ]; then echo -e "PHP major version.................: Using from common FCGID configuration" echo " Common FCGID config directory..: $common_fcgi_config_path" else echo -e "PHP major version.................: \033[33m\033[1m$major_php_verison\033[m" fi echo " FCGIWrapper Entry..............: $FCGI_Wrapper" fi if [ "$_type" = "PHP-FPM" ]; then echo -e "PHP major version.................: \033[33m\033[1m$major_php_verison\033[m" if [ "$connection" = "unix_socket" ]; then echo " PHP-FPM using Unix Socket......: $unix_socket" else echo " PHP-FPM using TCP Connection...: ${tcp_host}:$tcp_port" fi echo " ProxyPassMatch Directive.......: $_proxy_match" fi if [ "$_type" = "MOD_PHP" ]; then echo -e "PHP major version.................: PHP Version from mod_php at Apache Installation" fi if $_suEXEC ; then echo " suEXEC User....................: $suEXEC_user" echo " suEXEC Group...................: $suEXEC_group" fi echo "" echo "Apache Installationsverzeichnis...: $apache_base_dir ($_apache_base_dir_realpath)" echo "Apache User.......................: $web_user" echo "Apache Group......................: $web_group" echo "" echo "IPv4 Address......................: $_ipv4" echo "IPv6 Address......................: $_ipv6" echo "" echo "Listen also for HTTPS connections.: $_https" if $_https ; then echo " SSL Key File...................: $_ssl_key_file" echo " SSL Certificate File...........: $_ssl_cert_file" if [ -n "$_ssl_chain_file" ]; then echo " SSL Certificate Chain File.....: $_ssl_chain_file" else echo -e " SSL Certificate Chain File.....: [ \033[33m\033[1mNot given!\033[m ]: \"SSLCertificateChainFile\" Directive will be omitted!" fi fi echo "" echo "Site URL..........................: $site_url" echo "" echo "ServerName........................: $_server_name" echo "ServerAlias(es)...................: ${_server_aliases_arr[@]}" echo "" echo "Base Directory for site...........: $_web_base_dir" if $CREATE_SYMLINK_WEB_BASE_DIR ; then echo "Symlink for Base Directory........: `dirname $_web_base_dir`/$_symlink_web_base_dir" fi echo "Document Root Directory...........: $_doc_root" echo "" echo "Logfile Directory.................: $_log_dir" echo " CustomLog......................: $_combined_custom_log" echo " ErrorLog.......................: $_error_log" if [ -n "$_custom_ipv4_log" ]; then echo " Additional Logfile IPv4........: $_custom_ipv4_log" fi if [ -n "$_custom_ipv6_log" ]; then echo " Additional Logfile IPv6........: $_custom_ipv6_log" fi echo "" echo "VHost Base Directory..............: $_vhost_base_dir" echo "VHost configuration file..........: $_new_vhost_config_file" echo "" echo "" echo "" echononl "Parameters ok? [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 Repeat installation with different parameters fi if $_suEXEC ; then echo echo -e "\t---" echo -e "\t--- Create suEXEC Environment.." echo -e "\t---" echo"" getent passwd $suEXEC_user > /dev/null if [ "$?" = "0" ]; then echononl "\tUser/Group for suEXEC already exists.." echo_skipped _suEXEC_group=`id -gn $suEXEC_user` if [ "$_suEXEC_group" != "$suEXEC_group" ]; then warn "Changing suEXEC Group to \"$_suEXEC_group\"" suEXEC_group=$_suEXEC_group fi else #if [ "$suEXEC_user" != "$suEXEC_group" ]; then echononl "\tAdding Group \"$suEXEC_group\".." getent group $suEXEC_group > /dev/null if [ "$?" = "0" ]; then echo_skipped else groupadd $suEXEC_group if [ "$?" = "0" ]; then echo_ok else echo_failed error "Cannot create Group \"$suEXEC_group\"." fatal fi fi #fi echononl "\tAdding User \"$suEXEC_user\".." useradd -g $suEXEC_group -d $_web_base_dir -s /bin/bash -m $suEXEC_user if [ "$?" = "0" ]; then echo_ok else echo_failed error "Cannot create User \"$suEXEC_user\"." fatal fi fi echononl "\tSetting Password for user \"$suEXEC_user\".." if $set_suEXEC_password ; then echo "${suEXEC_user}:$suEXEC_password" | chpasswd if [ "$?" = "0" ]; then echo_ok else echo_failed fi else echo_skipped fi fi ## - Create needed directories ## - echo echo -e "\t---" echo -e "\t--- Create needed Directories" echo -e "\t---" echo"" #echo "" #echo "`dirname $_web_base_dir`/$_symlink_web_base_dir" #echo "" if [[ "X${_symlink_web_base_dir}" != "X" ]]; then if [ -d "`dirname $_web_base_dir`/$_symlink_web_base_dir" ]; then echo -e "\tMove `dirname $_web_base_dir`/$_symlink_web_base_dir to" echononl "\t $(dirname $_web_base_dir)/${_symlink_web_base_dir}.`date +%Y%m%d-%H%M`" mv `dirname $_web_base_dir`/$_symlink_web_base_dir \ `dirname $_web_base_dir}`/${_symlink_web_base_dir}.`date +%Y%m%d-%H%M` if [ "$?" = "0" ]; then echo_ok else echo_failed error "Cannot backup directory $(dirname $_web_base_dir)/${_symlink_web_base_dir}!" fi elif [ -f "`dirname $_web_base_dir`/$_symlink_web_base_dir" ]; then echononl "\tBackup existing file `dirname $_web_base_dir`/$_symlink_web_base_dir" mv $(dirname $_web_base_dir)/$_symlink_web_base_dir \ $(dirname $_web_base_dir)/$_symlink_web_base_dir.$(date +%Y%m%d-%H%M) if [ "$?" = "0" ]; then echo_ok else echo_failed error "Cannot backup file `dirname $_web_base_dir`/`basename $_web_base_dir`!" fi fi fi echononl "\tCreate Web Base directory \"$_web_base_dir\".." if [ ! -d "$_web_base_dir" ]; then mkdir $_web_base_dir if [ "$?" = "0" ]; then echo_ok else echo_failed error "Cannot create web base directory \"$_web_base_dir\"." fatal fi else echo_skipped fi echononl "\tChange owner of Web Base directory \"$_web_base_dir\".." if $_suEXEC ; then chown -R ${suEXEC_user}:$suEXEC_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 if $CREATE_SYMLINK_WEB_BASE_DIR ; then echononl "\tCreate Symlink $_symlink_web_base_dir --> `basename $_web_base_dir`" if [ -h "`dirname $_web_base_dir`/$_symlink_web_base_dir" ]; then echo_skipped elif [ -d "`dirname $_web_base_dir`/$_symlink_web_base_dir" ]; then cp -a `dirname $_web_base_dir`/$_symlink_web_base_dir/* `dirname $_web_base_dir`/$_symlink_web_base_dir.`date +%Y%m%d-%H%M` else ln -s `basename $_web_base_dir` `dirname $_web_base_dir`/$_symlink_web_base_dir if [ "$?" = "0" ]; then echo_ok else echo_failed error "Cannot create Symlink $_symlink_web_base_dir -> `basename $_web_base_dir`." fi fi fi echononl "\tCreate \"DocumentRoot\" directory.." if [ ! -d "$_doc_root" ]; then mkdir $_doc_root if [ "$?" = "0" ]; then echo_ok else echo_failed error "Cannot create document root directory \"$_doc_root\"." fatal fi else echo_skipped fi echononl "\tChange owner of \"DocumentRoot\" directory.." if $_suEXEC ; then chown -R ${suEXEC_user}:$suEXEC_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 echononl "\tCreate Logfile directory.." if [ ! -d "$_log_dir" ]; then mkdir $_log_dir if [ "$?" = "0" ]; then echo_ok #echononl "\tChange owner for Logfile directory.." #chown -R ${web_user}:${web_group} $_log_dir #if [ "$?" = "0" ]; then # echo_ok #else # echo_failed # error "Cannot change owner for directory \"$_log_dir\"" # fatal #fi else echo_failed error "Cannot create logfile directory \"$_log_dir\"." fatal fi else echo_skipped fi if [ "$_type" = "FCGID" -a "$_COMMON_FCGI_CONFIG" = "false" ]; then echononl "\tCreate fcgid configuration directory.." if [ ! -d "${_web_base_dir}/conf" ]; then mkdir ${_web_base_dir}/conf if [ "$?" = "0" ]; then echo_ok else echo_failed error "Cannot create fcgid configuration directory \"${_web_base_dir}/conf\"." fatal fi else echo_skipped fi echononl "\tChange owner of Configuration directory.." if $_suEXEC ; then chown -R ${suEXEC_user}:$suEXEC_group ${_web_base_dir}/conf else chown -R root:${web_group} ${_web_base_dir}/conf fi if [ "$?" = "0" ]; then echo_ok else echo_failed error "Cannot change owner of directory \"${_web_base_dir}/conf\"" fatal fi #if $_suEXEC ; then # echononl "\tChange owner of Configuration directory.." # chown -R ${suEXEC_user}:$suEXEC_group ${_web_base_dir}/conf # if [ "$?" = "0" ]; then # echo_ok # else # echo_failed # error "Cannot change owner of directory \"${_web_base_dir}/conf\"" # fatal # fi #fi echononl "\tCreate Session directory.." if [ ! -d "${_web_base_dir}/sessions" ]; then mkdir ${_web_base_dir}/sessions if [ "$?" = "0" ]; then echo_ok else echo_failed error "Cannot create session directory \"${_web_base_dir}/sessions\"." fatal fi else echo_skipped fi echononl "\tChange owner of Session directory.." if $_suEXEC ; then chown -R ${suEXEC_user}:$suEXEC_group ${_web_base_dir}/sessions else chown -R ${web_user}:${web_group} ${_web_base_dir}/sessions fi if [ "$?" = "0" ]; then echo_ok else echo_failed error "Cannot change owner of directory \"${_web_base_dir}/sessions\"" fatal fi echononl "\tCreate TMP directory.." if [ ! -d "${_web_base_dir}/tmp" ]; then mkdir ${_web_base_dir}/tmp if [ "$?" = "0" ]; then echo_ok else echo_failed error "Cannot create tmp directory \"${_web_base_dir}/tmp\"." fatal fi else echo_skipped fi echononl "\tChange owner of TMP directory.." if $_suEXEC ; then chown -R ${suEXEC_user}:$suEXEC_group ${_web_base_dir}/tmp else chown -R ${web_user}:${web_group} ${_web_base_dir}/tmp fi if [ "$?" = "0" ]; then echo_ok else echo_failed error "Cannot change owner of directory \"${_web_base_dir}/tmp\"" fatal fi ## - Create FCGID-Environment ## - echo echo echo -e "\t---" echo -e "\t--- Create \"$_type\"-Environment" echo -e "\t---" echo"" echononl "\tChange into \"fcgid\" configuration directory.." cd ${_web_base_dir}/conf if [ "$?" = "0" ]; then echo_ok else echo_failed error "Cannot change into directory \"${_web_base_dir}/conf\"" fatal fi _php_version_link= for _php_version in $_major_php_verisons ; do if [ -d /usr/local/php-$_php_version ]; then if [ -f /usr/local/php-${_php_version}/etc/php.ini ]; then _php_ini_file=${_web_base_dir}/conf/php.ini-$_php_version if [ -f "$_php_ini_file" ]; then echononl "\tSichere existierende Konfiguration" mv $_php_ini_file ${_php_ini_file}.`date +%Y%m%d-%H%M` if [ "$?" = 0 ]; then echo_ok else echo_failed error "Kann bestehende Konfigurationsdatei \"$_new_vhost_config_file.\" nicht sichern!" fatal fi fi ## - Adjust php.ini-$_php_version ## - cp /usr/local/php-${_php_version}/etc/php.ini $_php_ini_file chmod 640 $_php_ini_file if $_suEXEC ; then chown root:$suEXEC_group $_php_ini_file else chown root:$web_group $_php_ini_file fi ## - Set error_log = ${_web_base_dir}/logs/php_errors.log ## - _key="error_log" _val="${_web_base_dir}/logs/php_errors.log" echononl "\tphp.ini-$_php_version: $_val = $_key" _retval="" if grep -e "^\s*${_key}\s*=" $_php_ini_file > /dev/null 2>&1 ; then #sed -i "0,/^\([ \t]*${_key}[ \t]*=.*\)/ s##;\1\n${_key} = \"${_val}\"#" $_php_ini_file 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 _retval=$? fi if [ -z "$_retval" ]; then echo_skipped elif [ "$_retval" = "0" ]; then echo_ok else echo_failed fi touch $_val if $_suEXEC ; then chown -R ${suEXEC_user}:$suEXEC_group $_val else chown -R ${web_user}:${web_group} $_val fi ## - Set sys_temp_dir = ${_web_base_dir}/tmp ## - _key="sys_temp_dir" _val="${_web_base_dir}/tmp" echononl "\tphp.ini-$_php_version: $_val = $_key" _retval="" 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 _retval=$? fi if [ -z "$_retval" ]; then echo_skipped elif [ "$_retval" = "0" ]; then echo_ok else echo_failed fi ## - Set upload_tmp_dir = ${_web_base_dir}/tmp ## - _key="upload_tmp_dir" _val="${_web_base_dir}/tmp" echononl "\tphp.ini-$_php_version: $_val = $_key" _retval="" 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 _retval=$? fi if [ -z "$_retval" ]; then echo_skipped elif [ "$_retval" = "0" ]; then echo_ok else echo_failed fi ## - Set session.save_path = ${_web_base_dir}/sessions ## - _key="session.save_path" _val="${_web_base_dir}/sessions" echononl "\tphp.ini-$_php_version: $_val = $_key" _retval="" 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 _retval=$? fi if [ -z "$_retval" ]; then echo_skipped elif [ "$_retval" = "0" ]; then echo_ok else echo_failed fi ## - Set soap.wsdl_cache_dir = ${_web_base_dir}/tmp ## - _key="soap.wsdl_cache_dir" _val="${_web_base_dir}/tmp" echononl "\tphp.ini-$_php_version: $_val = $_key" _retval="" 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 _retval=$? fi if [ -z "$_retval" ]; then echo_skipped elif [ "$_retval" = "0" ]; then echo_ok else echo_failed fi ## - Set opcache.error_log = ${_web_base_dir}/logs/opcache_errors.log ## - _key="opcache.error_log" _val="${_web_base_dir}/logs/opcache_errors.log" echononl "\tphp.ini-$_php_version: $_val = $_key" _retval="" if grep -e "^\s*${_key}\s*=" $_php_ini_file > /dev/null 2>&1 ; then #sed -i "0,/^\([ \t]*${_key}[ \t]*=.*\)/ s##;\1\n${_key} = \"${_val}\"#" $_php_ini_file 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 _retval=$? fi if [ -z "$_retval" ]; then echo_skipped elif [ "$_retval" = "0" ]; then echo_ok else echo_failed fi touch $_val if $_suEXEC ; then chown -R ${suEXEC_user}:$suEXEC_group $_val else chown -R ${web_user}:${web_group} $_val fi if [ -f "${_web_base_dir}/conf/fcgid-${_php_version}" ]; then echononl "\tSichere existierende Scriptdatei .." mv ${_web_base_dir}/conf/fcgid-${_php_version} \ ${_web_base_dir}/conf/fcgid-${_php_version}.`date +%Y%m%d-%H%M` if [ "$?" = 0 ]; then echo_ok else echo_failed error "Kann bestehende Scriptdate \"${_web_base_dir}/conf/fcgid-${_php_version}\" nicht sichern!" fatal fi fi ## - Create fcgid-$_php_version ## - echononl "\tCreate ${_web_base_dir}/conf/fcgid-${_php_version}.." cat < ${_web_base_dir}/conf/fcgid-$_php_version #!/bin/sh export PHPRC="${_web_base_dir}/conf/" export TMPDIR="${_web_base_dir}/tmp" # PHP child process management (PHP_FCGI_CHILDREN) should # always be disabled with mod_fcgid, which will only route one # request at a time to application processes it has spawned; # thus, any child processes created by PHP will not be used # effectively. (Additionally, the PHP child processes may not # be terminated properly.) By default, and with the environment # variable setting PHP_FCGI_CHILDREN=0, PHP child process # management is disabled. PHP_FCGI_CHILDREN=0 export PHP_FCGI_CHILDREN exec /usr/local/php-${_php_version}/bin/php-cgi EOF if [ "$?" = 0 ]; then echo_ok else echo_failed error "Kann \"${_web_base_dir}/conf/fcgid-${_php_version}\" nicht erstellen!" fatal fi echononl "\tÄndere Zugriffsrechte für \"fcgid-$_php_version\"" chmod 750 ${_web_base_dir}/conf/fcgid-$_php_version if [ "$?" = 0 ]; then echo_ok else echo_failed error "Kann Zugriffsrechte für \"fcgid-${_php_version}\" nicht ändern!" fatal fi echononl "\tBesitzer von \"fcgid-$_php_version\".." if $_suEXEC ; then chown ${suEXEC_user}:$suEXEC_group $_val ${_web_base_dir}/conf/fcgid-$_php_version else chown root:$web_group ${_web_base_dir}/conf/fcgid-$_php_version fi chmod 750 ${_web_base_dir}/conf/fcgid-$_php_version if [ "$?" = 0 ]; then echo_ok else echo_failed error "Kann Besitzer für \"fcgid-${_php_version}\" nicht wechseln!" fatal fi _php_version_link=$_php_version echo "" fi fi done echo "" if [ -h "${_web_base_dir}/conf/php.ini" ]; then echononl "\tDelete symlink php.ini --> `basename $(realpath ${_web_base_dir}/conf/php.ini)`" rm ${_web_base_dir}/conf/php.ini if [ "$?" = 0 ]; then echo_ok else echo_failed error "Cannot delete symlink \"${_web_base_dir}/conf/php.ini\"" fatal fi fi echononl "\tSetze Symlink php.ini --> php.ini-$major_php_verison" ln -s php.ini-$major_php_verison ${_web_base_dir}/conf/php.ini if [ "$?" = 0 ]; then echo_ok else echo_failed error "Kann Symlink \"php.ini --> php.ini-$major_php_verison\" nicht setzen!" fatal fi if [ -h "${_web_base_dir}/conf/fcgid" ]; then echononl "\tDelete symlink fcgid --> `basename $(realpath ${_web_base_dir}/conf/fcgid)`" rm ${_web_base_dir}/conf/fcgid if [ "$?" = 0 ]; then echo_ok else echo_failed error "Cannot delete symlink \"${_web_base_dir}/conf/fcgid\"" fatal fi fi echononl "\tSetze Symlink fcgid --> fcgid-$major_php_verison" ln -s fcgid-$major_php_verison ${_web_base_dir}/conf/fcgid if [ "$?" = 0 ]; then echo_ok else echo_failed error "Kann Symlink \"fcgid --> fcgid-$major_php_verison\" nicht setzen!" fatal fi cat < ${_web_base_dir}/conf/changes.php.ini.txt error_log = "${_web_base_dir}/logs/php_errors.log" sys_temp_dir = "${_web_base_dir}/tmp" upload_tmp_dir = "${_web_base_dir}/tmp" session.save_path = "${_web_base_dir}/sessions" soap.wsdl_cache_dir = "${_web_base_dir}/tmp" opcache.error_log = ${_web_base_dir}/logs/opcache_errors.log EOF fi ## - Create VHost Configuration ## - echo echo echo -e "\t---" echo -e "\t--- Create VHost Configuration" echo -e "\t---" echo"" _failed=false echononl "\tErstelle VHost Konfiguration \"`basename $_new_vhost_config_file`\".." cat < ${_new_vhost_config_file} # --- $site_url EOF if [ "$?" != "0" ]; then _failed=true fi for _alias in "${_server_aliases_arr[@]}" ; do cat <> ${_new_vhost_config_file} # --- $_alias EOF if [ "$?" != "0" ]; then _failed=true fi done cat <> ${_new_vhost_config_file} ServerAdmin $server_admin ServerName $_server_name EOF if [ "$?" != "0" ]; then _failed=true fi for _alias in "${_server_aliases_arr[@]}" ; do cat <> ${_new_vhost_config_file} ServerAlias $_alias EOF if [ "$?" != "0" ]; then _failed=true fi done if $_suEXEC ; then cat <> ${_new_vhost_config_file} SuexecUserGroup $suEXEC_user $suEXEC_group EOF fi if [ "$_type" = "FCGID" ]; then cat <> ${_new_vhost_config_file} DocumentRoot $_doc_root Require all granted AllowOverride All FCGIWrapper $FCGI_Wrapper SetHandler fcgid-script Options +ExecCGI EOF elif [ "$_type" = "PHP-FPM" ]; then cat <> ${_new_vhost_config_file} #ProxyErrorOverride On SetHandler $_set_handler_fpm DirectoryIndex index.php index.html index.htm DocumentRoot $_doc_root Require all granted AllowOverride All EOF else cat <> ${_new_vhost_config_file} DocumentRoot $_doc_root AllowOverride All Require all granted EOF fi # if [ "$_type" = "FCGID" ]; then if [ -n "$_custom_ipv4_log" ]; then cat <> ${_new_vhost_config_file} CustomLog $_custom_ipv4_log base_requests EOF fi cat <> ${_new_vhost_config_file} CustomLog $_combined_custom_log combined ErrorLog $_error_log EOF if [ "$?" != "0" ]; then _failed=true fi if $_https ; then cat <> ${_new_vhost_config_file} ServerAdmin $server_admin ServerName $_server_name EOF if [ "$?" != "0" ]; then _failed=true fi for _alias in "${_server_aliases_arr[@]}" ; do cat <> ${_new_vhost_config_file} ServerAlias $_alias EOF if [ "$?" != "0" ]; then _failed=true fi done if $_suEXEC ; then cat <> ${_new_vhost_config_file} SuexecUserGroup $suEXEC_user $suEXEC_group EOF fi if [ "$_type" = "FCGID" ]; then cat <> ${_new_vhost_config_file} DocumentRoot $_doc_root Require all granted AllowOverride All FCGIWrapper $FCGI_Wrapper SetHandler fcgid-script Options +ExecCGI EOF elif [ "$_type" = "PHP-FPM" ]; then cat <> ${_new_vhost_config_file} #ProxyErrorOverride On SetHandler $_set_handler_fpm DirectoryIndex index.php index.html index.htm DocumentRoot $_doc_root Require all granted AllowOverride All EOF else cat <> ${_new_vhost_config_file} DocumentRoot $_doc_root AllowOverride All Require all granted EOF fi # if [ "$_type" = "FCGID" ] cat <> ${_new_vhost_config_file} SSLEngine on SSLCertificateFile $_ssl_cert_file SSLCertificateKeyFile $_ssl_key_file EOF if [ -n "$_ssl_chain_file" ]; then cat <> ${_new_vhost_config_file} SSLCertificateChainFile $_ssl_chain_file EOF fi if [ -n "$_custom_ipv4_log" ]; then cat <> ${_new_vhost_config_file} CustomLog $_custom_ipv4_log base_requests EOF fi cat <> ${_new_vhost_config_file} CustomLog $_combined_custom_log combined ErrorLog $_error_log EOF if [ "$?" != "0" ]; then _failed=true fi fi if [ "$_ipv6" != "disabled" ]; then cat <> ${_new_vhost_config_file} # --- # --- IPv6 # --- ServerAdmin $server_admin ServerName $_server_name EOF if [ "$?" != "0" ]; then _failed=true fi for _alias in "${_server_aliases_arr[@]}" ; do cat <> ${_new_vhost_config_file} ServerAlias $_alias EOF if [ "$?" != "0" ]; then _failed=true fi done if $_suEXEC ; then cat <> ${_new_vhost_config_file} SuexecUserGroup $suEXEC_user $suEXEC_group EOF fi if [ "$_type" = "FCGID" ]; then cat <> ${_new_vhost_config_file} DocumentRoot $_doc_root Require all granted AllowOverride All FCGIWrapper $FCGI_Wrapper SetHandler fcgid-script Options +ExecCGI EOF elif [ "$_type" = "PHP-FPM" ]; then cat <> ${_new_vhost_config_file} #ProxyErrorOverride On SetHandler $_set_handler_fpm DirectoryIndex index.php index.html index.htm DocumentRoot $_doc_root Require all granted AllowOverride All EOF else cat <> ${_new_vhost_config_file} DocumentRoot $_doc_root AllowOverride All Require all granted EOF fi # if [ "$_type" = "FCGID" ]; then if [ -n "$_custom_ipv6_log" ]; then cat <> ${_new_vhost_config_file} CustomLog $_custom_ipv6_log base_requests EOF fi cat <> ${_new_vhost_config_file} CustomLog $_combined_custom_log combined ErrorLog $_error_log EOF if [ "$?" != "0" ]; then _failed=true fi if $_https ; then cat <> ${_new_vhost_config_file} ServerAdmin $server_admin ServerName $_server_name EOF if [ "$?" != "0" ]; then _failed=true fi for _alias in "${_server_aliases_arr[@]}" ; do cat <> $_new_vhost_config_file ServerAlias $_alias EOF if [ "$?" != "0" ]; then _failed=true fi done if $_suEXEC ; then cat <> ${_new_vhost_config_file} SuexecUserGroup $suEXEC_user $suEXEC_group EOF fi if [ "$_type" = "FCGID" ]; then cat <> ${_new_vhost_config_file} DocumentRoot $_doc_root Require all granted AllowOverride All FCGIWrapper $FCGI_Wrapper SetHandler fcgid-script Options +ExecCGI EOF elif [ "$_type" = "PHP-FPM" ]; then cat <> ${_new_vhost_config_file} #ProxyErrorOverride On SetHandler $_set_handler_fpm DirectoryIndex index.php index.html index.htm DocumentRoot $_doc_root Require all granted AllowOverride All EOF else cat <> ${_new_vhost_config_file} DocumentRoot $_doc_root AllowOverride All Require all granted EOF fi # if [ "$_type" = "FCGID" ] cat <> ${_new_vhost_config_file} SSLEngine on SSLCertificateFile $_ssl_cert_file SSLCertificateKeyFile $_ssl_key_file EOF if [ -n "$_ssl_chain_file" ]; then cat <> ${_new_vhost_config_file} SSLCertificateChainFile $_ssl_chain_file EOF fi if [ -n "$_custom_ipv6_log" ]; then cat <> ${_new_vhost_config_file} CustomLog $_custom_ipv6_log base_requests EOF fi cat <> ${_new_vhost_config_file} CustomLog $_combined_custom_log combined ErrorLog $_error_log EOF if [ "$?" != "0" ]; then _failed=true fi fi # if $_https ; then fi # if [ "$_ipv6" != "disabled" ]; then if ! $_failed ; then echo_ok else echo_failed error "Kann fcgid Konfiguration für site \"$site_url\" nicht erstellen!" fatal fi _vhost_file_basename="`basename $_new_vhost_config_file`" _vhost_file_prefix="${_vhost_file_basename%.*}" if [ -h "${_vhost_base_dir}/$_vhost_file_prefix" ]; then echononl "\tDelete existing symlink \"${_vhost_base_dir}/$_vhost_file_prefix\".." rm ${_vhost_base_dir}/$_vhost_file_prefix if [ "$?" = "0" ];then echo_ok else echo_failed error "Cannot delete symlink \"${_vhost_base_dir}/$_vhost_file_prefix\"" fatal fi elif [ -f "${_vhost_base_dir}/$_vhost_file_prefix" ]; then echononl "\tMove existing file \"$_vhost_file_prefix\" to \"${_vhost_file_prefix}.mod_php\"" mv ${_vhost_base_dir}/$_vhost_file_prefix ${_vhost_base_dir}/${_vhost_file_prefix}.mod_php if [ "$?" = "0" ];then echo_ok else echo_failed error "Cannot move file \"${_vhost_base_dir}/$_vhost_file_prefix\"" fatal fi fi echononl "\tSet symlink \"$_vhost_file_prefix --> $_vhost_file_basename" ln -s $_vhost_file_basename ${_vhost_base_dir}/$_vhost_file_prefix if [ "$?" = "0" ];then echo_ok else echo_failed error "Setting symlink \"${_vhost_base_dir}/$_vhost_file_prefix -> $_vhost_file_basename\" failed." fatal fi echononl "\tCreate initial \"index.html\" file.." if [ ! -f "${_doc_root}/index.html" -a ! -r "${_doc_root}/index.php" -a ! -f "${_doc_root}/index.htm" ]; then cat < ${_doc_root}/index.html Maintenance / Wartungsarbeiten

${_server_name}

Seite im Aufbau

Diese Website wird in Kürze online gehen..

Bitte versuchen Sie es später noch einmal.

Vielen Dank für Ihr Verständnis!

Site under construction

This website will go online soon.

Please try again later.

Thank You very much!

EOF if [ "$?" = "0" ];then echo_ok echononl "\tChange ownerchip (${web_user}:${web_group}) of \"index.html\".." chown ${web_user}:$web_group ${_doc_root}/index.html if [ "$?" = "0" ];then echo_ok else echo_failed error "Cannot change ownerchip of file \"index.html\"" fi else echo_failed error "Cannot create file \"index.html\"." fi else echo_skipped fi echononl "\tCreate \"phpinfo.php\" file.." if $CREATE_PHPINFO_FILE ; then if [ ! -f "${_doc_root}/phpinfo.php" ]; then cat < ${_doc_root}/phpinfo.php PHP Info EOF if [ "$?" = "0" ];then echo_ok echononl "\tChange ownerchip (${web_user}:${web_group}) of \"phpinfo.php\".." chown ${web_user}:$web_group ${_doc_root}/phpinfo.php if [ "$?" = "0" ];then echo_ok else echo_failed error "Cannot change ownerchip of file \"phpinfo.php\"." fi else echo_failed error "Cannot create file \"phpinfo.php\"." fi else echo_skipped fi else echo_skipped fi _syntax_ok=false echo "" echononl "\tCheck Apache Configuration.." if [ "`apachectl configtest 2>&1`" = "Syntax OK" ]; then echo_ok _syntax_ok=true else echo_failed fi if $_syntax_ok ; then echononl "\tGraceful restart Apache Webserver.." apachectl graceful 2> /dev/null if [ "$?" = "0" ];then echo_ok else echo_failed error "Graceful restart of Apache Webserver failed!" fi fi rm -f $log_file echo echo exit 0