昨天配置了亚马逊的EC2。通过了神圣完整的谷歌。没有运气,没有工作。我真的不知道下一步需要测试什么才能运行我的静态文件。
我共享我的本地工作系统Django配置:
settings.py
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'ui',
)
TEMPLATE_DIR = (
os.path.join(BASE_DIR, 'website/ui/templates/'),
)
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "website/ui/static"),
)现在的问题是,TEMPLATE_DIR运行良好。
index.html
{% load static from staticfiles %}
...
...
<img src="{% static 'images/logo.jpg' %}" width="100" height="100" />
...
...我在EC2上所做的特定配置是:
我遵循了这个博客的说明:在AWS上部署Django
现在,我的/etc/apache2/sites-enabled包含具有以下数据的test_site.com.conf:
WSGIScriptAlias / /home/ubuntu/v1/app-info/app/website/website/wsgi.py
WSGIPythonPath /home/ubuntu/v1/app-info/app/website
<Directory /home/ubuntu/v1/app-info/app/website/website/>
<Files wsgi.py>
Order deny,allow
Require all granted
</Files>
</Directory>
<Directory /home/ubuntu/v1/app-info/app/website/ui/static>
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log和IT只为静态文件提供 Page not found (404)
有人能指导如何解决这个问题吗?
发布于 2014-08-18 18:26:04
在做了这么多试验之后,我得出的结论是,主要问题在于APACHE配置。
用以下内容替换/etc/apache2/sites-enabled/test_site.com.conf内容解决了我的问题。
WSGIScriptAlias / /home/ubuntu/v1/website-info/app/website/website/wsgi.py
WSGIPythonPath /home/ubuntu/v1/website-info/app/website
<Directory /home/ubuntu/v1/website-info/app/website/website>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /static/ /home/ubuntu/v1/website-info/app/website/ui/static/
<Directory /home/ubuntu/v1/website-info/app/website/ui/static>
Require all granted
</Directory>
ErrorLog /var/log/apache2/error.loghttps://stackoverflow.com/questions/25368885
复制相似问题