Par defaut, Apache sur Debian 11 a un bloc de serveur active par defaut qui est configure
pour servir des documents a partir du /var/www/html annuaire.
Si vous exploitez un site Web, vous pouvez modifier ce bloc de serveur en fonction du votre.
Cependant, si vous hebergez plusieurs sites Web, vous devez creer une nouvelle structure de
repertoires pour vos differents domaines. Exemple : m17.f1ptl.net
###############################################################################################
Installation du module pour Apache2 mod-php
apt install libapache2-mod-php -y
Creation du repertoire
sudo mkdir /var/www/m17.f1ptl.net
Modification du GID/UID
chown -R www-data:www-data /var/www/m17.f1ptl.net
Liste du repertoire
ls -l /var/www/
total 8
drwxr-xr-x 23 www-data www-data 4096 Jan 14 22:12 html
drwxr-xr-x 2 www-data www-data 4096 Jan 15 18:45 m17.f1ptl.net
Changement des droits d'acces
chmod -R 755 /var/www/m17.f1ptl.net
Creation du fichier index.html pour valider les acces
nano /var/www/m17.f1ptl.net/index.html
Copier et coller le texte dans le fichier index.html
Bonjour m17.f1ptl.net !
Success ! Activation Virtual Hosts m17.f1ptl.net
Creer un Hote Virtuel
nano /etc/apache2/sites-available/m17.f1ptl.net.conf
Copier et coller le texte dans le fichier m17.f1ptl.net.conf
ServerAdmin ff1ptl@gmail.com
ServerName m17.f1ptl.net
ServerAlias www.m17.f1ptl.net
DocumentRoot /var/www/m17.f1ptl.net
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Desactivez le fichier de bloc de serveur installe par defaut existant 000-default.conf
avec la commande a2dissite
a2dissite 000-default.conf
Activez votre fichier d'hote virtuel avec la commande a2ensite
a2ensite m17.f1ptl.net.conf
systemctl reload apache2
Avant de le mettre en ligne, testez votre fichier de configuration à l'aide de la commande
apache2ctl configtest
Si tout fonctionne correctement, la sortie doit être
Syntax OK
Redemarrage de votre server Apache2
systemctl restart apache2
Verification du demarrage de votre serveur Apache2
systemctl status apache2
=> apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2022-01-15 19:19:07 CET; 8s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 126371 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 126375 (apache2)
Tasks: 6 (limit: 19172)
Memory: 12.5M
CPU: 76ms
CGroup: /system.slice/apache2.service
├─126375 /usr/sbin/apache2 -k start
├─126377 /usr/sbin/apache2 -k start
├─126378 /usr/sbin/apache2 -k start
├─126379 /usr/sbin/apache2 -k start
├─126380 /usr/sbin/apache2 -k start
└─126381 /usr/sbin/apache2 -k start
Jan 15 19:19:07 vmi739877.contaboserver.net systemd[1]: Starting The Apache HTTP Server...
Jan 15 19:19:07 vmi739877.contaboserver.net systemd[1]: Started The Apache HTTP Server.
Apache devrait actuellement servir la page de destination que vous avez creee pour votre nouveau domaine
http://m17.f1ptl.net
La page affiche
Success ! Activation Virtual Hosts m17.f1ptl.net
73's
F1PTL Bruno