Mezzanine--在DigitalOcean上使用apache啟動多站點/加入Domain

Posted by: bart30508 | in Mezzanine | 11 months ago |

#7 Issue closed: Mezzanine--在DigitalOcean上使用apache啟動多站點/加入Domain

Labels: Mezzanine

MaxwellBest opened issue at 2021-06-19 09:03:

這次的目標是要將Mezzanine使用apache啟動, 並且在同一個Domain中使用多站點: Site1 : maxchen.invest Site2 : maxchen.engineer


  1. 添加新的setting2.py 原本的setting.py SITE_ID = 1

setting2 SITE_ID = 2

  1. 添加新的wsgi2.py

其中加入指定的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())

```
  1. 修改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

  1. 完成 如此一來就設定完成了.

你就可以在你原本的domain加入/invest或/engineer就可以對應到不同的site了!

Note: 我在完成此步驟後, admin的css跑掉: 修改apache設定 (/etc/apache2/sitedenabled/000-default.conf) 加入 DocumentRoot /var/www/InvestBlog 之後在, 重啟apache後就好了.

ServerName是在購買Domain時必須加上去的.

image

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

Currently unrated
 or 

Subscribe

* indicates required

Recent Posts

Archive

2022
2021

Categories

Apache 1

Data Science 2

Dbfit 1

Design Pattern 1

Devops 3

DigitalOcean 1

Django 1

English 3

Excel 5

Flask 3

Git 1

HackMD 1

Heroku 1

Html/Css 1

Linux 4

Machine Learning 2

Manufacture 1

Mezzanine 18

Oracle 1

Postgresql 7

PowerBI 4

Powershell 4

Python 21

SEO 2

SQL Server 51

SQLite 1

Windows 1

database 8

work-experience 1

其他 1

自我成長 1

資料工程 1

Tags

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)

Authors

bart30508 (146)

Feeds

RSS / Atom

Mezzanine--在DigitalOcean上使用apache啟動多站點/加入Domain

© COPYRIGHT 2011-2022. Max的文藝復興. ALL RIGHT RESERVED.