WN

WN (https://www.wn.se/forum/index.php)
-   Serversidans teknologier (https://www.wn.se/forum/forumdisplay.php?f=4)
-   -   Virtual host (https://www.wn.se/forum/showthread.php?t=35846)

Traveler 2009-03-18 20:13

Hej.

Jag har satt upp en server hemma på min comhem anslutning.

Jag kör med CentOS 5.2 och Apache 2.2.3.

Webservern funkar bra, den svarar snabbt på anrop både på IP, dynDNS och via domännamn.

Men jag får alla domännamn att komma direkt till rooten fast jag vill att varje domännamn skall gå till separat mapp.

Jag tycker att jag har testat allt.

Kan nån hjälpa mig???


Bifogar utdrag ur httpd.conf

#
# Use name-based virtual hosting.
#
#NameVirtualHost *:80
#
# NOTE: NameVirtualHost cannot be used without a port specifier
# (e.g. :80) if mod_ssl is being used, due to the nature of the
# SSL protocol.
#

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
#<VirtualHost *:80>
# ServerAdmin [email protected]
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>




<VirtualHost www2.xxxxxxxx.com:80>
DocumentRoot /var/www/html/www2.xxxxxxxx.com
<Directory /var/www/html/www2.xxxxxxx.com>
allow from all
Options +Indexes
</Directory>
VirtualDocumentRoot /var/www/html/www2.xxxxxxxx.com
</VirtualHost>

<VirtualHost www.xxxxxxxx.com:80>
DocumentRoot /var/www/html/www.xxxxxxxx.com
<Directory /var/www/html/www.xxxxxxx.com>
allow from all
Options +Indexes
</Directory>
VirtualDocumentRoot /var/www/html/www.xxxxxxxx.com
</VirtualHost>

crazzy 2009-03-18 20:39

En snabb hopskrivning av hur jag gör på mina maskiner:
Kod:

NameVirtualHost *:80
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com
<Directory /var/www/example.com>
Order allow,deny
allow from all
Options FollowSymLinks MultiViews
</Directory>
</VirtualHost>

Sen är det bara att kopiera VirtualHost biten och ändra till en annan domän. :)

Traveler 2009-03-18 22:00

Citat:

Originally posted by crazzy@Mar 18 2009, 21:39
En snabb hopskrivning av hur jag gör på mina maskiner:
Kod:

NameVirtualHost *:80
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com
<Directory /var/www/example.com>
Order allow,deny
allow from all
Options FollowSymLinks MultiViews
</Directory>
</VirtualHost>

Sen är det bara att kopiera VirtualHost biten och ändra till en annan domän. :)

Så här ser min fil ut nu och det funkar fortfarande inte.

Oavsett vilken adress jag skriver så kommer jag till rooten.


skriver jag ip-nummret så kommer jag till rooten
skriver jag ip-nummret/mappen så kommer jag till rätt sida.




Kod:

#  CustomLog logs/dummy-host.example.com-access_log common
#</VirtualHost>



NameVirtualHost *:80
<VirtualHost site1.com:80>
ServerName site1.com
ServerAlias www.site1.com
DocumentRoot /var/www/html/site1
<Directory "/var/www/html/site1">
Order allow,deny
allow from all
Options FollowSymLinks MultiViews
</Directory>
</VirtualHost>

NameVirtualHost *:80
<VirtualHost site2.com:80>
ServerName site2.com
ServerAlias www.site2.com
DocumentRoot /var/www/html/site2
<Directory "/var/www/html/site2">
Order allow,deny
allow from all
Options FollowSymLinks MultiViews
</Directory>
</VirtualHost>


emilv 2009-03-18 22:47

NameVirtualHost behöver du bara ange en gång.
Glöm inte att köra /etc/init.d/httpd reload efter att du ändrat konfig.

Traveler 2009-03-18 22:54

Citat:

Originally posted by emilv@Mar 18 2009, 23:47
NameVirtualHost behöver du bara ange en gång.
Glöm inte att köra /etc/init.d/httpd reload efter att du ändrat konfig.

Verkar inte hjälpa.

Kan det ha något med Comhem att göra..

crazzy 2009-03-18 23:38

Du ska inte ha domännamnet i VirtualHost deklarationen.

Den ska se likadan ut som NameVirtualHost.

Traveler 2009-03-19 01:22

Citat:

Originally posted by crazzy@Mar 19 2009, 00:38
Du ska inte ha domännamnet i VirtualHost deklarationen.

Den ska se likadan ut som NameVirtualHost.

Nu funkar det.

Jag hade skrivit adressen på för många ställen

Tack så mycket för hjälpen.


Alla tider är GMT +2. Klockan är nu 06:48.

Programvara från: vBulletin® Version 3.8.2
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Svensk översättning av: Anders Pettersson