Linuxhotel Wiki

Wie ging das nochmal?

Benutzer-Werkzeuge

Webseiten-Werkzeuge


lpi2:apache-virtual-hosts

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen gezeigt.

Link zu der Vergleichsansicht

Beide Seiten, vorherige Überarbeitung Vorherige Überarbeitung
Nächste Überarbeitung
Vorherige Überarbeitung
Letzte Überarbeitung Beide Seiten, nächste Überarbeitung
lpi2:apache-virtual-hosts [2016/03/18 11:35]
ingo_wichmann [vhost-Konfiguration überprüfen]
lpi2:apache-virtual-hosts [2018/06/14 12:17]
127.0.0.1 Externe Bearbeitung
Zeile 1: Zeile 1:
 ====== Namebased Virtual Hosts ====== ====== Namebased Virtual Hosts ======
 Vorraussetzung:​ [[apache]], [[bind]] und [[dns]] Vorraussetzung:​ [[apache]], [[bind]] und [[dns]]
- 
-Achtung: in der Apache-Konfiguration ist die Reihenfolge wichtig. ​ 
  
 ===== Namen im DNS eintragen ===== ===== Namen im DNS eintragen =====
Zeile 11: Zeile 9:
  
 ===== SuSE ===== ===== SuSE =====
-''​/etc/apache2/listen.conf''​ : (SuSE  bis 12.3 )+==== HTML-Dateien ablegen ==== 
 +openSuSE ab 10.2: 
 +<file html /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>​ 
 +</​file>​
  
-<​file>​+  mkdir -p /​srv/​www/​iw.linuxhotel.de/​{cgi-bin,​htdocs} 
 + 
 +openSuSE ab 10.2: 
 +<​file ​html /​srv/​www/​iw.linuxhotel.de/​htdocs/​test.html>​ 
 +<​html>​ 
 +  <​head>​ 
 +    <​title>​Virtual Host iw!</​title>​ 
 +  </​head>​ 
 +  <​body>​ 
 +    <​h1>​Virtual Host iw</​h1>​ 
 +    Link zu <a href="​http://​notebook34.linuxhotel.de/​test.html">​Default Host</​a>​ 
 +  </​body>​ 
 +</​html>​ 
 +</​file>​ 
 + 
 +==== Apache Konfiguration ==== 
 +openSuSE bis 12.3: 
 +<file txt /​etc/​apache2/​listen.conf>
 NameVirtualHost * NameVirtualHost *
 </​file>​ </​file>​
  
-''​/​etc/​apache2/​conf.d/​default_vhost.conf''​ : ( SuSE ab 10.2 ) +openSuSE ab 10.2: 
- +<file txt /​etc/​apache2/​conf.d/​default_vhost.conf>​
-<file>+
 <​VirtualHost *> <​VirtualHost *>
 </​VirtualHost>​ </​VirtualHost>​
 </​file>​ </​file>​
  
-''​/​etc/​apache2/​vhosts.d/​iw.linuxhotel.de.conf''​ : ( SuSE ab 10.2 ) +openSuSE ab 42.1: 
- +<file txt /​etc/​apache2/​vhosts.d/​iw.linuxhotel.de.conf>​
-<file>+
 <​VirtualHost *> <​VirtualHost *>
   ServerName iw.linuxhotel.de   ServerName iw.linuxhotel.de
Zeile 32: Zeile 57:
  
   <​Directory "/​srv/​www/​iw.linuxhotel.de/​htdocs">​   <​Directory "/​srv/​www/​iw.linuxhotel.de/​htdocs">​
-    ​Order allow,​deny +    ​Require ​all granted
-    Allow from all+
   </​Directory>​   </​Directory>​
 </​VirtualHost>​ </​VirtualHost>​
 </​file>​ </​file>​
  
-==== Configdateien ​überprüfen ====+==== Konfigdateien ​überprüfen ====
   apache2ctl configtest   apache2ctl configtest
 +Vhosts anzeigen:
   apache2ctl -S   apache2ctl -S
  
-==== HTML-Dateien ablegen ​==== +==== Konfiguration neu laden ==== 
-''/​srv/​www/​htdocs/​test.html''​ : ( SuSE ab 10.2 )+  ​apache2ctl graceful
  
-<​file>​+===== CentOS 7 ===== 
 +==== HTML-Dateien ablegen ==== 
 +<​file ​html /​var/​www/​html/​test.html>
 <​html>​ <​html>​
   <​head>​   <​head>​
Zeile 51: Zeile 78:
   </​head>​   </​head>​
   <​body>​   <​body>​
-    Default Host notebook34<​br/>+    ​<h1>Default Host notebook34</​h1>
     <a href="​http://​iw.linuxhotel.de/​test.html">​Virtual Host</​a>​     <a href="​http://​iw.linuxhotel.de/​test.html">​Virtual Host</​a>​
   </​body>​   </​body>​
Zeile 57: Zeile 84:
 </​file>​ </​file>​
  
-  mkdir -p /srv/​www/​iw.linuxhotel.de/​{cgi-bin,​htdocs} +  mkdir -p /var/​www/​iw.linuxhotel.de/​{cgi-bin,​html}
- +
-''/​srv/​www/​iw.linuxhotel.de/​htdocs/​test.html''​ : ( SuSE ab 10.2 )+
  
-<​file>​+<​file ​html /​var/​www/​iw.linuxhotel.de/​html/​test.html>
 <​html>​ <​html>​
   <​head>​   <​head>​
Zeile 73: Zeile 98:
 </​file>​ </​file>​
  
-===== CentOS 5 ===== +==== Apache Konfiguration ​==== 
-''​/​etc/​httpd/​conf/​httpd.conf'':​ ( Centos 5 ) +<file txt /​etc/​httpd/​conf.d/vhosts.conf>
- +
-<file> +
-ServerAdmin root@notebook14.linuxhotel.de +
-ServerName notebook14.linuxhotel.de +
-DocumentRoot /​var/​www/​html +
- +
-<​Directory "/​var/​www/​html">​ +
-  Order allow,​deny +
-  Allow from all +
-</​Directory>​ +
- +
-ErrorLog logs/​error_log +
-CustomLog logs/​access_log combined +
-NameVirtualHost * +
 <​VirtualHost *:80> <​VirtualHost *:80>
 </​VirtualHost>​ </​VirtualHost>​
Zeile 96: Zeile 106:
 </​file>​ </​file>​
  
-  mkdir vhosts.d+  mkdir /etc/httpd/vhosts.d
  
-''​/​etc/​httpd/​vhosts.d/​iw.linuxhotel.de.conf''​ : ( Centos 5 ) +<file txt /​etc/​httpd/​vhosts.d/​iw.linuxhotel.de.conf>​
- +
-<file>+
 <​VirtualHost *:80> <​VirtualHost *:80>
   ServerName iw.linuxhotel.de   ServerName iw.linuxhotel.de
Zeile 106: Zeile 114:
  
   <​Directory "/​var/​www/​iw.linuxhotel.de/​html">​   <​Directory "/​var/​www/​iw.linuxhotel.de/​html">​
-    ​Order allow,​deny +    ​Require ​all granted
-    Allow from all+
   </​Directory>​   </​Directory>​
 </​VirtualHost>​ </​VirtualHost>​
 </​file>​ </​file>​
  
-==== Configdateien ​überprüfen ====+==== Konfigdateien ​überprüfen ====
   apachectl configtest   apachectl configtest
-  apachectl ​-S+Vhosts anzeigen: 
 +  httpd -S
  
-==== HTML-Dateien ablegen ​==== +==== Konfiguration neu laden ==== 
-''/​var/​www/​html/​test.html''​ : ( Centos 5 )+  ​apachectl graceful
  
-<​file>​+===== Debian / Ubuntu ===== 
 +==== HTML-Dateien ablegen ==== 
 +<​file ​html /​var/​www/​html/​test.html>
 <​html>​ <​html>​
   <​head>​   <​head>​
Zeile 125: Zeile 135:
   </​head>​   </​head>​
   <​body>​   <​body>​
-    Default Host notebook34<​br/> +    ​<h1>Default Host notebook34</​h1
-    <a href="​http://​iw.linuxhotel.de/​test.html">​Virtual Host</​a>​+    ​Link zu <a href="​http://​iw.linuxhotel.de/​test.html">​Virtual Host</​a>​
   </​body>​   </​body>​
 </​html>​ </​html>​
 </​file>​ </​file>​
  
-  mkdir /var/www/​iw.linuxhotel.de/​{cgi-bin,html+  mkdir -p /srv/​iw.linuxhotel.de/​{html,cgi-bin} 
- +ab Debian 5.0: 
-''​/var/www/​iw.linuxhotel.de/​html/​test.html''​ : ( Centos 5 ) +<file html /srv/​iw.linuxhotel.de/​html/​test.html>​
- +
-<file>+
 <​html>​ <​html>​
   <​head>​   <​head>​
Zeile 141: Zeile 149:
   </​head>​   </​head>​
   <​body>​   <​body>​
-    Virtual Host iw<br/> +    ​<h1>Virtual Host iw</h1
-    <a href="​http://​notebook34.linuxhotel.de/​test.html">​Default Host</​a>​+    ​Link zu <a href="​http://​notebook34.linuxhotel.de/​test.html">​Default Host</​a>​
   </​body>​   </​body>​
 </​html>​ </​html>​
 </​file>​ </​file>​
  
-===== Debian / Ubuntu ===== +==== Apache Konfiguration ​==== 
- +Debian 5 - 7//apache Version 2.2// 
-''/​etc/​apache2/​sites-available/​iw.linuxhotel.de''​ : ( Debian 5 - 7 //apache Version 2.2// +<​file ​txt /​etc/​apache2/​sites-available/​iw.linuxhotel.de>
-<​file>​+
 <​VirtualHost *:80> <​VirtualHost *:80>
   ServerName iw.linuxhotel.de   ServerName iw.linuxhotel.de
Zeile 162: Zeile 169:
 </​file>​ </​file>​
  
-''​/​etc/​apache2/​sites-available/​iw.linuxhotel.de.conf''​ : ( Debian 8 ) //apache Version 2.4// +Debian ab 8, Ubuntu 16.04: //apache Version 2.4// 
-<file>+<file txt /​etc/​apache2/​sites-available/​iw.linuxhotel.de.conf>​
 <​VirtualHost *:80> <​VirtualHost *:80>
   ServerName iw.linuxhotel.de   ServerName iw.linuxhotel.de
Zeile 173: Zeile 180:
 </​VirtualHost>​ </​VirtualHost>​
 </​file>​ </​file>​
-  mkdir -p /​srv/​iw.linuxhotel.de/​{html,​cgi-bin} 
   a2ensite iw.linuxhotel.de   a2ensite iw.linuxhotel.de
  
-==== Configdateien ​überprüfen ====+==== Konfigdateien ​überprüfen ====
   apache2ctl configtest   apache2ctl configtest
- +Vhosts anzeigen:
-==== HTML-Dateien ablegen ==== +
- +
-''/​srv/​iw.linuxhotel.de/​html/​index.html''​ : ( Debian 5.0 ) +
- +
-<​file>​ +
-<​html>​ +
-  <​head>​ +
-    <​title>​Virtual Host iw!</​title>​ +
-  </​head>​ +
-  <​body>​ +
-    Virtual Host iw<​br/>​ +
-    <a href="​http://​notebook34.linuxhotel.de/​test.html">​Default Host</​a>​ +
-  </​body>​ +
-</​html>​ +
-</​file>​ +
- +
-===== Testen ===== +
-==== vhost-Konfiguration überprüfen ==== +
- +
-Debian, openSuSE, Ubuntu:+
   apache2ctl -S   apache2ctl -S
  
-Centos: +==== Konfiguration ​neu laden ====
-  httpd -S +
- +
-==== Apache ​neu starten ​==== +
-  /​etc/​init.d/​apache2 restart +
- +
-oder Configtest und Reload in einem: graceful +
- +
-SuSE 10.2, Debian 4.0:+
   apache2ctl graceful   apache2ctl graceful
  
-Centos 5: +===== Virtual-Host testen ​===== 
-  apachectl graceful +=== netcat === 
- +(( ''​-C''​ habe ich zum ersten Mal unter Debian 8 gebraucht )) 
-==== Virtual-Host testen ==== +  netcat -Cv localhost 80 
-=== netcat ​/ telnet ​=== +  GET /​test.html ​HTTP/1.1
-  netcat -localhost 80 +
-  GET /​test.html ​http/1.1+
   host: iw.linuxhotel.de   host: iw.linuxhotel.de
  
lpi2/apache-virtual-hosts.txt · Zuletzt geändert: 2021/11/28 19:18 von arne_wichmann