RHEL 7 configurer des hôtes virtuels

Ludovic QUENEC'HDU
Ludovic QUENEC'HDU Ajouter un commentaire 1e lecture en min

RHEL7: Les Virtualhost.

Pre requis
Disposer d’un serveur web apache installé

Procédure

Le site web se nomme vhost.alphorm.lan. Création du répertoire /var/www/html/vhost.alphorm.lan
# cd /var/www/html
# mkdir vhost.alphorm.lan
Créer un fichier index.html et assigner le context pour SELinux
# echo "Ceci est un hôte virtuel." > vhost.alphorm.lan/index.html
# restorecon -R vhost.alphorm.lan
Créer un fichier /etc/httpd/conf.d/vhosts.conf et insérer les lignes suivantes ::
<VirtualHost *:80>
ServerAdmin webmaster@vhost.alphorm.lan
DocumentRoot /var/www/html/vhost.alphorm.lan
ServerName vhost.alphorm.lan
ErrorLog logs/vhost.alphorm.lan-error_log
CustomLog logs/vhost.alphorm.lan-access_log common
</VirtualHost>
On valide la configuration:
# apachectl configtest
Syntax OK
# httpd -t
Syntax OK
Redémarrage du service httpd :
# apachectl restart
OU
# systemctl restart httpd
Vérification des virtualhost :
# httpd -D DUMP_VHOSTS
VirtualHost configuration:
*:80                   is a NameVirtualHost
         default server vhost.alphorm.lan (/etc/httpd/conf.d/vhosts.conf:1)
         port 80 namevhost vhost.alphorm.lan (/etc/httpd/conf.d/vhosts.conf:1)
         port 80 namevhost vhost.alphorm.lan (/etc/httpd/conf.d/vhosts.conf:1)

On test

On installe un navigateur web :
# yum install -y elinks
# elinks http://vhost.alphorm.lan
Partager cet article
Par Ludovic QUENEC'HDU Expert en Virtualisation et Sécurité Informatique au Service de Grands Comptes et du Logiciel Libre
Ludovic QUENECHDU est un véritable virtuose de la virtualisation et de la sécurité informatique. Depuis son indépendance professionnelle en 2000, il a apporté son expertise à de prestigieux clients tels que Cameroun Telecom, Merryl Lynch, Ernst & Young, AXA, et bien d'autres. En parallèle, Ludovic s'engage régulièrement dans le démarrage de petites entreprises, notamment dans le domaine du logiciel libre, une passion qu'il chérit pour ses valeurs de partage et d'échange. Son parcours professionnel et sa passion pour la technologie en font un acteur incontournable de l'industrie informatique.
Laisser un commentaire