[英]Django and Apache / mod_wsgi not rendering css
我在這里已經無所適從,因為我已經采取了很多步驟,但沒有任何幫助。 最奇怪的部分是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 –
是的,沒關系...在某些時候,我已將STATIC_URL變量更改為“ example.com/static/”,而只需將其設置為“ / static /”即可。 一切再次正常。 如果您的電腦不工作,希望至少有一些可以嘗試的事情...
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.