Dies ist eine alte Version des Dokuments!
Fedora:
httpd
SuSE:
apache2 apache2-prefork
Debian ab 3.1:
apache2 apache2-mpm-prefork
Im einfachsten Fall
/var/www/html/test.html
: ( CentOS )
/srv/www/htdocs/test.html
: ( SuSE 10.0 )
/var/www/index.html
: ( Debian 5.0 )
<html> <head> <title>Hello World!</title> </head> <body> Hello World </body> </html>
telnet localhost 80 GET http://localhost/test.html HTTP/1.1 Host: localhost
Die Namen aller Virtual Hosts müssen im DNS eingetragen sein, fehlende wie unter bind gezeigt hinzufügen
getent hosts notebook14.linuxhotel.de getent hosts iw.linuxhotel.de
/etc/apache2/listen.conf
: ( SuSE 10.2 )
NameVirtualHost *
/etc/apache2/conf.d/default_vhost.conf
: ( SuSE 10.2 )
<VirtualHost *> </VirtualHost>
/etc/apache2/vhosts.d/iw.linuxhotel.de.conf
: ( SuSE 10.2 )
<VirtualHost *> ServerName iw.linuxhotel.de DocumentRoot /srv/www/iw.linuxhotel.de/htdocs <Directory "/srv/www/iw.linuxhotel.de/htdocs"> Order allow,deny Allow from all </Directory> </VirtualHost>
apache2ctl configtest apache2ctl -t
/srv/www/htdocs/test.html
: ( SuSE 10.2 )
<html> <head> <title>Default Host notebook34!</title> </head> <body> Default Host notebook34 </body> </html>
mkdir /srv/www/iw.linuxhotel.de/{cgi-bin,htdocs}
/srv/www/iw.linuxhotel.de/htdocs/test.html
: ( SuSE 10.2 )
<html> <head> <title>Virtual Host iw!</title> </head> <body> Virtual Host iw </body> </html>
/etc/httpd/conf/httpd.conf
: ( Centos 5 )
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> Include vhosts.d/*.conf
mkdir vhosts.d
/etc/httpd/vhosts.d/iw.linuxhotel.de.conf
: ( Centos 5 )
<VirtualHost *:80> ServerName iw.linuxhotel.de DocumentRoot /var/www/iw.linuxhotel.de/html <Directory "/var/www/iw.linuxhotel.de/html"> Order allow,deny Allow from all </Directory> </VirtualHost>
apachectl configtest apachectl -S
/var/www/html/test.html
: ( Centos 5 )
<html> <head> <title>Default Host notebook34!</title> </head> <body> Default Host notebook34 </body> </html>
mkdir /var/www/iw.linuxhotel.de/{cgi-bin,html}
/var/www/iw.linuxhotel.de/html/test.html
: ( Centos 5 )
<html> <head> <title>Virtual Host iw!</title> </head> <body> Virtual Host iw </body> </html>
/etc/apache2/sites-enabled/000-default
: ( Debian 5.0 )
<VirtualHost *:80> ServerAdmin webmaster@notebook32.linuxhotel.de DocumentRoot /var/www/notebook32.linuxhotel.de/html <Directory /var/www/notebook32.linuxhotel.de/html> Order allow,deny allow from all </Directory> ErrorLog /var/log/apache2/error.log CustomLog /var/log/apache2/access.log combined </VirtualHost>
mkdir -p /var/www/notebook32.linuxhotel.de/html
/etc/apache2/sites-available/iw.linuxhotel.de
: ( Debian 5.0 )
<VirtualHost *:80> ServerName iw.linuxhotel.de DocumentRoot /var/www/iw.linuxhotel.de/html <Directory "/var/www/iw.linuxhotel.de/html"> Order allow,deny Allow from all </Directory> </VirtualHost>
mkdir -p /var/www/iw.linuxhotel.de/{html,cgi-bin} a2ensite iw.linuxhotel.de
apache2ctl configtest
/var/www/notebook32.linuxhotel.de/html/index.html
: ( Debian 5.0 )
<html> <head> <title>Default Host notebook32!</title> </head> <body> Default Host notebook32 </body> </html>
/var/www/iw.linuxhotel.de/html/index.html
: ( Debian 5.0 )
<html> <head> <title>Virtual Host iw!</title> </head> <body> Virtual Host iw </body> </html>
vhost-Konfiguration überprüfen:
Debian:
apache2ctl -S
SuSE, Centos:
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
Centos 5:
apachectl graceful
Virtual-Host testen:
telnet localhost 80 GET /test.html http/1.1 host: iw.linuxhotel.de
/etc/apache2/ports.conf
: ( Debian 4.0 )
Listen 0.0.0.0:80