简体   繁体   中英

Multiple subdomains with django

I'm trying to run two applications on a webserver with Django + Apache at signal.server.com and noise.server.com .

Currently both URLs point to singal.server.com

I've been changing options around to no avail. Here is my virtual host for the server.com which works fine

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>

virtual config for singal.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>

And the virtual config for noise.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>

If I visit http://noise.server.com/noise/ then I get to the app I want to see but I'd rather just have http://noise.server.com work.

My config is one Django project with two apps.

What am I missing here?

The configuration is correct. Turns out my issue was in my settings file which was still pointing the noise.server.com to the main app.

Double check your settings files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM