【发布时间】:2015-11-20 08:27:58
【问题描述】:
尝试在 EC2 上的生产环境中访问我的 django 应用程序上的静态文件时收到 404 错误,尽管它在 Vbox 中的同一个 Bitnami 堆栈中上演,绝对没问题。我在httpd.conf 中的Alias 条目适用于robots.txt 和favicon.ico - 我可以正确访问它们。但是,我似乎无法使用 Alias 条目(即在所有页面上)访问 /static 中的任何特定内容。
我的 apache 日志中没有出现关于被服务器配置/等阻止的错误,并且我的 static 文件夹的权限(暂时)设置为 777,它没有帮助。我做错了什么?
我的 STATIC_ROOT 是 /opt/bitnami/apps/django/django_projects/data_dashboard/project/static
我的httpd.conf 文件如下所示:
<Directory /opt/bitnami/apps/django/django_projects/data_dashboard/project/project>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIScriptAlias / /opt/bitnami/apps/django/django_projects/data_dashboard/project/project/wsgi.py
<Directory "/opt/bitnami/apps/django/django_projects/data_dashboard/project/static">
Require all granted
</Directory>
Alias /static /opt/bitnami/apps/django/django_projects/data_dashboard/project/static
Alias /robots.txt /opt/bitnami/apps/django/django_projects/data_dashboard/project/static/robots.txt
Alias /favicon.ico /opt/bitnami/apps/django/django_projects/data_dashboard/project/static/favicon.ico
我的httpd-vhosts.conf:
<VirtualHost *:80>
ServerName ec2-xx-xx-xxx-xx.eu-west-1.compute.amazonaws.com
Include "/opt/bitnami/apps/django/django_projects/data_dashboard/project/conf/httpd-app.conf"
</VirtualHost>
<VirtualHost *:443>
ServerName ec2-xx-xx-xxx-xx.eu-west-1.compute.amazonaws.com
SSLEngine on
SSLCertificateFile "/opt/bitnami/apps/django/django_projects/data_dashboard/project/conf/certs/server.crt"
SSLCertificateKeyFile "/opt/bitnami/apps/django/django_projects/data_dashboard/project/conf/certs/server.key"
Include "/opt/bitnami/apps/django/django_projects/data_dashboard/project/conf/httpd-app.conf"
我的http-app.conf:
<IfDefine !IS_DJANGOSTACK_LOADED>
Define IS_DJANGOSTACK_LOADED
WSGIDaemonProcess wsgi-djangostack processes=2 threads=15 display-name=%{GROUP}
</IfDefine>
<Directory "/opt/bitnami/apps/django/django_projects/data_dashboard/project/project">
Options +MultiViews
AllowOverride All
<IfVersion < 2.3 >
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.3>
Require all granted
</IfVersion>
WSGIProcessGroup wsgi-djangostack
WSGIApplicationGroup %{GLOBAL}
<IfVersion < 2.3 >
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.3>
Require all granted
</IfVersion>
</Directory>
<Directory "/opt/bitnami/python/lib/python2.7/site-packages/django">
Options +MultiViews
AllowOverride All
<IfVersion < 2.3 >
Order allow,deny
Allow from all
</IfVersion>
<IfVersion >= 2.3>
Require all granted
</IfVersion>
</Directory>
【问题讨论】:
标签: python django apache amazon-ec2