20 avr.
Par Nico,à 13:55 :: Technique :: #50 :: rss
Les Virtual Host avec Apache2 quand on n'a qu'une seule adresse ip ...
Juste un pense bête
Exemple de configuration d'apache:
NameVirtualHost *
<VirtualHost *>
ServerAdmin webmaster@thenico.fr.eu.org
DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
<VirtualHost *>
ServerAdmin kmehdi@thenico.fr.eu.org
ServerName lecentral.eu.org
DocumentRoot /usr/chroot/home/kmehdi/public_html
<Directory "/usr/chroot/home/kmehdi/public_html">
Options Indexes MultiViews
AllowOverride FileInfo AuthConfig Indexes
Order allow,deny
allow from all
</Directory>
ErrorLog /home/kmehdi/logs/error.log
LogLevel warn
CustomLog /home/kmehdi/logs/access.log combined
</VirtualHost>
<VirtualHost *>
ServerAdmin webmaster@thenico.fr.eu.org
ServerName xavia.thenico.fr.eu.org
DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
Ceci configure 2 virtual host en se basant sur le parametre Host: de la requette HTTP du navigateur:
- D'abord le catch-all qui quand aucune information Host: n'est donné pointe sur /var/www
- Puis lecentral.eu.org qui est dans /usr/chroot/home/kmehdi/public_html
- Et xavia.thenico.fr.eu.org qui est dans /var/www
Pour ajouter un nom vhost, il suffit de rajouter un block <VirtualHost></VirtualHost>
en précisant bien le ServerName
sinon cela ne fonctionnera pas !
8 vote(s)
Commentaires
1. Le jeudi 20 avril 2006 à 21:43, par KMehdi
2. Le samedi 22 avril 2006 à 22:47, par Nico
Ajouter un commentaire
Les commentaires pour ce billet sont fermés.