closed
: Mezzanine--在DigitalOcean上使用apache啟動多站點/加入DomainLabels: Mezzanine
這次的目標是要將Mezzanine使用apache啟動, 並且在同一個Domain中使用多站點: Site1 : maxchen.invest Site2 : maxchen.engineer
setting2 SITE_ID = 2
其中加入指定的setting, 而此檔案稍後要在apache設定, 使指定的url對應指定的wsgi(2).py
```
import os
from django.core.wsgi import get_wsgi_application
from dj_static import Cling
from mezzanine.utils.conf import real_project_name
# os.environ.setdefault("DJANGO_SETTINGS_MODULE",
# "%s.settings2" % real_project_name("investblog"))
os.environ["DJANGO_SETTINGS_MODULE"] = "investblog.settings2"
# application = get_wsgi_application()
application = Cling(get_wsgi_application())
```
修改apache設定 (/etc/apache2/sitedenabled/000-default.conf) 在原本的設定中更改為以下:
WSGIDaemonProcess investblog python-path=/var/www/InvestBlog:/var/www/VENV/lib/python3.8/site-packages
WSGIProcessGroup investblog
WSGIScriptAlias /invest /var/www/InvestBlog/investblog/wsgi.py
WSGIScriptAlias /engineer /var/www/InvestBlog/investblog/wsgi2.py
也就是同一個Domain中
/invest => wsgi.py => setting.py /engineer => wsgi2.py => setting2.py
你就可以在你原本的domain加入/invest或/engineer就可以對應到不同的site了!
Note: 我在完成此步驟後, admin的css跑掉: 修改apache設定 (/etc/apache2/sitedenabled/000-default.conf) 加入
DocumentRoot /var/www/InvestBlog
之後在, 重啟apache後就好了.ServerName是在購買Domain時必須加上去的.
Reference:
https://stackoverflow.com/questions/9500598/apache-not-serving-django-admin-static-files https://docs.djangoproject.com/en/dev/ref/settings/#admin-media-prefix https://stackoverflow.com/questions/30474668/django-admin-css-missing-when-deployed-on-apache-with-mod-wsgi https://serverfault.com/questions/896340/how-do-i-configure-apache-to-work-with-multiple-django-apps/896345 https://codertw.com/%E4%BC%BA%E6%9C%8D%E5%99%A8/377669/ https://stackoverflow.com/questions/9483800/error-target-wsgi-script-not-found-or-unable-to-stat-when-run-django-on-apache
Share on Twitter Share on FacebookSQL Server Analytics Service 1
SEO(1) Github(2) Title Tag(2) ML(1) 李宏毅(1) SQL Server(18) Tempdb(1) SSMS(1) Windows(1) 自我成長(2) Excel(1) python Flask(1) python(5) Flask(2)
Max Chen (159)