From 78d70728c5adf8c181fd20a7111368d06d963c39 Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Thu, 3 Oct 2024 17:40:39 +0200 Subject: [PATCH] Ubuntu 24.04 (#89) --- README.md | 6 ++-- addons/automatic_updates.sh | 2 +- addons/brotli-nginx.sh | 52 +++++++++++++++++++++++++++++++ addons/locales.sh | 2 +- addons/locate_mirror.sh | 2 +- addons/redis-server-ubuntu.sh | 6 ++-- addons/smtp-mail.sh | 2 +- apps/adminer.sh | 2 +- apps/bpytop.sh | 2 +- apps/fail2ban.sh | 2 +- apps/midnight-commander.sh | 4 +-- apps/netdata.sh | 2 +- apps/webmin.sh | 2 +- lets-encrypt/activate-tls.sh | 2 +- lets-encrypt/test-new-config.sh | 2 +- lib.sh | 23 +++++++++----- menu/additional_apps.sh | 2 +- menu/fail2ban_menu.sh | 2 +- menu/main_menu.sh | 2 +- menu/menu.sh | 2 +- menu/server_configuration.sh | 2 +- menu/startup_configuration.sh | 2 +- network/ddclient-configuration.sh | 4 +-- network/static_ip.sh | 2 +- static/adduser.sh | 2 +- static/change_db_pass.sh | 2 +- static/nginx.conf | 6 ++++ static/wordpress_update.sh | 7 +++-- wordpress-startup-script.sh | 2 +- wordpress_install.sh | 19 +++++------ 30 files changed, 120 insertions(+), 49 deletions(-) create mode 100644 addons/brotli-nginx.sh diff --git a/README.md b/README.md index 860e20f..d715d39 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,10 @@ ### https://www.techandme.se ### https://www.hanssonit.se/wordpress-vm/ -- Ubuntu 22.04 Server -- MariaDB 10.10 +- Ubuntu 24.04 Server +- MariaDB 11.4 - NGINX 1.26 (with Brotli support) -- PHP-FPM 8.1 +- PHP-FPM 8.4 - Latest Wordpress (updates automatically) - WP-CLI - Redis Cache diff --git a/addons/automatic_updates.sh b/addons/automatic_updates.sh index a692dc1..8698219 100644 --- a/addons/automatic_updates.sh +++ b/addons/automatic_updates.sh @@ -1,6 +1,6 @@ #!/bin/bash -# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ +# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/ # shellcheck disable=2034,2059 true diff --git a/addons/brotli-nginx.sh b/addons/brotli-nginx.sh new file mode 100644 index 0000000..be1b2d7 --- /dev/null +++ b/addons/brotli-nginx.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/ +# Copyright © 2024 Simon Lindner (https://github.com/szaimen) + +# shellcheck disable=2034,2059 +true +SCRIPT_NAME="Nginx Brotli" +SCRIPT_EXPLAINER="Enables Brotli compression support for Nginx" +# shellcheck source=lib.sh +source /var/scripts/fetch_lib.sh || source <(curl -sL https://raw.githubusercontent.com/techandme/wordpress-vm/master/lib.sh) + +# Check for errors + debug code and abort if something isn't right +# 1 = ON +# 0 = OFF +DEBUG=0 +debug_mode + +# Check if root +root_check + +# Replace old Nginx with Brotli supported Nginx +if [ ! -f /etc/nginx/modules-enabled/50-mod-http-brotli-filter.conf ] +then + install_if_not ppa-purge + ppa-purge nginx/stable + rm -f /etc/apt/sources.list.d/nginx* + check_command yes | add-apt-repository ppa:ondrej/nginx + apt update -q4 && spinner_loading + install_if_not nginx + systemctl stop nginx + systemctl start nginx + systemctl enable nginx + apt-get purge ppa-purge -y + apt-get autoremove -y +else + exit +fi + +# Enable Brotli +install_if_not libnginx-mod-brotli +echo "load_module modules/ngx_http_brotli_filter_module.so;" > /etc/nginx/modules-enabled/50-mod-http-brotli-filter.conf + +# Enable Brotli in config +rm -f /etc/nginx/nginx.conf +curl_to_dir "$STATIC" nginx.conf /etc/nginx/ + +# Restart Nginx +if nginx -t +then + systemctl restart nginx +fi diff --git a/addons/locales.sh b/addons/locales.sh index b07e598..5d7e445 100644 --- a/addons/locales.sh +++ b/addons/locales.sh @@ -1,6 +1,6 @@ #!/bin/bash -# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ +# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/ # shellcheck disable=2034,2059,1091 true diff --git a/addons/locate_mirror.sh b/addons/locate_mirror.sh index bd7e637..82b3199 100644 --- a/addons/locate_mirror.sh +++ b/addons/locate_mirror.sh @@ -1,6 +1,6 @@ #!/bin/bash -# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ +# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/ # shellcheck disable=2034,2059 true diff --git a/addons/redis-server-ubuntu.sh b/addons/redis-server-ubuntu.sh index 05aadf8..cdf89ec 100644 --- a/addons/redis-server-ubuntu.sh +++ b/addons/redis-server-ubuntu.sh @@ -5,7 +5,7 @@ SCRIPT_NAME="Redis Server Ubuntu" # shellcheck source=lib.sh source /var/scripts/fetch_lib.sh || source <(curl -sL https://raw.githubusercontent.com/techandme/wordpress-vm/master/lib.sh) -# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ +# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/ # Check for errors + debug code and abort if something isn't right # 1 = ON @@ -17,9 +17,9 @@ debug_mode root_check # Check Ubuntu version -if ! version 18.04 "$DISTRO" 22.04.10 +if ! version 20.04 "$DISTRO" 24.04.10 then - msg_box "Your current Ubuntu version is $DISTRO but must be between 18.04 - 22.04.10 to run this script." + msg_box "Your current Ubuntu version is $DISTRO but must be between 20.04 - 24.04.10 to run this script." msg_box "Please contact us to get support for upgrading your server: https://www.hanssonit.se/#contact https://shop.hanssonit.se/" diff --git a/addons/smtp-mail.sh b/addons/smtp-mail.sh index ae97930..917c75d 100644 --- a/addons/smtp-mail.sh +++ b/addons/smtp-mail.sh @@ -1,6 +1,6 @@ #!/bin/bash -# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ +# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/ # shellcheck disable=2034,2059 true diff --git a/apps/adminer.sh b/apps/adminer.sh index 33d2bb9..dd1882a 100644 --- a/apps/adminer.sh +++ b/apps/adminer.sh @@ -1,6 +1,6 @@ #!/bin/bash -# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ +# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/ # shellcheck disable=2034,2059 true diff --git a/apps/bpytop.sh b/apps/bpytop.sh index 6da4280..961dca9 100644 --- a/apps/bpytop.sh +++ b/apps/bpytop.sh @@ -1,6 +1,6 @@ #!/bin/bash -# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ +# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/ # shellcheck disable=2034,2059 true diff --git a/apps/fail2ban.sh b/apps/fail2ban.sh index 22b5694..50088af 100644 --- a/apps/fail2ban.sh +++ b/apps/fail2ban.sh @@ -1,6 +1,6 @@ #!/bin/bash -# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ +# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/ # Inspired by https://github.com/nextcloud/nextcloudpi/blob/master/etc/nextcloudpi-config.d/fail2ban.sh # shellcheck disable=2034,2059 diff --git a/apps/midnight-commander.sh b/apps/midnight-commander.sh index ba1c5ac..1f1337c 100644 --- a/apps/midnight-commander.sh +++ b/apps/midnight-commander.sh @@ -1,7 +1,7 @@ #!/bin/bash -# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ -# Copyright © 2023 Simon Lindner (https://github.com/szaimen) +# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/ +# Copyright © 2024 Simon Lindner (https://github.com/szaimen) # shellcheck disable=2034,2059 true diff --git a/apps/netdata.sh b/apps/netdata.sh index 3e142ce..91b1e32 100644 --- a/apps/netdata.sh +++ b/apps/netdata.sh @@ -1,6 +1,6 @@ #!/bin/bash -# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ +# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/ # shellcheck disable=2034,2059 true diff --git a/apps/webmin.sh b/apps/webmin.sh index c5ffcc3..9a7aa60 100644 --- a/apps/webmin.sh +++ b/apps/webmin.sh @@ -1,6 +1,6 @@ #!/bin/bash -# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ +# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/ # shellcheck disable=2034,2059 true diff --git a/lets-encrypt/activate-tls.sh b/lets-encrypt/activate-tls.sh index 3a15882..85983f7 100644 --- a/lets-encrypt/activate-tls.sh +++ b/lets-encrypt/activate-tls.sh @@ -5,7 +5,7 @@ SCRIPT_NAME="Activate TLS" # shellcheck source=lib.sh source /var/scripts/fetch_lib.sh || source <(curl -sL https://raw.githubusercontent.com/techandme/wordpress-vm/master/lib.sh) -# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ +# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/ # Check for errors + debug code and abort if something isn't right # 1 = ON diff --git a/lets-encrypt/test-new-config.sh b/lets-encrypt/test-new-config.sh index 23e9ed6..820a6c1 100644 --- a/lets-encrypt/test-new-config.sh +++ b/lets-encrypt/test-new-config.sh @@ -5,7 +5,7 @@ SCRIPT_NAME="Test New Configuration" # shellcheck source=lib.sh source /var/scripts/fetch_lib.sh || source <(curl -sL https://raw.githubusercontent.com/techandme/wordpress-vm/master/lib.sh) -# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ +# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/ # Check for errors + debug code and abort if something isn't right # 1 = ON diff --git a/lib.sh b/lib.sh index 38f5b89..d5c5e94 100644 --- a/lib.sh +++ b/lib.sh @@ -130,7 +130,7 @@ NGINX_CONF="/etc/nginx/nginx.conf" NGINX_DEF="$SITES_AVAILABLE/default" # PHP-FPM -PHPVER=8.1 +PHPVER=8.4 PHP_FPM_DIR=/etc/php/$PHPVER/fpm PHP_INI=$PHP_FPM_DIR/php.ini PHP_POOL_DIR=$PHP_FPM_DIR/pool.d @@ -485,10 +485,10 @@ version(){ [[ $2 != "$h" && $2 != "$t" ]] } -if ! version 20.04 "$DISTRO" 22.04.10 +if ! version 20.04 "$DISTRO" 24.04.10 then print_text_in_color "$IRed" "Your current Ubuntu version is $DISTRO but must be between \ -20.04 - 22.04.10 to run this script." +20.04 - 24.04.10 to run this script." print_text_in_color "$ICyan" "Please contact us to get support for upgrading your server:" print_text_in_color "$ICyan" "https://www.hanssonit.se/#contact" print_text_in_color "$ICyan" "https://shop.hanssonit.se/" @@ -711,8 +711,8 @@ You can find the download link here: https://www.ubuntu.com/download/server" exit 1 fi -if ! version 20.04 "$DISTRO" 22.04.10; then - msg_box "Your current Ubuntu version is $DISTRO but must be between 20.04 - 22.04.10 to run this script." +if ! version 20.04 "$DISTRO" 24.04.10; then + msg_box "Your current Ubuntu version is $DISTRO but must be between 20.04 - 24.04.10 to run this script." msg_box "Please contact us to get support for upgrading your server: https://www.hanssonit.se/#contact https://shop.hanssonit.se/" @@ -807,7 +807,7 @@ version(){ [[ $2 != "$h" && $2 != "$t" ]] } -if version 20.04 "$DISTRO" 22.04.10 +if version 20.04 "$DISTRO" 24.04.10 then print_text_in_color "$ICyan" "Testing if network is OK..." if ! netplan apply @@ -828,7 +828,7 @@ then fi fi else - msg_box "Your current Ubuntu version is $DISTRO but must be between 20.04 - 22.04.6 to run this script." + msg_box "Your current Ubuntu version is $DISTRO but must be between 20.04 - 24.04.6 to run this script." msg_box "Please contact us to get support for upgrading your server: https://www.hanssonit.se/#contact https://shop.hanssonit.se/" @@ -1049,6 +1049,15 @@ then elif grep 8.2 <<< "$GETPHP" >/dev/null 2>&1 then export PHPVER=8.2 +elif grep 8.3 <<< "$GETPHP" >/dev/null 2>&1 +then + export PHPVER=8.3 +elif grep 8.4 <<< "$GETPHP" >/dev/null 2>&1 +then + export PHPVER=8.4 +elif grep 8.5 <<< "$GETPHP" >/dev/null 2>&1 +then + export PHPVER=8.5 fi export PHP_INI=/etc/php/"$PHPVER"/fpm/php.ini diff --git a/menu/additional_apps.sh b/menu/additional_apps.sh index d9fb92c..962638b 100644 --- a/menu/additional_apps.sh +++ b/menu/additional_apps.sh @@ -1,6 +1,6 @@ #!/bin/bash -# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ +# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/ # shellcheck disable=2034,2059 true diff --git a/menu/fail2ban_menu.sh b/menu/fail2ban_menu.sh index 3dc29ef..62caad8 100644 --- a/menu/fail2ban_menu.sh +++ b/menu/fail2ban_menu.sh @@ -1,6 +1,6 @@ #!/bin/bash -# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ +# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/ true SCRIPT_NAME="Fail2ban Menu" diff --git a/menu/main_menu.sh b/menu/main_menu.sh index 1027ca4..fe32f72 100644 --- a/menu/main_menu.sh +++ b/menu/main_menu.sh @@ -1,6 +1,6 @@ #!/bin/bash -# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ +# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/ # shellcheck disable=2034,2059,1091 true diff --git a/menu/menu.sh b/menu/menu.sh index a2bcd9e..398f90d 100644 --- a/menu/menu.sh +++ b/menu/menu.sh @@ -1,6 +1,6 @@ #!/bin/bash -# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ +# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/ # shellcheck disable=2034,2059,1091 true diff --git a/menu/server_configuration.sh b/menu/server_configuration.sh index d8346d1..ad88846 100644 --- a/menu/server_configuration.sh +++ b/menu/server_configuration.sh @@ -1,6 +1,6 @@ #!/bin/bash -# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ +# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/ # shellcheck disable=2034,2059 true diff --git a/menu/startup_configuration.sh b/menu/startup_configuration.sh index 199988b..d8c5843 100644 --- a/menu/startup_configuration.sh +++ b/menu/startup_configuration.sh @@ -1,6 +1,6 @@ #!/bin/bash -# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ +# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/ # shellcheck disable=2034,2059 true diff --git a/network/ddclient-configuration.sh b/network/ddclient-configuration.sh index 36cace2..69d3a1f 100644 --- a/network/ddclient-configuration.sh +++ b/network/ddclient-configuration.sh @@ -1,7 +1,7 @@ #!/bin/bash -# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ -# Copyright © 2023 Simon Lindner (https://github.com/szaimen) +# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/ +# Copyright © 2024 Simon Lindner (https://github.com/szaimen) # shellcheck disable=2034,2059 true diff --git a/network/static_ip.sh b/network/static_ip.sh index 826f4e6..fefc652 100644 --- a/network/static_ip.sh +++ b/network/static_ip.sh @@ -1,6 +1,6 @@ #!/bin/bash -# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ +# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/ # Use local lib file in case there is no internet connection if printf "Testing internet connection..." && ping github.com -c 2 >/dev/null 2>&1 diff --git a/static/adduser.sh b/static/adduser.sh index 15fba36..c828124 100644 --- a/static/adduser.sh +++ b/static/adduser.sh @@ -5,7 +5,7 @@ SCRIPT_NAME="Add CLI User" # shellcheck source=lib.sh source /var/scripts/fetch_lib.sh || source <(curl -sL https://raw.githubusercontent.com/techandme/wordpress-vm/master/lib.sh) -# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ +# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/ # Check for errors + debug code and abort if something isn't right # 1 = ON diff --git a/static/change_db_pass.sh b/static/change_db_pass.sh index 93edf27..7b601f2 100644 --- a/static/change_db_pass.sh +++ b/static/change_db_pass.sh @@ -5,7 +5,7 @@ SCRIPT_NAME="Change Database Password" # shellcheck source=lib.sh source /var/scripts/fetch_lib.sh || source <(curl -sL https://raw.githubusercontent.com/techandme/wordpress-vm/master/lib.sh) -# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ +# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/ # Check for errors + debug code and abort if something isn't right # 1 = ON diff --git a/static/nginx.conf b/static/nginx.conf index 5a47deb..067a8ce 100644 --- a/static/nginx.conf +++ b/static/nginx.conf @@ -16,6 +16,12 @@ events { } http { + ## + # Brootli support + ## + brotli on; + brotli_comp_level 6; + ## # Basic Settings ## diff --git a/static/wordpress_update.sh b/static/wordpress_update.sh index 96d3cb7..ff37c8f 100644 --- a/static/wordpress_update.sh +++ b/static/wordpress_update.sh @@ -34,7 +34,7 @@ https://shop.hanssonit.se/product/premium-support-per-30-minutes/" fi fi -# Ubuntu 18.04 is deprecated +# Ubuntu 20.04 is deprecated check_distro_version # Make sure VMLOGS are present @@ -75,7 +75,10 @@ then fi fi -# Update Redis PHP extension (20.04 --> 20.04 since 18.04 already is deprecated in the top of this script) +# Upgrade Nginx +run_script "$ADDONS" brotli-nginx + +# Update Redis PHP extension (20.04 --> 20.04 since 20.04 already is deprecated in the top of this script) print_text_in_color "$ICyan" "Trying to upgrade the Redis PECL extension..." # Check current PHP version diff --git a/wordpress-startup-script.sh b/wordpress-startup-script.sh index f8800aa..0871b21 100644 --- a/wordpress-startup-script.sh +++ b/wordpress-startup-script.sh @@ -1,6 +1,6 @@ #!/bin/bash -# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ +# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/ ######### diff --git a/wordpress_install.sh b/wordpress_install.sh index 106a1c0..e14f832 100644 --- a/wordpress_install.sh +++ b/wordpress_install.sh @@ -1,6 +1,6 @@ #!/bin/bash -# T&M Hansson IT AB © - 2023, https://www.hanssonit.se/ +# T&M Hansson IT AB © - 2024, https://www.hanssonit.se/ # Prefer IPv4 for apt echo 'Acquire::ForceIPv4 "true";' >> /etc/apt/apt.conf.d/99force-ipv4 @@ -213,13 +213,13 @@ done # Install MariDB repos install_if_not software-properties-common -curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash -s -- --mariadb-server-version="mariadb-10.10" --skip-maxscale +curl -LsS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash -s -- --mariadb-server-version="mariadb-11.4" --skip-maxscale # Avoid i386 since we use x64 sed -i "s|deb http|deb [arch=amd64] http|g" /etc/apt/sources.list.d/mariadb.list # USed debconf to install it -sudo debconf-set-selections <<< "mariadb-server-10.10 mysql-server/root_password password $MARIADB_PASS" -sudo debconf-set-selections <<< "mariadb-server-10.10 mysql-server/root_password_again password $MARIADB_PASS" -install_if_not mariadb-server-10.10 +sudo debconf-set-selections <<< "mariadb-server-11.4 mysql-server/root_password password $MARIADB_PASS" +sudo debconf-set-selections <<< "mariadb-server-11.4 mysql-server/root_password_again password $MARIADB_PASS" +install_if_not mariadb-server-11.4 # mysql_secure_installation install_if_not expect @@ -255,16 +255,17 @@ install_if_not open-vm-tools check_command yes | add-apt-repository ppa:ondrej/nginx apt update -q4 && spinner_loading install_if_not nginx -sudo systemctl stop nginx.service -sudo systemctl start nginx.service -sudo systemctl enable nginx.service +systemctl stop nginx.service +systemctl start nginx.service +systemctl enable nginx.service # Enable Brotli install_if_not libnginx-mod-brotli -# Download TLSv 1.3 modified nginx.conf +# Download TLSv 1.3 and Brotli modified nginx.conf rm -f /etc/nginx/nginx.conf curl_to_dir "$STATIC" nginx.conf /etc/nginx/ +systemctl restart nginx.service # Install PHP 8.1 apt install -y \