====== Namebased Virtual Hosts ====== Vorraussetzung: [[apache]], [[bind]] und [[dns]] ===== Namen im DNS eintragen ===== Die Namen aller Virtual Hosts sind im DNS eingetragen, fehlende wie unter [[bind]] gezeigt hinzufügen ==== Namensauflösung testen ==== getent hosts notebook14.linuxhotel.de getent hosts iw.linuxhotel.de ===== SuSE ===== ==== HTML-Dateien ablegen ==== openSuSE ab 10.2: Default Host notebook34!

Default Host notebook34

Link zu Virtual Host
mkdir -p /srv/www/iw.linuxhotel.de/{cgi-bin,htdocs} openSuSE ab 10.2: Virtual Host iw!

Virtual Host iw

Link zu Default Host
==== Apache Konfiguration ==== openSuSE bis 12.3: NameVirtualHost * openSuSE ab 10.2: openSuSE ab 42.1: ServerName iw.linuxhotel.de DocumentRoot /srv/www/iw.linuxhotel.de/htdocs Require all granted ==== Konfigdateien überprüfen ==== apache2ctl configtest Vhosts anzeigen: apache2ctl -S ==== Konfiguration neu laden ==== apache2ctl graceful ===== CentOS 7 ===== ==== HTML-Dateien ablegen ==== Default Host notebook34!

Default Host notebook34

Virtual Host
mkdir -p /var/www/iw.linuxhotel.de/{cgi-bin,html} Virtual Host iw! Virtual Host iw
Default Host
==== Apache Konfiguration ==== Include vhosts.d/*.conf mkdir /etc/httpd/vhosts.d ServerName iw.linuxhotel.de DocumentRoot /var/www/iw.linuxhotel.de/html Require all granted ==== Konfigdateien überprüfen ==== apachectl configtest Vhosts anzeigen: httpd -S ==== Konfiguration neu laden ==== apachectl graceful ===== Debian / Ubuntu ===== ==== HTML-Dateien ablegen ==== Default Host notebook34!

Default Host notebook34

Link zu Virtual Host
mkdir -p /srv/iw.linuxhotel.de/{html,cgi-bin} Debian (ab 8): Virtual Host iw!

Virtual Host iw

Link zu Default Host
==== Apache Konfiguration ==== Debian (ab 8), Ubuntu (ab 16.04): ServerName iw.linuxhotel.de DocumentRoot /srv/iw.linuxhotel.de/html Require all granted a2ensite iw.linuxhotel.de ==== Konfigdateien überprüfen ==== apache2ctl configtest Vhosts anzeigen: apache2ctl -S ==== Konfiguration neu laden ==== apache2ctl graceful ===== Virtual-Host testen ===== === netcat === (( ''-C'' habe ich zum ersten Mal unter Debian 8 gebraucht )) netcat -Cv localhost 80 GET /test.html HTTP/1.1 host: iw.linuxhotel.de === wget === wget -nv -O - --header="Host: iw.linuxhotel.de" http://localhost/test.html === ab === ab -H 'Host: iw.linuxhotel.de' http://localhost/test.html