0

我在这里完全不知所措,因为我已经采取了很多步骤,但没有任何帮助。最奇怪的部分是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 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 –
4

1 回答 1

1

是的,没关系...在某些时候,我已将 STATIC_URL 变量更改为“example.com/static/”,而它只需要是“/static/”。一切都恢复正常。如果您的方法不起作用,希望至少有一份可以尝试的事情清单......

于 2013-07-10T22:55:48.147 回答