Sponsor-Board.de

Normale Version: Apache2 vHost konfigurieren
Du siehst gerade eine vereinfachte Darstellung unserer Inhalte. Normale Ansicht mit richtiger Formatierung.
Hallo liebe Community,

derzeit arbeite ich mit meinem Bruder an einem Projekt, was auch schon bald released werden soll.

Die bisherigen vHosts waren nur "schnell schnell" konfiguriert, damit wir erstmal arbeiten können.

Gerne würden wir das ganze nun richtig konfigurieren!

Erstmal ein paar Infos zum System und dem, was konfiguriert werden soll:
Linux Debian x64 System
Apache2 als Webserver
1 .de TLD
2 Subdomains
1 IP Adresse

Hätte hier jemand passende Konfigurationen für die vHosts? Und vor allem - soll in der ports.conf der NameVirtualHost auf meine IP:80 zeigen (Und dann in den vHosts auch)?


Bedanke mich schon einmal im voraus.

Beste Grüße
G1ggles
Hallo
unter /etc/apache2/sites-enabled/
erstellst du dir für jeden vhost einen Datei.

Die sehen immer so aus:

Code:
# Ensure that Apache listens on port 80
Listen 80

# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.example.com

# Other directives here

</VirtualHost>

Meine bisherige Konfiguration der domain.tld sieht wiefolgt aus:

Code:
<VirtualHost XXX.XXX.XXX.XXX:80>
        ServerAdmin [email protected]
        ServerName domain.tld
        ServerAlias www.domain.tld

        DocumentRoot /var/www/domain.tld/htdocs

        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/domain.tld/htdocs>
                Options -Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


Die Konfigurationsdatei der Subdomain admin.domain.tld:

Code:
<VirtualHost XXX.XXX.XXX.XXX:80>
        ServerAdmin [email protected]
        ServerAlias admin.domain.tld

        DocumentRoot /var/www/domain.tld/subdomains/admin.domain.tld/htdocs

        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/domain.tld/subdomains/admin.domain.tld/htdocs/>
                Options -Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


Die Konfigurationsdatei der Subdomain hosting.domain.tld:

Code:
<VirtualHost XXX.XXX.XXX.XXX:80>
        ServerAdmin [email protected]
        ServerAlias hosting.domain.tld

        DocumentRoot /var/www/domain.tld/subdomains/hosting.domain.tld/htdocs

        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/domain.tld/subdomains/hosting.domain.tld/htdocs/>
                Options -Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


Aktiviert habe ich die Konfigurationen im Ordner /etc/apache2/sites-available/ mit dem Befehl:
a2ensite domain.tld
a2ensite admin.domain.tld
a2ensite hosting.domain.tld

Dann noch ein kurzer Neustart des Apache2:
service apache2 restart

Sobald die Konfiguration admin.domain.tld aktiviert ist, wird beim Aufrufen von domain.tld im Browser das DocumentRoot der Subdomain admin.domain.tld aufgerufen. Warum kommt dieser Fehler?

Die VirtualHost IP habe ich auf die meiner VPS gesetzt (Habe nur eine IP Adresse), in der ports.conf in /etc/apache2/ habe ich den NameVirtualHost ebenfalls auf die IP:80 gestellt.


Was mache ich falsch?


@Vogel
Ich gebe sicherlich niemanden Zugriff zu meiner VPS Biggrin Du kannst mir Konfigurationen gerne nennen oder hier über das Forum helfen, aber du bekommst sicherlich keinen Zugriff zu meiner VPS Wink

Referenz-URLs