Python AmazonEC2Django静态文件配置

Python AmazonEC2Django静态文件配置,python,django,apache,amazon-web-services,amazon-ec2,Python,Django,Apache,Amazon Web Services,Amazon Ec2,昨天配置了一个AmazonEC2。通过谷歌搜索。没有运气,没有工作。我真的不确定接下来需要测试什么才能让我的静态文件运行 我共享我的工作本地系统Django配置: 设置.py BASE_DIR = os.path.dirname(os.path.dirname(__file__)) INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes'

昨天配置了一个AmazonEC2。通过谷歌搜索。没有运气,没有工作。我真的不确定接下来需要测试什么才能让我的静态文件运行

我共享我的工作本地系统Django配置:

设置.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"),
)
现在问题是
模板\u DIR
工作正常

index.html

{% load static from staticfiles %}
...
...
<img src="{% static 'images/logo.jpg' %}" width="100" height="100" />
...
...
它为我提供了
未找到页面(404)
仅用于静态文件


有人可以指导如何修复它吗:|

好的,在做了这么多试验之后,我得出结论,主要问题在于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.log
WSGIScriptAlias//home/ubuntu/v1/website info/app/website/website/wsgi.py
WSGIPythonPath/home/ubuntu/v1/website info/app/website
要求所有授权
别名/static//home/ubuntu/v1/website info/app/website/ui/static/
要求所有授权
ErrorLog/var/log/apache2/error.log

这也适用于我。我必须添加别名行以指向我的静态目录。
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.log