Ich habe zwei Django-Sites. Der eine ist ein Aufstellungsort und der andere ist die Produktion. Ich möchte, dass die Staging-Site unter beta.ialexander.io
und die Produktion unter ialexander.io
sichtbar ist. Ich benutze mod_wsgi
mit Apache. Hier sind die beiden .conf
Dateien:Wie führe ich zwei separate Django-Sites basierend auf einer Subdomain aus?
ialexander.conf
:
# WSGI Stuff
WSGIPythonPath /var/www/Ullmannite
<VirtualHost *:80>
# WSGI Stuff
WSGIScriptAlias//var/www/Ullmannite/Ullmannite/wsgi.py
# Identification
ServerName ialexander.io
ServerAdmin [email protected]
# Public files
Alias /assets /var/www/Ullmannite/public
# Logs
ErrorLog ${APACHE_LOG_DIR}/iAlexander-Error.log
CustomLog ${APACHE_LOG_DIR}/iAlexander-Access.log combined
# Access
DocumentRoot "/var/www/Ullmannite/public"
<Directory "/var/www/Ullmannite/Ullmannite">
<Files "wsgi.py">
Require all granted
</Files>
</Directory>
<Directory "/var/www/Ullmannite/public">
Require all granted
</Directory>
</VirtualHost>
000-ialexander-staging.conf
:
# WSGI Stuff
WSGIPythonPath /var/www/Ullmannite-Staging
<VirtualHost *:80>
# WSGI Stuff
WSGIScriptAlias /beta /var/www/Ullmannite-Staging/Ullmannite/wsgi.py
# Identification
ServerName ialexander.io
ServerAdmin [email protected]
# Public files
Alias /assets /var/www/Ullmannite-Staging/public
# Logs
ErrorLog ${APACHE_LOG_DIR}/iAlexander-Staging-Error.log
CustomLog ${APACHE_LOG_DIR}/iAlexander-Staging-Access.log combined
# Access
DocumentRoot "/var/www/Ullmannite-Staging/public"
<Directory "/var/www/Ullmannite-Staging/Ullmannite">
<Files "wsgi.py">
Require all granted
</Files>
</Directory>
<Directory "/var/www/Ullmannite-Staging/public">
Require all granted
</Directory>
</VirtualHost>
Ich habe jetzt seit Wochen kämpfen mit diesem. Ursprünglich in 000-ialexander-staging.conf
hatte ich WSGIScriptAlias//var/www/Ullmannite-Staging/Ullmannite/wsgi.py
und ServerName beta.ialexander.io
, aber das gab mir nicht, was ich brauche. Ich erinnere mich nicht genau, was passiert ist, denn das war vor ungefähr zwei Wochen.
Zur Zeit habe ich 000-ialexander-staging.conf
deaktiviert, weil es die andere (ialexander.conf
) bricht. Jedoch, wenn ich 000-ialexander-staging.conf
aktiviert habe und ich besuche http://ialexander.io/beta
sehe ich die Produktionsstätte.
Ich weiß, es gibt eine Panne, wo Sie die Seiten haben müssen, die WSGIScriptAlias
Werte in Reihenfolge haben. Wenn ich das erste habe, wo WSGIScriptAlias
auf /
vor dem zweiten gesetzt wird, wird es das zuerst senden. Das ist der Grund, warum ich 000-ialexander-staging.conf
mit dem Präfix 000-
benannt habe. Ich wollte sicherstellen, dass Apache das zuerst liest, weil es derjenige ist, der einen WSGIScriptAlias
Wert von /beta
hat.
Warum sind diese Dinge passiert und wie kann ich die Produktionsstätte bei ialexander.io
zurück, aber die Staging One unter beta.ialexander.io
?
Ich bin eher ein nginx Kerl, aber wenn Sie taten 'WSGIScriptAlias //var/www/Ullmannit-Staging/Ullmannite/wsgi.py' und 'ServerName beta.ialexander.io' Sie haben es richtig gemacht. Was passiert ist, als du das getan hast, ist das eigentliche Problem. Mach das und poste, was danach passiert. –
Wenn ich das mache, verhält sich "ialexander.io" normal, aber wenn ich 'beta.alexander.io' besuche, wird eine andere Webseite angezeigt. Es gibt eine Seite zurück, die ich über Italien für die Schule gemacht habe. Wenn Sie zu http://beta.ialexander.io/ gehen, können Sie sehen, wie sich diese '.conf'-Dateien verhalten. Hier ist der Gist: https://gist.github.com/Arcrammer/256ad69a5ccc076fe657de505b83fa8a – IIllIIll