diff --git a/nginxinstall b/nginxinstall index bcf2c61..1009b4a 100755 --- a/nginxinstall +++ b/nginxinstall @@ -11,15 +11,9 @@ if [[ $(id -u) -ne 0 ]]; then echo "" && echo "Must be root or use sudo" && echo "" ; exit 1; fi # -# Function to check if a service is already running or not +# Check if services are allready running # -serviceyes () { printf "\n%s" $service ; printf " is already running cannot continue...\n\n"; } -servicealive () { status=$(systemctl is-active $service); if [[ "$status" == "active" ]]; then serviceyes ; exit; fi; } - -# -# If Nginx is allready running then die -# -service="nginx" ; servicealive +for svc in nginx php*-fpm; do if systemctl is-active --quiet "$svc"; then printf "\n%s is already running, cannot continue...\n\n" "${svc^}" ; exit 1 ; fi ; done # # Let's go @@ -51,7 +45,9 @@ apt install -y php-fpm php-curl php-dom php-gd php-imagick php-ldap php-mbstring # Determine Php version # phpver=$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;') -phpfpm="php$phpver-fpm"; phpclidir="/etc/php/$phpver/cli"; phpfpmdir="/etc/php/$phpver/fpm" +phpfpm="php${phpver}-fpm" +phpclidir="/etc/php/$phpver/cli" +phpfpmdir="/etc/php/$phpver/fpm" # # Configure Nginx @@ -61,8 +57,8 @@ cp "$phpfpmdir"/php.ini "$phpfpmdir"/php.ini.orig cp "$nginxsnippets"/nginxconf/nginx.conf /etc/nginx cp "$nginxsnippets"/nginxconf/nginx.conf.high.perf /etc/nginx cp "$nginxsnippets"/nginxconf/default /etc/nginx/sites-available/default -sed -i "s/VERSION/$phpver/" /etc/nginx/nginx.conf -sed -i "s/VERSION/$phpver/" /etc/nginx/nginx.conf.high.perf +sed -i "s/PHPVERSION/$phpfpm/" /etc/nginx/nginx.conf +sed -i "s/PHPVERSION/$phpfpm/" /etc/nginx/nginx.conf.high.perf # # Creating a high performance www.conf file for optional or later use @@ -87,7 +83,8 @@ sed -i 's/;date.timezone =/date.timezone = Europe\/Copenhagen/' "$phpfpmdir"/php # # Restart Nginx and Php-Fpm # -systemctl restart "$phpfpm" && systemctl restart nginx +systemctl restart "$phpfpm" +systemctl restart nginx # # All done