new php-fpm check

This commit is contained in:
2025-10-29 11:07:41 +01:00
parent 709dddd8e3
commit e574c6cfe4

View File

@@ -14,7 +14,12 @@ if [[ $(id -u) -ne 0 ]]; then echo "" && echo "Must be root or use sudo" && echo
# Define variables and functions # Define variables and functions
# #
hostname="$1" hostname="$1"
phpver=$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;') ; phpfpm="php$phpver-fpm"
#
# Get php-fpm version
#
phpfpm=$(systemctl list-units --type=service --all | awk '/php[0-9]+\.[0-9]+-fpm/ {print $1; exit}' | sed 's/\.service//')
if [[ -z "$phpfpm" ]]; then printf "\nUnable to detect php-fpm version. Is PHP-FPM installed?\n\n" ; exit 1 ; fi
# #
# Function usage # Function usage
@@ -72,13 +77,14 @@ chown -R www-data: "$wikidir"
# Create a DokuWiki nginx configuration file # Create a DokuWiki nginx configuration file
# #
cp "$nginxsnippets/hostfiles/dokuwiki.80.conf" /etc/nginx/conf.d/"$hostname".conf cp "$nginxsnippets/hostfiles/dokuwiki.80.conf" /etc/nginx/conf.d/"$hostname".conf
sed -i "s/DOMAIN/$hostname/g" /etc/nginx/conf.d/"$hostname".conf sed -i -- "s/DOMAIN/$hostname/g" /etc/nginx/conf.d/"$hostname".conf
sed -i "s/VERSION/$phpver/" /etc/nginx/conf.d/"$hostname".conf sed -i "s/PHPVERSION/$phpfpm/" /etc/nginx/conf.d/"$hostname".conf
# #
# Restarting Nginx and Phpfpm for changes to take effect # Restarting Nginx and Phpfpm for changes to take effect
# #
systemctl restart "$phpfpm" ; systemctl restart nginx systemctl restart "$phpfpm"
systemctl restart nginx
# #
# Create postinstall script # Create postinstall script