Skip to content

Commit 3b2dc94

Browse files
authored
Merge pull request #48 from i-doit/47-add-red-hat-95
Update recommended PHP version to 8.2 and add RHEL 9.5 support
2 parents 90e2a5d + dac8b69 commit 3b2dc94

File tree

1 file changed

+72
-19
lines changed

1 file changed

+72
-19
lines changed

idoit-install

Lines changed: 72 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ IFS=$'\n\t'
5252
: "${JOBS_BIN:="/usr/local/bin/idoit-jobs"}"
5353
: "${CRON_FILE:="/etc/cron.d/i-doit"}"
5454
: "${BACKUP_DIR:="/var/backups/i-doit"}"
55-
: "${RECOMMENDED_PHP_VERSION:="8.0"}"
55+
: "${RECOMMENDED_PHP_VERSION:="8.2"}"
5656
: "${RECOMMENDED_MARIADB_VERSION:="10.6"}"
5757

5858
##
@@ -327,8 +327,20 @@ function identifyOS {
327327
abort "Error: This version of Debian GNU/Linux is not supported anymore. Please upgrade to Debian 12."
328328
elif [[ "$NAME" == "Debian GNU/Linux" && "$VERSION" == "8 (jessie)" ]]; then
329329
abort "Error: This version of Debian GNU/Linux is not supported anymore. Please upgrade to Debian 12."
330+
elif [[ "$NAME" == "Red Hat Enterprise Linux" && "$VERSION_ID" == 9* ]]; then
331+
OS="rhel9"
332+
APACHE_USER="apache"
333+
APACHE_GROUP="apache"
334+
APACHE_CONFIG_FILE="/etc/httpd/conf.d/i-doit.conf"
335+
MARIADB_CONFIG_FILE="/etc/my.cnf.d/99-i-doit.cnf"
336+
PHP_CONFIG_FILE="/etc/php.d/i-doit.ini"
337+
MARIADB_SOCKET="/var/lib/mysql/mysql.sock"
338+
PHP_FPM_SOCKET="/var/run/php-fpm/php-fpm.sock"
339+
APACHE_UNIT="httpd"
340+
MARIADB_UNIT="mariadb"
341+
MEMCACHED_UNIT="memcached"
342+
PHP_FPM_UNIT="php-fpm"
330343
elif [[ "$NAME" == "Red Hat Enterprise Linux" && "$VERSION_ID" == 8* ]]; then
331-
332344
OS="rhel8"
333345
APACHE_USER="apache"
334346
APACHE_GROUP="apache"
@@ -343,7 +355,6 @@ function identifyOS {
343355
PHP_FPM_UNIT="php-fpm"
344356
elif [[ "$NAME" == "Red Hat Enterprise Linux Server" && "$VERSION_ID" == 7* ]]; then
345357
abort "Warning: RHEL 7 is out-dated. Please consider to upgrade your OS."
346-
347358
OS="rhel7"
348359
APACHE_USER="apache"
349360
APACHE_GROUP="apache"
@@ -509,7 +520,7 @@ function checkSoftwareRequirements {
509520
binaries["memcached"]=$(command -v memcached)
510521

511522
case "$OS" in
512-
"rhel7" | "rhel8" | "centos7" | "centos8")
523+
"rhel7" | "rhel8" | "rhel9" | "centos7" | "centos8")
513524
binaries["httpd"]=$(command -v httpd)
514525
;;
515526
*)
@@ -530,8 +541,8 @@ function checkSoftwareRequirements {
530541
log "Check for installed PHP extensions…"
531542

532543
case "$OS" in
533-
## TODO There is no php-memcached on RHEL 8:
534-
"rhel8" | "centos8")
544+
## TODO There is no php-memcached on RHEL 8 and 9:
545+
"rhel8" | "rhel9" | "centos8")
535546
local phpExtensions=(bcmath ctype curl fileinfo gd json ldap
536547
mbstring mysqli mysqlnd pgsql session soap xml zip)
537548
;;
@@ -587,6 +598,9 @@ function configureOS {
587598
"rhel8")
588599
configureRHEL8
589600
;;
601+
"rhel9")
602+
configureRHEL9
603+
;;
590604
"centos7")
591605
configureCentOS7
592606
;;
@@ -811,6 +825,53 @@ function configureCentOS8 {
811825
unitctl "restart" "firewalld"
812826
}
813827

828+
function configureRHEL9 {
829+
log "Keep your packages up-to-date"
830+
dnf --assumeyes --quiet update || abort "Unable to update yum packages"
831+
dnf --assumeyes --quiet autoremove || abort "Unable to remove out-dated yum packages"
832+
dnf --assumeyes --quiet clean all || abort "Unable to clean yum caches"
833+
rm -rf /var/cache/dnf || abort "Unable to remove orphaned yum caches"
834+
835+
for appStream in mariadb:10.11 php:8.2; do
836+
log "Install AppStream $appStream"
837+
dnf --assumeyes --quiet module install "$appStream"
838+
done
839+
840+
log "Install some important packages"
841+
dnf --assumeyes --quiet install \
842+
httpd memcached unzip boost-program-options wget zip \
843+
php-{bcmath,curl,gd,json,ldap,mysqli,mysqlnd,odbc,pecl-zip,pgsql,pdo,snmp,soap,zip} || abort "Unable to install packages"
844+
845+
# Is used to install moreutils which provides chronic which is needed for the idoit-jobs
846+
if ! rpm -qa | grep "epel-release" >/dev/null; then
847+
log "Import EPEL public GPG key"
848+
rpm --import --quiet https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-9 || abort "Unable to import public GPG key from EPEL"
849+
log "Add epel releases repository"
850+
rpm -Uvh --quiet https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm || abort "Unable to install epel releases repository"
851+
fi
852+
853+
# Provides dependencies for moreutils
854+
log "Enable codeready-builder for RHEL 9"
855+
subscription-manager repos --enable "codeready-builder-for-rhel-9-x86_64-rpms" || abort "Unable to enable Codeready-Builder"
856+
857+
log "Install moreutils with all dependencies"
858+
dnf --assumeyes --quiet install moreutils || abort "Unable to install moreutils"
859+
860+
for unit in $APACHE_UNIT $MARIADB_UNIT $MEMCACHED_UNIT $PHP_FPM_UNIT; do
861+
unitctl "enable" "$unit"
862+
unitctl "start" "$unit"
863+
done
864+
865+
log "Allow incoming HTTP traffic"
866+
systemctl -q is-active firewalld.service || (
867+
log "Firewall is inactive."
868+
unitctl "start" "firewalld"
869+
)
870+
871+
firewall-cmd --permanent --add-service=http || abort "Unable to configure firewall"
872+
unitctl "restart" "firewalld"
873+
}
874+
814875
function configureRHEL8 {
815876
log "Keep your yum packages up-to-date"
816877
yum --assumeyes --quiet update || abort "Unable to update yum packages"
@@ -1110,8 +1171,7 @@ function configurePHP {
11101171
abort "PHP ${php_version} is way too old. Please upgrade. We recommend version ${RECOMMENDED_PHP_VERSION}."
11111172
;;
11121173
"7.4")
1113-
log "PHP ${php_version} is installed, but this version is deprecated. Please consider to upgrade. We recommend version ${RECOMMENDED_PHP_VERSION}."
1114-
php_en_mod=$(command -v phpenmod)
1174+
abort "PHP ${php_version} is way too old. Please upgrade. We recommend version ${RECOMMENDED_PHP_VERSION}."
11151175
;;
11161176
"8.0")
11171177
php_en_mod=$(command -v phpenmod)
@@ -1174,7 +1234,7 @@ function configurePHPFPM {
11741234
"debian11" | "debian12" | "ubuntu2004" | "ubuntu2204" | "ubuntu2404")
11751235
unitctl "restart" "$PHP_FPM_UNIT"
11761236
;;
1177-
"rhel7" | "rhel8" | "centos7" | "centos8")
1237+
"rhel7" | "rhel8" | "rhel9" | "centos7" | "centos8")
11781238
log "Disable default configuration file"
11791239
mv /etc/php-fpm.d/www.conf{,.bak} || abort "Unable to disable default configuration file"
11801240
log "Put new settings into file '/etc/php-fpm.d/i-doit.conf'"
@@ -1235,7 +1295,7 @@ function configureApache {
12351295
hostname="$(cat /etc/hostname)"
12361296

12371297
case "$OS" in
1238-
"rhel7" | "rhel8" | "centos7" | "centos8")
1298+
"rhel7" | "rhel8" | "rhel9" | "centos7" | "centos8")
12391299
cat <<EOF >${APACHE_CONFIG_FILE} || abort "Unable to create and edit file '${APACHE_CONFIG_FILE}'"
12401300
DirectoryIndex index.php
12411301
DocumentRoot ${INSTALL_DIR}/
@@ -1268,14 +1328,7 @@ EOF
12681328
chcon -t httpd_sys_rw_content_t "${INSTALL_DIR}/" -R || abort "Unable to give write permissions recursively"
12691329

12701330
## mpm_event is already enabled on RHEL 8:
1271-
if [[ "$OS" != "rhel8" ]]; then
1272-
log "Disable MPM prefork"
1273-
sed -i "/.* mpm_prefork_module /s/^#*/#/" /etc/httpd/conf.modules.d/00-mpm.conf || abort "sed exited with error"
1274-
log "Enable MPM event"
1275-
sed -i "/^#.* mpm_event_module /s/^#//" /etc/httpd/conf.modules.d/00-mpm.conf || abort "sed exited with error"
1276-
fi
1277-
1278-
if [[ "$OS" != "centos8" ]]; then
1331+
if [[ "$OS" != "centos8" && "$OS" != "rhel8" ]]; then
12791332
log "Disable MPM prefork"
12801333
sed -i "/.* mpm_prefork_module /s/^#*/#/" /etc/httpd/conf.modules.d/00-mpm.conf || abort "sed exited with error"
12811334
log "Enable MPM event"
@@ -1600,7 +1653,7 @@ function secureMariaDB {
16001653
esac
16011654

16021655
case "$OS" in
1603-
"rhel7" | "rhel8" | "centos7" | "centos8")
1656+
"rhel7" | "rhel8" | "rhel9" | "centos7" | "centos8")
16041657
log "Allow $MARIADB_SUPERUSER_USERNAME login only from localhost"
16051658
"$MARIADB_BIN" \
16061659
-h"$MARIADB_HOSTNAME" \

0 commit comments

Comments
 (0)