【发布时间】:2019-08-26 13:04:31
【问题描述】:
我正在尝试从头开始部署网站变得更好,因此我使用最新的 Ubuntu(我认为是 19.04)从 Linode 设置了一个新的 Nanode。
我按照说明安装了 Mezzanine CMS(基于 Django),一切顺利,我能够在端口 8000 上运行开发服务器来测试网站。
我确实安装了 UFW,现在只有端口 80 上的活动没有被拒绝。我也有 mysql 数据库运行夹层而不是 Django 的默认 SQLlite。
我安装了 Apache 和 WSGI。起初 Apache 不会重新启动,因为我认为我已经解决了一些配置问题。
我有一个在 godaddy 上的域 alexmerced,但我有一个 DNS“a”记录指向我的 linodes IP 地址“mezz.alexmerced.com”
Mezzanine 仍然是全新安装,所以我没有真正更改 WSGI 和 settings.py 之外的任何内容。
我目前在输入 URL 或 IP 地址时出现禁止错误,应用程序目录的权限为 755。
以下是我的配置文件设置,看看我是否犯了任何错误。
django_project.conf(在 /sites-available/ 目录中启用的唯一 conf 文件
<VirtualHost *:80>
ServerName mezz.alexmerced.com
ServerAdmin mezzanine@localhost
DocumentRoot /mymezz
WSGIScriptAlias / /mymezz/mymezz/wsgi.py
Alias /static /mymezz/static/
<Directory /mymezz/>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
这里是 wsgi.py 文件
"""
WSGI config for mymezz project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
from mezzanine.utils.conf import real_project_name
os.environ.setdefault("DJANGO_SETTINGS_MODULE",
"%s.settings" % real_project_name("mymezz"))
application = get_wsgi_application()
我阅读的其他内容要求我将以下内容添加到我的 settings.py 中
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.join(PROJECT_ROOT, ".."))
settings_module = "%s.settings" % PROJECT_ROOT.split(os.sep)[-1]
os.environ["DJANGO_SETTINGS_MODULE"] = settings_module
和
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
【问题讨论】:
标签: django apache ubuntu wsgi mezzanine