Compare commits

..

5 Commits

Author SHA1 Message Date
5e663d8925 listing update 2025-03-24 00:43:14 +01:00
2f0831aa09 configuraiton des modules opcache et apcu 2025-03-23 21:55:54 +01:00
cad29cdc71 demande si on créé la page info.php 2025-03-23 21:49:17 +01:00
eabf6c042e ajout de sqlite3 2025-03-23 21:35:15 +01:00
ca73246a47 correction 2025-03-23 21:29:09 +01:00
5 changed files with 95 additions and 26 deletions

View File

@@ -1,2 +1,3 @@
common_utils.sh common_utils.sh
setup_debian.sh setup_debian.sh
setup_mdns.sh

View File

@@ -67,10 +67,10 @@ get_fqdn_and_domain() {
# Vérification de la résolution DNS # Vérification de la résolution DNS
check_dns() { check_dns() {
local server_name=$1 local server_name=$1
# Récupération de l'adresse IP publique du serveur # Récupération de l'adresse IP publique du serveur
SERVER_IP=$(curl -4 -s ifconfig.me || hostname -I | awk '{print $1}') SERVER_IP=$(curl -4 -s ifconfig.me || hostname -I | awk '{print $1}')
# Récupération de l'adresse IP associée au FQDN # Récupération de l'adresse IP associée au FQDN
FQDN_IP=$(dig +short A "$server_name" | tail -n1) FQDN_IP=$(dig +short A "$server_name" | tail -n1)
@@ -78,17 +78,18 @@ check_dns() {
if [[ -z "$FQDN_IP" ]]; then if [[ -z "$FQDN_IP" ]]; then
echo "❌ Erreur : Impossible de récupérer l'adresse IP associée à $server_name via DIG." echo "❌ Erreur : Impossible de récupérer l'adresse IP associée à $server_name via DIG."
echo "➡️ Vérifie la configuration DNS et l'existence du domaine." echo "➡️ Vérifie la configuration DNS et l'existence du domaine."
exit 1 return 1 # Erreur bloquante uniquement ici
fi fi
# Comparaison des IPs # Comparaison des IPs mais uniquement en Alerte non bloquante
if [[ "$SERVER_IP" != "$FQDN_IP" ]]; then if [[ "$SERVER_IP" != "$FQDN_IP" ]]; then
echo "⚠️ Alerte DNS : L'adresse IP résolue ($FQDN_IP) ne correspond pas à l'IP publique actuelle ($SERVER_IP)." echo "⚠️ Alerte DNS : L'adresse IP résolue ($FQDN_IP) ne correspond pas à l'IP publique actuelle ($SERVER_IP)."
echo "➡️ Vérifie la configuration DNS et la propagation des enregistrements." echo "➡️ Vérifie la configuration DNS et la propagation si nécessaire."
exit 1 else
echo "✅ Vérification réussie : $server_name pointe correctement vers $SERVER_IP."
fi fi
echo "✅ Vérification réussie : $server_name pointe correctement vers $SERVER_IP." return 0
} }

View File

@@ -9,16 +9,15 @@ source "$(dirname "$0")/../common/common_utils.sh"
# Vérifier si le script est exécuté en root # Vérifier si le script est exécuté en root
check_root check_root
# Vérification DNS # Vérification DNS (alerte non bloquante)
check_dns "$DOMAIN" if ! check_dns "$DOMAIN"; then
echo "⚠️ Attention : Résolution DNS impossible pour $DOMAIN. Vérifie si c'est bien ce que tu veux."
fi
REVERSED_DOMAIN=$(echo "$DOMAIN" | awk -F. '{for(i=NF; i>0; i--) printf "%s%s", $i, (i>1 ? "." : "")}') REVERSED_DOMAIN=$(echo "$DOMAIN" | awk -F. '{for(i=NF; i>0; i--) printf "%s%s", $i, (i>1 ? "." : "")}')
VHOST_CONF="/etc/apache2/sites-available/$REVERSED_DOMAIN.conf" VHOST_CONF="/etc/apache2/sites-available/$REVERSED_DOMAIN.conf"
# Créer les dossiers nécessaires # Pparer le dossier du VirtualHost
mkdir -p "$BACKUP_DIR" "$TEMPLATE_DIR" "$CHALLENGE_DIR"
chown -R www-data:www-data "$CHALLENGE_DIR"
mkdir -p "/var/www/$REVERSED_DOMAIN" mkdir -p "/var/www/$REVERSED_DOMAIN"
chown -R www-data:www-data "/var/www/$REVERSED_DOMAIN" chown -R www-data:www-data "/var/www/$REVERSED_DOMAIN"
chmod -R 755 "/var/www/$REVERSED_DOMAIN" chmod -R 755 "/var/www/$REVERSED_DOMAIN"

View File

@@ -43,11 +43,48 @@ PHP_VERSION="8.3"
# Vérification de l'installation de PHP # Vérification de l'installation de PHP
echo -e "${YELLOW}Installation de PHP $PHP_VERSION et des modules courants...${RESET}" echo -e "${YELLOW}Installation de PHP $PHP_VERSION et des modules courants...${RESET}"
apt install -y php$PHP_VERSION php$PHP_VERSION-cli php$PHP_VERSION-fpm \
php$PHP_VERSION-mysql php$PHP_VERSION-curl php$PHP_VERSION-gd \ # Base des modules PHP à installer
php$PHP_VERSION-mbstring php$PHP_VERSION-xml php$PHP_VERSION-zip \ PHP_MODULES=(
php$PHP_VERSION-bcmath php$PHP_VERSION-soap php$PHP_VERSION-intl \ php${PHP_VERSION}
php$PHP_VERSION-readline php$PHP_VERSION-ldap php$PHP_VERSION-imagick || { echo -e "${RED}Échec de l'installation de PHP${RESET}"; exit 1; } php${PHP_VERSION}-cli
php${PHP_VERSION}-fpm
php${PHP_VERSION}-curl
php${PHP_VERSION}-gd
php${PHP_VERSION}-mbstring
php${PHP_VERSION}-xml
php${PHP_VERSION}-zip
php${PHP_VERSION}-bcmath
php${PHP_VERSION}-soap
php${PHP_VERSION}-intl
php${PHP_VERSION}-readline
php${PHP_VERSION}-ldap
php${PHP_VERSION}-imagick
php${PHP_VERSION}-exif
php${PHP_VERSION}-gmp
php${PHP_VERSION}-apcu
php${PHP_VERSION}-opcache
php${PHP_VERSION}-sqlite3
)
# Vérification MySQL / MariaDB
if dpkg -l | grep -qE 'mysql-server|mariadb-server'; then
echo -e "${GREEN}MySQL/MariaDB détecté. Ajout du module php-mysql.${RESET}"
PHP_MODULES+=(php${PHP_VERSION}-mysql)
fi
# Vérification PostgreSQL
if dpkg -l | grep -q postgresql; then
echo -e "${GREEN}PostgreSQL détecté. Ajout du module php-pgsql.${RESET}"
PHP_MODULES+=(php${PHP_VERSION}-pgsql)
fi
# Installation des modules PHP
echo -e "${GREEN}Installation des modules PHP...${RESET}"
apt install -y "${PHP_MODULES[@]}" || {
echo -e "${RED}❌ Échec de l'installation de PHP ou des modules.${RESET}"
exit 1
}
# Vérification si Apache est installé et installation du module PHP si nécessaire # Vérification si Apache est installé et installation du module PHP si nécessaire
if systemctl list-units --type=service --all | grep -q "apache2.service"; then if systemctl list-units --type=service --all | grep -q "apache2.service"; then
@@ -60,6 +97,7 @@ fi
# Configuration de PHP-FPM si ce n'est pas déjà fait # Configuration de PHP-FPM si ce n'est pas déjà fait
PHP_INI="/etc/php/$PHP_VERSION/fpm/php.ini" PHP_INI="/etc/php/$PHP_VERSION/fpm/php.ini"
PHP_INI_DIR="/etc/php/${PHP_VERSION}/fpm/conf.d"
if grep -q "memory_limit = 512M" "$PHP_INI"; then if grep -q "memory_limit = 512M" "$PHP_INI"; then
echo -e "${GREEN}Configuration de PHP-FPM déjà optimisée.${RESET}" echo -e "${GREEN}Configuration de PHP-FPM déjà optimisée.${RESET}"
@@ -74,17 +112,45 @@ else
systemctl restart php$PHP_VERSION-fpm || { echo -e "${RED}Échec du redémarrage de PHP-FPM${RESET}"; exit 1; } systemctl restart php$PHP_VERSION-fpm || { echo -e "${RED}Échec du redémarrage de PHP-FPM${RESET}"; exit 1; }
fi fi
# Vérification des modules PHP installés # Configuration OPCache
echo -e "${GREEN}Modules PHP installés :${RESET}" OPCACHE_INI="${PHP_INI_DIR}/10-opcache.ini"
php -m cat > "$OPCACHE_INI" <<EOF
; Configuration OPcache optimisée
opcache.enable=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=10000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1
EOF
echo "==> Fichier $OPCACHE_INI mis à jour."
# Configuration APCu
APCU_INI="${PHP_INI_DIR}/20-apcu.ini"
cat > "$APCU_INI" <<EOF
; Configuration APCu optimisée
apc.enabled=1
apc.shm_size=64M
apc.ttl=7200
apc.enable_cli=0
EOF
echo "==> Fichier $APCU_INI mis à jour."
# Test de la configuration Apache # Test de la configuration Apache
if systemctl is-active --quiet apache2; then if systemctl is-active --quiet apache2; then
echo -e "${YELLOW}Vérification du support de PHP par Apache...${RESET}" read -rp "Voulez-vous tester le support de PHP par Apache ? (o/n) : " test_php
echo "<?php phpinfo(); ?>" > /var/www/html/info.php if [[ "$test_php" =~ ^[oOyY]$ ]]; then
chown www-data:www-data /var/www/html/info.php echo -e "${YELLOW}Vérification du support de PHP par Apache...${RESET}"
chmod 644 /var/www/html/info.php echo "<?php phpinfo(); ?>" > /var/www/html/info.php
echo -e "${GREEN}Vous pouvez tester PHP en accédant à : http://<IP_SERVEUR>/info.php${RESET}" chown www-data:www-data /var/www/html/info.php
chmod 644 /var/www/html/info.php
echo -e "${GREEN}Vous pouvez tester PHP en accédant à : http://<IP_SERVEUR>/info.php${RESET}"
else
echo -e "${YELLOW}Test PHP annulé.${RESET}"
fi
else
echo -e "${RED}Le service Apache n'est pas actif.${RESET}"
fi fi
echo -e "${GREEN}Installation terminée avec succès ! 🚀${RESET}" echo -e "${GREEN}Installation terminée avec succès ! 🚀${RESET}"

View File

@@ -1,2 +1,4 @@
check_mysql_secure.sh
create_db.sh create_db.sh
set_root_password.sh
setup_mariadb.sh setup_mariadb.sh