2013-07-10 88 views
0

由于我采取了大量的步骤并没有任何帮助,因此我在这里完全失败。最奇怪的部分是,CSS是今天早些时候工作,我不知道我会做出什么大的改变。Django和Apache/mod_wsgi没有渲染css

这里是我到目前为止所采取的步骤:

$ sudo的乔敦 - R的WWW的数据LBOG /(LBOG是该项目的名称)

$ sudo的文件模式-R 777 LBOG /(变得有点沮丧,并用777去)在/ var/WWW

/LBOG /文件夹

$蟒蛇manage.py collectstatic

重新启动Apache的(过程中好几次)

开业在Firebug的页面,复制链接到CSS文件,而在另一个选项卡中打开该文件没有问题。所以路径应该是正确的。另外,正如我所提到的那样,css正在工作得更早。

这里是希望所有相关的配置文件。

/etc/apache2/sites-available中的lbog.conf。媒体的东西被有意识地注释掉了。 (也跑了 “$ a2ensite lbog.conf” 再次和反应是 “网站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 [email protected] 

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 – 

回答

1

呀没关系......在有一点我将STATIC_URL变量改为“example.com/static/”,而它只需要是“/ static /”。一切再次运作。希望至少有一些事情可以尝试,如果你的工作不...