• This forum has a zero tolerance policy regarding spam. If you register here to publish advertising, your user account will be deleted without further questions.

Ubuntu Server & Vhost

D

Deleted member 18741

Guest
Hallo liebe Community,

ich kämpfe als Neuling mit der konfiguration eines Linux Server (Ubuntu).
Nach 4 Tagen des kämpfens und viel lesen läuft das Ding jetzt.
Bei der Konfiguration des vhost verzweifel ich langsam.

Ich habe 2 Domains (domain-1 & domain-2) und der Server hat eine IP-Adresse (213.050.11.190).
Beide Domains zeigen via A-Record auf die IP-Adresse 213.050.11.190.
Jetzt muss ich es irgendwie hin bekommen, das ich auf dem Server mehrere Webseiten betreiben kann.

Beim Aufruf der beiden Domains wird aktuell aber der selbe Inhalt angezeigt.

Was mache ich FALSCH?

Danke schon mal für eure Antworten.

-------------------------------------------------------------
mkdir -p /var/www/html/domain-1_de
-------------------------------------------------------------
joe /etc/apache2/sites-available/domain-1_de.conf
-------------------------------------------------------------
<VirtualHost 213.050.11.190:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.

ServerName domain-1.de

ServerAdmin admin@irgendeine-domain.mobi
DocumentRoot /var/www/html/domain-1_de/wordpress

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/domain-1_de_error.log
CustomLog ${APACHE_LOG_DIR}/domain-1_de_access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with ""a2disconf"".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
-------------------------------------------------------------
a2ensite domain-1_de.conf

#############################################################
#############################################################

joe /etc/apache2/sites-available/www_domain-1_de_de.conf
-------------------------------------------------------------
<VirtualHost 213.050.11.190:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.

ServerName www.domain-1_de.de

ServerAdmin admin@irgendeine-domain.mobi
DocumentRoot /var/www/html/domain-1_de_de/wordpress

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/domain-1_de_error.log
CustomLog ${APACHE_LOG_DIR}/domain-1_de_access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with ""a2disconf"".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
-------------------------------------------------------------
a2ensite www_domain-1_de.conf
-------------------------------------------------------------
 
Das sich von mir geänderte Beispiele der original vhost Datei. ;-)
Ja habe ich und auch den Server Physisch neu gestartet + systemd-resolve - -flush-caches.
Den DNS Cache meines PC habe ich auch bereits geleert.
 
Deine beiden Beispiele oben zeigen auf das gleiche DocRoot, müssen also das gleiche Ergebnis bringen.
Ansonsten man nachgesehen, ob die Symlinks zu den einzelnen Domains auch alle unter /etc/apache2/sites-enabled existieren?
 
Danke @danton !

Nächste Frage.

Woher kommt der default Eintrag (ganz oben)?

default server m-m-xxxxxxx.de (/etc/apache2/sites-enabled/m_m_xxxxxxx_de.conf:1)
port 80 namevhost m-m-xxxxxxx.de (/etc/apache2/sites-enabled/m_m_xxxxxxx_de.conf:1)
port 80 namevhost tutorial.xxxxxxx.de (/etc/apache2/sites-enabled/tutorial_xxxxxxx_de.conf:1)
port 80 namevhost www.m-m-xxxxxxx.de (/etc/apache2/sites-enabled/www_m_m_bosbach_de.conf:1)
port 80 namevhost www.tutorial.xxxxxxx.de (/etc/apache2/sites-enabled/www_tutorial_xxxxxxx_de.conf:1)
 
Der erste vHost in der Apache-Konfiguration ist immer der Default-Eintrag. Auf den gehen alle Anfragen, die nicht per ServerName oder ServerAlias gematcht werden können. Ich habe dazu unter sites-available eine default.conf liegen, die einfach nur eine Weiterleitung auf eine bestimmte Domain enthält (damit die Adresse sich in der Browserzeile ändert) und diese manuell in sites-enabled als 00-default.conf verlinkt (durch wird dieser vHost als erstes geladen). Außerdem habe ich die meine Domains mit und ohne www in einer Datei zusammengefasst (ich leite ohne subdomain einfach nach www weiter, man kann aber auch mit ServerAlias arbeiten) - bei einer Anpassung muss man so nur an einer Stelle was ändern.
 
Back
Top