由於我採取了大量的步驟並沒有任何幫助,因此我在這裏完全失敗。最奇怪的部分是,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 –