我正在从 Django 开发服务器切换到 Apache 进行生产。为此,我安装了modwsgi,并在apache2.conf中指定了以下内容。
# Run my django application.
WSGIScriptAlias / /home/david/registration/registration/wsgi.py
WSGIPythonPath /home/david/registration
<Directory /home/david/registration/registration>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
当我重新启动 Apache 时,我发现我的应用程序在我的浏览器中加载,但 CSS 或图像都没有。
以前,我一直用staticfiles
它来管理我的静态文件。我有这些设置。
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = '/home/david/static/'
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
静态文件过去可以工作,但现在不行了。为什么切换到 Apache 会阻止我的静态文件加载?