我在这里已经无所适从,因为我已经采取了很多步骤,但没有任何帮助。最奇怪的部分是CSS今天早些时候在工作,我不知道在哪里进行大的更改。

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



$ sudo chown -R www-data lbog /(lbog是项目的名称)

$ sudo chmod -R 777 lbog /(有点沮丧并使用了777)

在/ var / www / lbog /文件夹中



$ python 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 –

最佳答案

是的,没关系...在某些时候,我已将STATIC_URL变量更改为“ example.com/static/”,而只需将其设置为“ / static /”即可。一切再次正常。希望至少有一些可以尝试的列表,如果您的列表不起作用...

08-04 03:07