我在这里完全失去了,因为我采取了大量的步骤,没有任何帮助。最奇怪的部分是css今天早些时候工作,我不知道我会在哪里做出重大改变。
以下是我目前采取的步骤:
冉
$ sudo chown -R www-data lbog /(lbog是项目的名称)
$ sudo chmod -R 777 lbog /(有点沮丧,跟777一起去)
www / lbog / folder 中的
跑
$ python manage.py collectstatic
重启Apache(在此过程中相当多次)
在Firebug中打开页面,将链接复制到css文件并在另一个选项卡中打开文件而没有任何问题。所以路径应该是正确的。另外,正如我所提到的,CSS已经提前运行了。
这里有希望所有相关的配置文件。
来自/ etc / apache2 / sites-available的lbog.conf。媒体的内容是故意评论出来的。 (还再次运行“$ a2ensite lbog.conf”,响应是“已启用Site lbog.conf”):
<VirtualHost *:80>
WSGIScriptAlias / /var/www/lbog/apache/django.wsgi
ServerName example.com #changed for the post
# ServerAlias www.example.com #changed for the post
# ServerAdmin webmaster@example.com
DocumentRoot /var/www/lbog
Alias /static /var/www/lbog/static/
# Alias /media /var/www/lbog/media/
# <Directory /var/www/lbog/media>
# Order allow,deny
# Allow from all
# </Directory>
<Directory /var/www/lbog>
Order allow,deny
Allow from all
</Directory>
<Directory /var/www/lbog/apache>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
django.wsgi(位于正确的目录中)
import os
import sys
sys.path.append('/var/www/lbog/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'lbog.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
和settings.py(希望所有相关位)
STATIC_ROOT = '/var/www/lbog/static/'
# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = 'example.com/static/' #changed for this post
# Additional locations of static files
STATICFILES_DIRS = (
('global', '/var/www/lbog/globalstatic/',),
('users', '/var/www/lbog/users/templates/static/'),
)
这让我很生气,所以如果有人能够提供帮助,我会非常感激。
哦,这是Apache的错误日志中的一个片段,它显示了一些东西(它显示了我在配置路径和模板时无法正确访问文件):
[Wed Jul 10 22:22:35 2013] [notice] caught SIGTERM, shutting down
[Wed Jul 10 22:23:20 2013] [notice] Apache/2.2.22 (Ubuntu) PHP/5.4.6-1ubuntu1.2 mod_wsgi/3.4 Python/2.7.3 configured -- resuming normal operations
[Wed Jul 10 22:25:10 2013] [notice] caught SIGTERM, shutting down
[Wed Jul 10 22:25:11 2013] [notice] Apache/2.2.22 (Ubuntu) PHP/5.4.6-1ubuntu1.2 mod_wsgi/3.4 Python/2.7.3 configured -- resuming normal operations –
答案 0 :(得分:1)
是的,没关系......在某些时候,我已经将STATIC_URL变量更改为“example.com/static/”,而它只需要是“/ static /”。一切都有效。希望如果你的工作不起作用,至少要列出一些事情......