-C habe ich zum ersten Mal unter Debian 8 gebraucht lpi2:apache-virtual-hosts
Dies ist eine alte Version des Dokuments!
Inhaltsverzeichnis
Namebased Virtual Hosts
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:
- /srv/www/htdocs/test.html
<html> <head> <title>Default Host notebook34!</title> </head> <body> <h1>Default Host notebook34</h1> Link zu <a href="http://iw.linuxhotel.de/test.html">Virtual Host</a> </body> </html>
mkdir -p /srv/www/iw.linuxhotel.de/{cgi-bin,htdocs}
openSuSE ab 10.2:
Apache Konfiguration
openSuSE bis 12.3:
- /etc/apache2/listen.conf
NameVirtualHost *
openSuSE ab 10.2:
- /etc/apache2/conf.d/default_vhost.conf
<VirtualHost *> </VirtualHost>
openSuSE ab 42.1:
- /etc/apache2/vhosts.d/iw.linuxhotel.de.conf
<VirtualHost *> ServerName iw.linuxhotel.de DocumentRoot /srv/www/iw.linuxhotel.de/htdocs <Directory "/srv/www/iw.linuxhotel.de/htdocs"> Require all granted </Directory> </VirtualHost>
Konfigdateien überprüfen
apache2ctl configtest
Vhosts anzeigen:
apache2ctl -S
Konfiguration neu laden
apache2ctl graceful
CentOS 7
HTML-Dateien ablegen
- /var/www/html/test.html
<html> <head> <title>Default Host notebook34!</title> </head> <body> <h1>Default Host notebook34</h1> <a href="http://iw.linuxhotel.de/test.html">Virtual Host</a> </body> </html>
mkdir -p /var/www/iw.linuxhotel.de/{cgi-bin,html}
Apache Konfiguration
- /etc/httpd/conf.d/vhosts.conf
<VirtualHost *:80> </VirtualHost> Include vhosts.d/*.conf
mkdir /etc/httpd/vhosts.d
- /etc/httpd/vhosts.d/iw.linuxhotel.de.conf
<VirtualHost *:80> ServerName iw.linuxhotel.de DocumentRoot /var/www/iw.linuxhotel.de/html <Directory "/var/www/iw.linuxhotel.de/html"> Require all granted </Directory> </VirtualHost>
Konfigdateien überprüfen
apachectl configtest
Vhosts anzeigen:
httpd -S
Konfiguration neu laden
apachectl graceful
Debian / Ubuntu
HTML-Dateien ablegen
- /var/www/html/test.html
<html> <head> <title>Default Host notebook34!</title> </head> <body> <h1>Default Host notebook34</h1> Link zu <a href="http://iw.linuxhotel.de/test.html">Virtual Host</a> </body> </html>
mkdir -p /srv/iw.linuxhotel.de/{html,cgi-bin}
ab Debian 5.0:
Apache Konfiguration
Debian 5 - 7: apache Version 2.2
- /etc/apache2/sites-available/iw.linuxhotel.de
<VirtualHost *:80> ServerName iw.linuxhotel.de DocumentRoot /srv/iw.linuxhotel.de/html <Directory "/srv/iw.linuxhotel.de/html"> Order allow,deny Allow from all </Directory> </VirtualHost>
Debian ab 8, Ubuntu 16.04: apache Version 2.4
- /etc/apache2/sites-available/iw.linuxhotel.de.conf
<VirtualHost *:80> ServerName iw.linuxhotel.de DocumentRoot /srv/iw.linuxhotel.de/html <Directory "/srv/iw.linuxhotel.de/html"> Require all granted </Directory> </VirtualHost>
a2ensite iw.linuxhotel.de
Konfigdateien überprüfen
apache2ctl configtest
Vhosts anzeigen:
apache2ctl -S
Konfiguration neu laden
apache2ctl graceful
Virtual-Host testen
netcat
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
1)
lpi2/apache-virtual-hosts.1638127091.txt.gz · Zuletzt geändert: 2021/11/28 19:18 von arne_wichmann
