django 的多个子域

Multiple subdomains with django

我正在尝试 运行 在 signal.server.comnoise.server.com.

上使用 Django + Apache 的网络服务器上的两个应用程序

目前两个 URL 都指向 singal.server.com

我一直在更改选项,但无济于事。这是我的 server.com 虚拟主机,运行良好

WSGIPythonPath /var/www/html/d_signal
WSGISocketPrefix run/wsgi

<VirtualHost *:80>
        ServerAdmin hello@mail.server.com
        ServerName www.server.com
        DocumentRoot /var/www/html

        <Directory /var/www/html/>
            Options Indexes FollowSymLinks
            AllowOverride All
        </Directory>

        ErrorLog /var/log/httpd/server.error.log
        CustomLog /var/log/httpd/access.log combined

        <IfModule mod_dir.c>
            DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
        </IfModule>
</VirtualHost>

单声道虚拟配置。server.com

 <VirtualHost *:80>
    ServerAdmin hello@server.com
    ServerName signal.server.com
    ServerAlias signal.server.com
    DocumentRoot /var/www/html/d_signal/d_signal
    WSGIScriptAlias / /var/www/html/d_signal/d_signal/wsgi.py
    WSGIDaemonProcess signal.server.com python-home=/var/www/html/d_signal/signal_env socket-user=apache
    WSGIProcessGroup signal.server.com

     Alias /static /var/www/html/d_signal/static
     <Directory /var/www/html/d_signal/sig/templates/sig/static>
         #Require all granted
     </Directory>

     <Directory /var/www/html/d_signal/d_signal>
    AllowOverride all 
    #Require all granted 
    Options Indexes FollowSymlinks
         <Files wsgi.py>
             #Require all granted
         </Files>
     </Directory>

 </VirtualHost>

以及噪音的虚拟配置。server.com

<VirtualHost *:80>
    ServerAdmin hello@server.com
    ServerName noise.server.com
    ServerAlias noise.server.com
    DocumentRoot /var/www/html/d_signal/noise
    WSGIScriptAlias / /var/www/html/d_signal/d_signal/wsgi_noise.py
    WSGIDaemonProcess noise.server.com python-home=/var/www/html/d_signal/noise_env socket-user=apache
    WSGIProcessGroup noise.server.com

     Alias /static /var/www/html/d_signal/static
     <Directory /var/www/html/d_signal/sig/templates/sig/static>
         #Require all granted
     </Directory>

     <Directory /var/www/html/d_signal/noise>
    AllowOverride all 
    #Require all granted 
    Options Indexes FollowSymlinks
         <Files wsgi_noise.py>
             #Require all granted
         </Files>
     </Directory>

 </VirtualHost>

如果我访问 http://noise.server.com/noise/,那么我会进入我想查看的应用程序,但我宁愿只让 http://noise.server.com 工作。

我的配置是一个 Django 项目和两个应用程序。

我在这里错过了什么?

配置正确。原来我的问题出在我的设置文件中,它仍然将 noise.server.com 指向主应用程序。

仔细检查您的设置文件。