diff --git a/etc/apache2.site b/etc/apache2.site index 31cbcb485..84b16cb7e 100644 --- a/etc/apache2.site +++ b/etc/apache2.site @@ -192,7 +192,7 @@ AddDefaultCharset utf-8 # Pull in the Apache2 ContentPolicy - Include /opt/fpp/etc/apache2.csp + IncludeOptional /opt/fpp/etc/apache2.csp # Set other security settings diff --git a/scripts/common b/scripts/common index f9c236443..cb33e527d 100755 --- a/scripts/common +++ b/scripts/common @@ -201,18 +201,35 @@ setSetting() { gracefullyReloadApacheConf() { if [[ "$OSTYPE" == "darwin"* ]]; then # macOS - sudo apachectl graceful + if sudo apachectl -t >/dev/null 2>&1; then + sudo apachectl graceful + echo "Apache configuration reloaded successfully." + else + echo "Apache is not running." + return 1 + fi elif [[ -f /etc/debian_version ]]; then # Debian/Ubuntu - sudo systemctl reload apache2 + if systemctl is-active --quiet apache2; then + sudo systemctl reload apache2 + echo "Apache configuration reloaded successfully." + else + echo "Apache is not running." + return 1 + fi elif [[ -f /etc/redhat-release ]]; then # RHEL/CentOS/Fedora - sudo systemctl reload httpd + if systemctl is-active --quiet httpd; then + sudo systemctl reload httpd + echo "Apache configuration reloaded successfully." + else + echo "Apache is not running." + return 1 + fi else echo "Unsupported OS" return 1 fi - echo "Apache configuration reloaded successfully." } ###################################################################