在一台服务器上具有不同域的多个django项目

时间:2015-11-13 10:47:19

标签: django apache

我试图在同一台服务器上运行两个不同的django项目,有两个不同的域。 Django版本是1.8,网络服务器是Apache 2.4.7。 这些是我在站点中的conf文件:

#example.conf

<VirtualHost *:80>
  ServerName example.com
  ServerAlias example.com
  ServerAdmin admin@example.com

  WSGIDaemonProcess example.com python-path=/path/example/WebPortal:/path/example/venv/lib/python3.4/site-packages
  WSGIProcessGroup example.com
  WSGIPassAuthorization On
  WSGIScriptAlias / /path/example/WebPortal/WebPortal/wsgi.py
  WSGIApplicationGroup %{GLOBAL}

  <Directory /path/example/WebPortal/WebPortal>
  <Files wsgi.py>
  Require all granted
  </Files>
  </Directory>

  Alias /robots.txt /path/example/WebPortal/static/robots.txt
  Alias /favicon.ico /path/example/WebPortal/static/favicon.ico
  Alias /media/ /path/example/WebPortal/media/
  Alias /static/ /path/example/WebPortal/static/

  <Directory /path/example/WebPortal/static>
     Require all granted
     Options -Indexes
  </Directory>

 <Directory /path/example/WebPortal/media>
     Require all granted
     Options -Indexes
  </Directory>

  ErrorLog "/path/example/WebPortal/logs/webportal-error.log" 
  CustomLog "/path/example/WebPortal/logs/webportal-access.log" combined
  CustomLog "/path/example/WebPortal/logs/webportal-bandwidth.log" common

#sub.example2.conf

<VirtualHost *:80>
  ServerName sub.example2.com
  ServerAlias sub.example2.com
  ServerAdmin admin@example2.com

  WSGIDaemonProcess sub.example2.com python-path=/path/sub_example2/WebPortal:/path/sub_example2/venv/lib/python3.4/site-packages
  WSGIProcessGroup sub.example2.com
  WSGIPassAuthorization On
  WSGIScriptAlias / /path/sub_example2/WebPortal/WebPortal/wsgi.py
  WSGIApplicationGroup %{GLOBAL}

  <Directory /path/sub_example2/WebPortal/WebPortal>
  <Files wsgi.py>
  Require all granted
  </Files>
  </Directory>

  Alias /robots.txt /path/sub_example2/WebPortal/static/robots.txt
  Alias /favicon.ico /path/sub_example2/WebPortal/static/favicon.ico
  Alias /media/ /path/sub_example2/WebPortal/media/
  Alias /static/ /path/sub_example2/WebPortal/static/

  <Directory /path/sub_example2/WebPortal/static>
     Require all granted
     Options -Indexes
  </Directory>

 <Directory /path/sub_example2/WebPortal/media>
     Require all granted
     Options -Indexes
  </Directory>

  ErrorLog "/path/sub_example2/WebPortal/logs/webportal-error.log" 
  CustomLog "/path/sub_example2/WebPortal/logs/webportal-access.log" combined
  CustomLog "/path/sub_example2/WebPortal/logs/webportal-bandwidth.log" common

当我同时启用这两种配置时,只有一个域正常工作...另一个域我收到错误请求(400)。 我尝试了很多选择,但没有人工作。 有什么想法吗?

0 个答案:

没有答案
相关问题