【发布时间】:2016-07-24 05:27:58
【问题描述】:
我正在使用 Django 1.8 开发应用程序,我正在尝试接收子域,然后根据子域呈现自定义主页。例如:example.com 是我公司的主页,用户注册为 conqueryyor.example.com,他们会得到一个名为“conqueryor.example.com”或任何他们想要的新主页。
听起来很简单,甚至还有我正在使用的 django 子域库。我当前的问题在于在本地设置 Apache2 和 mod WSGI,以便我可以在影响项目中的其他人之前在本地对其进行测试。我目前可以在我的 /etc/hosts 文件中使用以下 .conf 文件,其中包含 127.0.0.1 example.dev 和 127.0.0.1 .example.dev 行。在我的浏览器中,我可以从 example.dev 访问我的应用程序,但是如果我尝试任何子域,我会收到“未找到服务器”页面。我也尝试使用 dnsmasq 并添加行 address=/.example.dev/127.0.0.1
当前环境: Ubuntu 15.10 Django 1.8.1 阿帕奇 2.4
<VirtualHost *:80>
ServerName example.dev
DocumentRoot /home/example
ServerAlias www.example.dev
WSGIDaemonProcess example python-path=/home/example:/home/venv/example/lib/python2.7/site-packages
WSGIProcessGroup example
WSGIScriptAlias / /home/example/saas/wsgi.py
<Directory /home/example/static>
Require all granted
</Directory>
<Directory /home/example/saas>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName example.dev
DocumentRoot /home/example
ServerAlias example.dev
WSGIDaemonProcess example2 python-path=/home/example:/home/venv/example/lib/python2.7/site-packages
WSGIProcessGroup example2
WSGIScriptAlias / /home/example/saas/wsgi.py
Alias /static/ /home/example/static/
<Directory /home/example/static>
Require all granted
</Directory>
<Directory /home/example/saas>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName example.dev
DocumentRoot /home/example
ServerAlias *.example.dev
WSGIDaemonProcess example3 python-path=/home/example:/home/venv/example/lib/python2.7/site-packages
WSGIProcessGroup example3
WSGIScriptAlias / /home/example/saas/wsgi.py
Alias /static/ /home/example/static/
<Directory /home/example/static>
Require all granted
</Directory>
<Directory /home/example/saas>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
谢谢!
【问题讨论】:
标签: django apache ubuntu mod-wsgi