potrebujem nastavit virtual hosts pod apache 2. aktualna situacia:
- dva weby na jednom apachi iba v lokalnej lan
- dns mena su lwis a ris su nastavene na tu istu IP
- kazdy web ma svoju directory: /var/www/lwis a /var/www/ris
da sa nastavit, aby ked napisem do adresneho riadku v prehliadaci lwis aby mi nacital /var/www/lwis/index.php a ked napisem ris do adresneho riadku aby nacital /var/www/ris/index.php?
momentalne mi funguje stranka lwis, potrebujem vsak pridat este tu druhu.
nemoze to fungovat takym stylom, ze oslovim trebars ip:80 pre lwis a ip:8080 pre ris, pretoze su zablokovane porty.
obidva musia bezat na jednom porte, s tym, ze rozlisovat bude na zaklade dns mena ktore zada uzivatel.
nejake napady? nebezime v sieti s domenou. OS je debian.
V konfiguraku treba mat uvedenu cestu k modulu virtual hosts
LoadModule vhost_alias_module cesta_k/mod_vhost_alias.so
Dalej tam mam include na prislusny konfigurak
Include etc/apache22/extra/httpd-vhosts.conf
No a obsah samotneho httpd-vhosts.conf je (trochu som ho prisposobil, aby sedel na tvoju poziadavku)
<VirtualHost *:80>
# DocumentRoot a ServerName su podstatne !
DocumentRoot "/var/www/lwis"
ServerName www.lwis.sk
# Moze sa pridat aj adresa na administratora servera,
# ktora sa zobrazi navstevnikovi pri chybovych hlaskach
ServerAdmin webmaster@lwis.sk
# ErrorLog a CustomLog mozu ostat zakomentovane,
# v tom pripade bude logovat do standardnych logov
# ErrorLog "/var/log/apache/lwis.log"
# CustomLog "/var/log/apache/lwis-custom.log" common
</VirtualHost>
<VirtualHost *:80>
# DocumentRoot a ServerName su podstatne !
DocumentRoot "/var/www/ris"
ServerName www.ris.sk
# Moze sa pridat aj adresa na administratora servera,
# ktora sa zobrazi navstevnikovi pri chybovych hlaskach
ServerAdmin webmaster@ris.sk
# ErrorLog a CustomLog mozu ostat zakomentovane,
# v tom pripade bude logovat do standardnych logov
# ErrorLog "/var/log/apache/ris.log"
# CustomLog "/var/log/apache/ris-custom.log" common
</VirtualHost>
No a aby po zadani url adresy prehliadac zobrazil index.php, tak si treba najst v konfiguraku
DirectoryIndex index.html
a zmenit ho na
DirectoryIndex index.php index.html
DocumentRoot "/var/www/lwis"
ServerName www.lwis.sk
ServerAdmin webmaster@lwis.sk
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/var/www/ris"
ServerName www.ris.sk
ServerAdmin webmaster@ris.sk
</VirtualHost>
Ale vypisuje mi pri restarte apacha:
Forcing reload of web server (apache2)...apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[Mon Sep 22 10:54:12 2008] [warn] _default_ VirtualHost overlap on port 80, the first has precedence
httpd (no pid file) not running
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[Mon Sep 22 10:54:12 2008] [warn] _default_ VirtualHost overlap on port 80, the first has precedence
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/var/www/lwis"
ServerName www.lwis.sk
ServerAdmin webmaster@lwis.sk
ErrorLog "/var/log/apache/lwis.log"
CustomLog "/var/log/apache/lwis-custom.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/var/www/ris"
ServerName www.ris.sk
ServerAdmin webmaster@ris.sk
ErrorLog "/var/log/apache/ris.log"
CustomLog "/var/log/apache/ris-custom.log" common
</VirtualHost>
Ale stale chyba:
Forcing reload of web server (apache2)...apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName.
Funguje mi iba lwis web stranka, ris sa nenacitava
# Include the virtual host configurations:
Include /etc/apache2/sites-enabled/
v sites-enabled (subor 000-default) mas virtualnych hostov, ten subor musis editovat, plus pridat zaznam do /etc/hosts
priklad zaznamu:
<VirtualHost *:80>
ServerName eshop
DocumentRoot "/var/www/eshop/"
<Directory "/var/www/eshop/">
Options None
AllowOverride None
Order allow,deny
Allow from all
DirectoryIndex index.php
</Directory>
</VirtualHost>
a kde napisem do browsera http://eshop tak mi nacita index.php z adresara /var/www/eshop/
to varovanie vyriesis, ak v apache2 konfiguraku pridas zaznam ServerName blabla
ako mas ty eshop. tak by som chcel este aj normal prezencnu stranku ktora by bezala, a ak nedam http://eshop ale http://web aby mi bezal web a ked http://echop tak aby bezal eshop, toto potrebujem. jeden web mi ide, druhy nie a nie...
v /etc/hosts mam pridane
10.232.129.5 lwis
10.232.129.5 ris
127.0.0.1 lwis
127.0.0.1 ris
ale ani tak ani tak to nejde
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/var/www/lwis"
ServerName lwis
ErrorLog "/var/log/apache/lwis.log"
CustomLog "/var/log/apache/lwis-custom.log" common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/var/www/ris"
ServerName ris
ErrorLog "/var/log/apache/ris.log"
CustomLog "/var/log/apache/ris-custom.log" common
</VirtualHost>
a v /etc/hosts
10.232.129.5 lwis
10.232.129.5 ris
Dik za help, hlavny problem bol v tom, ze dns ktore si berie ten server z ineho servra, neboli este pridane. ja som myslel ze to je nezavisle ked som to pridaval priamo do /etc/hosts, ale asi to na to vplyv ma.