====== Titre de Votre Tuto ====== * Objet : Configuration apache 2.4 * Niveau requis : FIXME {{tag>débutant avisé}} * Commentaires : //Contexte d'utilisation du sujet du tuto. // notes pour compléter la doc une fois que tout sera testé * Débutant, à savoir : [[:doc:systeme:commandes:le_debianiste_qui_papillonne|Utiliser GNU/Linux en ligne de commande, tout commence là !.]] :-) ===== Introduction ===== ===== Installation ===== CF [[http://debian-facile.org/doku.php?do=search&id=apache|apache2]] A l'installation on peut voir le chargement de certains modules Paramétrage de libapr1:amd64 (1.5.1-3) ... Paramétrage de libaprutil1:amd64 (1.5.4-1) ... Paramétrage de libaprutil1-dbd-sqlite3:amd64 (1.5.4-1) ... Paramétrage de libaprutil1-ldap:amd64 (1.5.4-1) ... Paramétrage de apache2-bin (2.4.10-10+deb8u5) ... Paramétrage de apache2-utils (2.4.10-10+deb8u5) ... Paramétrage de apache2-data (2.4.10-10+deb8u5) ... Paramétrage de apache2 (2.4.10-10+deb8u5) ... Enabling module mpm_event. Enabling module authz_core. Enabling module authz_host. Enabling module authn_core. Enabling module auth_basic. Enabling module access_compat. Enabling module authn_file. Enabling module authz_user. Enabling module alias. Enabling module dir. Enabling module autoindex. Enabling module env. Enabling module mime. Enabling module negotiation. Enabling module setenvif. Enabling module filter. Enabling module deflate. Enabling module status. Enabling conf charset. Enabling conf localized-error-pages. Enabling conf other-vhosts-access-log. Enabling conf security. Enabling conf serve-cgi-bin. Enabling site 000-default. Traitement des actions différées (« triggers ») pour libc-bin (2.19-18+deb8u4) ... Traitement des actions différées (« triggers ») pour systemd (215-17+deb8u4) ... ===== Utilisation ===== === commande apachectl === Vérifiez quels modules sont actuellement activés avec apachectl apachectl -t -D DUMP_MODULES AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message Loaded Modules: core_module (static) so_module (static) watchdog_module (static) http_module (static) log_config_module (static) logio_module (static) version_module (static) unixd_module (static) access_compat_module (shared) alias_module (shared) auth_basic_module (shared) authn_core_module (shared) authn_file_module (shared) authz_core_module (shared) authz_host_module (shared) authz_user_module (shared) autoindex_module (shared) deflate_module (shared) dir_module (shared) env_module (shared) filter_module (shared) mime_module (shared) mpm_prefork_module (shared) negotiation_module (shared) php5_module (shared) rewrite_module (shared) setenvif_module (shared) status_module (shared) shared veux dire que le module ne fait pas partie intégrante du binaire httpd et que c'est un module externe chargé en fonction des besoins de configuration. === vérification du fichier /etc/apache2/apache2.conf === apachectl configtest ou apachectl -t AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message Syntax OK et: /usr/sbin/apache2 -t [Sun Aug 14 11:56:44.606889 2016] [core:warn] [pid 25800] AH00111: Config variable ${APACHE_LOCK_DIR} is not defined [Sun Aug 14 11:56:44.607124 2016] [core:warn] [pid 25800] AH00111: Config variable ${APACHE_PID_FILE} is not defined [Sun Aug 14 11:56:44.607210 2016] [core:warn] [pid 25800] AH00111: Config variable ${APACHE_RUN_USER} is not defined [Sun Aug 14 11:56:44.607260 2016] [core:warn] [pid 25800] AH00111: Config variable ${APACHE_RUN_GROUP} is not defined [Sun Aug 14 11:56:44.607355 2016] [core:warn] [pid 25800] AH00111: Config variable ${APACHE_LOG_DIR} is not defined [Sun Aug 14 11:56:44.682181 2016] [core:warn] [pid 25800] AH00111: Config variable ${APACHE_LOG_DIR} is not defined [Sun Aug 14 11:56:44.683102 2016] [core:warn] [pid 25800] AH00111: Config variable ${APACHE_LOG_DIR} is not defined [Sun Aug 14 11:56:44.683204 2016] [core:warn] [pid 25800] AH00111: Config variable ${APACHE_LOG_DIR} is not defined AH00526: Syntax error on line 74 of /etc/apache2/apache2.conf: Invalid Mutex directory in argument file:${APACHE_LOCK_DIR} Ces deux commandes ont vérifié le même fichier de configuration notez la différence au niveau du retour... ===Connaitre la conssomation en ram=== ps -ylC apache2|awk ' { SUM += $8 } END { print SUM/1024 } ' Pour la consso moyenne/processus: ps -ylC apache2|awk ' {x += $8;y+= 1} END {print "\nUtilisation Memoire Apache (Mo): "x/1024;print "Moyenne du processus Apache (Mo):"x/ ((y-1)*1024)}' === Optimisation du fichier /etc/apache2/apache2.conf === Options Indexes FollowSymLinks AllowOverride None Require all granted DirectoryIndex index.php "DirectoryIndex" permet à apache de savoir quel fichier lire, ça lui evite de chercher un fichier index.html ou index.htm alors qu'il n'y en a pas. Cela diminue considérablement le nombre d'accès disque pour chaque requête. Vous pouvez également préciser plusieurs fichiers d'index Options Indexes FollowSymLinks AllowOverride None Require all granted DirectoryIndex index.php index.html Le fichier index.php sera traité avant le fichier index.html