我最近在运行Ubuntu,Python 2.7.3,django.VERSION 1.5.1的EC2服务器上上传了我的应用程序。我成功地在没有任何CSS /图像或JS的情况下成功启动它。我可以查看模板并浏览它们意味着模板目录设置正在工作。 看起来我缺少静态/媒体文件的一些设置。 任何人都可以请指教?Django app on EC2 ubuntu静态文件问题
内容的 “猫/etc/apache2/httpd.conf”
WSGIScriptAlias//home/ubuntu/site/ProjectName/ProjectName/wsgi.py
WSGIPythonPath /home/ubuntu/site/ProjectName
<Directory /home/ubuntu/site/ProjectName/ProjectName>
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
内容settings.py
MEDIA_ROOT = '/var/www/media/'
MEDIA_URL = ''
STATIC_ROOT = ''
STATIC_URL = '/static/'
ADMIN_MEDIA_PREFIX = '/var/www/static/admin/'
STATICFILES_DIRS = (
'/var/www/static',
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
TEMPLATE_DIRS = ('/var/www/templates',)
**$ ls -ltr /var/www**
总共16
-rw-R-- r - 1 root root 177 Jul 26 20:21 index.html
drwxr-xr-x 3 www-data root 4096 Jul 28 04:20 static
drwxr-XR-×5 WWW的数据根4096年07月28个04:20媒体
drwxr-XR-×20 www数据根4096年07月28个16点29模板
在错误的apache2/access.log的
[29 /月/ 2013:13:41:36 -0500] “GET /static/neatadmin/css/bootstrap.css HTTP/1.1” 404 1798 [29 /月/ 2013:13:41: 36 -0500]“GET /static/neatadmin/css/jquery.fancybox.css HTTP/1.1”404 1806 [29/Jul/2013:13:41:36 -0500]“GET/static/neatadmin/js/jquery .js HTTP/1.1“404 1798 [29/Jul/2013:13:41:36 -0500]”GET /static/neatadmin/js/jquery.metadata.js H TTP/1.1“404 1804 [29/Jul/2013:13:41:36 -0500]”GET /static/neatadmin/css/login.css HTTP/1.1“404 1794 [29/Jul/2013:13: 41:36 -0500] “GET /static/neatadmin/js/error.js HTTP/1.1” 404 1794
在错误的Apache2/error.log中(我不认为这是相关的,但只是FYI)
[Mon Jul 29 13:41:29 2013] [error] /usr/local/lib/python2.7/dist-packages/django/conf/ init .py:221:DeprecationWarning:您没有定义过滤器'mail_admins'日志处理程序:添加隐式调试 - 仅错误过滤器。见http://docs.djangoproject.com/en/dev/releases/1.4/#request-exceptions-are-now-always-logged [Mon Jul 29 13:41:29 2013] [error] DeprecationWarning) [Mon Jul 29 13:41:29 2013] [error] [Mon Jul 29 13:41:35 2013] [error]/usr/local/lib/python2.7/dist-packages/django/conf/init .py:221:DeprecationWarning:在'mail_admins'日志处理程序中没有定义过滤器:添加隐式调试 - 仅限假过滤器。见http://docs.djangoproject.com/en/dev/releases/1.4/#request-exceptions-are-now-always-logged [周一07月29日13时41分35秒2013] [错误] DeprecationWarning) [周一07月29日13时41分35秒2013] [错误]
非常感谢Mark,我能够跟随文档,并能够通过更新httpd.conf –