2016-12-09 21 views
0

私はそこに提供されているすべてのソリューションを試しましたが、運はありませんでした。 'static'フォルダをルートに追加しました。 これはCentOS 6でGodaddyのVPSに転送した古いdjangoアプリです。 サーバ上に別の非pythonウェブサイトがあります。Djangoスラッシュを静的ファイルのURLに追加して404エラーを取得する

/etc/httpd/conf/httpd.conf 

<VirtualHost *:80> 

ServerName familyfn.com 
ServerAlias www.familyfn.com 

# Note: Whether or not django can write to a directory is controlled by filesys$ 

# Apache's internal directory auth has to give the vhost access to the wsgi.py $ 
<Directory /home/familysu/public_html/wsgi> 
     Options None 
     AllowOverride None 
     Order Deny,Allow 
     Allow from all 
</Directory> 

# Apache's internal directory auth has to give the vhost access to directories $ 
<Directory /home/familysu/public_html/code/mediafiles> 
     Options None 
     AllowOverride None 
     Order Deny,Allow 
     Allow from all 
</Directory> 
<Directory /home/familysu/public_html/code/staticfiles> 
     Options None 
     AllowOverride None 
     Order Deny,Allow 
     Allow from all 
</Directory> 
<Directory /home/familysu/public_html/code/breakdown/static> 
     Options None 
     AllowOverride None 
     Order Deny,Allow 
     Allow from all 
</Directory> 

# Use the following to restrict access during review. You'll need to generate t$ 
#<Location "/"> 
# AuthName "familysu Review" 
# AuthType Basic 
# Require valid-user 
# AuthUserFile /home/familysu/public_html/reviewusers.htpasswd 
#</Location> 

# mod_wsgi works with the Alias directive such that aliased files and directori$ 
Alias /media/ /home/familysu/public_html/code/mediafiles/ 
Alias /static/ /home/familysu/public_html/code/staticfiles/ 
Alias /robots.txt /home/familysu/public_html/code/breakdown/static/robots.txt 
Alias /favicon.ico /home/familysu/public_html/code/breakdown/static/favicon.ico 

WSGIDaemonProcess www.familyfn.com processes=2 threads=15 display-name=%{GROUP} 
WSGIProcessGroup www.familyfn.com 
# Note: wsgi.py is in its own folder so the above directory permissions will ap$ 
WSGIScriptAlias//home/familysu/public_html/wsgi/wsgi.py 

LogLevel warn 
ErrorLog /home/familysu/public_html/logs/error.log 
CustomLog /home/familysu/public_html/logs/access.log combined 
</VirtualHost> 

setting.py:

STATIC_ROOT = os.path.join(TOP_DIR, 'staticfiles') 
STATIC_URL = '/static/' 
STATICFILES_DIRS = [ 
    os.path.join(TOP_DIR, 'breakdown', 'static'), 
] 

Djangoのバージョン1.1.4。 Pythonのバージョン2.6

INSTALLED_APPS = (
    'django.contrib.admin', 
    'django.contrib.auth', 
    'django.contrib.contenttypes', 
    'django.contrib.humanize', 
    'django.contrib.sessions', 
    'django.contrib.sites', 
    'staticfiles', 
    'sky_redirects', 

    'cms', 
    'cms.plugins.text', 
    'cms.plugins.picture', 
    'cms.plugins.link', 
    'cms.plugins.file', 
    'cms.plugins.snippet', 
    'cms.plugins.googlemap', 
    'mptt', 
    'publisher', 

    'filebrowser', 

    'mainsite.articles', 
    'mainsite.zone_report', 
    'mainsite.pressroom', 
    'mainsite.downloads', 

) 

私は、このチェックしました:

python manage.py findstatic --verbosity 2 css/styles.css 

をし、それが正しいパスが見つかりました:

Found 'css/styles.css' here: 
    /home/familysu/public_html/code/breakdown/static/css/styles.css 

それが何らかの理由で各静的ファイルの末尾にスラッシュを追加しました: enter image description here

+0

http://.../static/css/styles.css?その結果、404になりますか? /home/familysu/public_html/code/staticfiles/css/styles.cssファイルは存在しますか? –

+1

待機、Django 1.1;少年、それは古いの? –

+1

あなたは緊急にDjangoのバージョンをアップグレードする必要があります。それは何年もサポートされておらず、完全に安全ではありません。 –

答えて

0

私はどのように静的fil 1.1で動作していました。しかし、あなたのApacheの設定では、この行間違っているようだ:私は、Djangoの1.1 STATIC_ROOTSTATIC_URLSTATICFILES_DIRSを持っていなかったと思う

Alias /static/ /home/familysu/public_html/ 

Alias /static/ /home/familysu/public_html/code/staticfiles/code/breakdown/static/ 

は、おそらくこれであるべき。

関連する問題