我使用Apache和mod\wsgi一起为项目提供服务,它是静态文件。在
我使用了官方文档"How to use Django with Apache and mod_wsgi",除了没有找到静态文件外,一切正常。我没有找到任何好的方法来调试这个问题,甚至没有得到一条可以指出错误的特定消息。在
到目前为止我所做的:
设置.py:
[..]
DEBUG = False
STATIC_ROOT = '/var/www/djangoProject/static-files'
STATIC_URL = '/static/'
Apache设置:
^{pr2}$wsgi.py
import os, sys
sys.path.append('/var/www/djangoProject')
sys.path.append('/var/www/djangoProject/venv/lib/python2.7/site-packages')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "djangoProject.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
Apache访问日志:
"GET /static/app01/css/default.css HTTP/1.1" 404 346 "http://example.com/"
apache2.conf:
Mutex file:${APACHE_LOCK_DIR} default
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/
我找到了一个很好的答案“Serving static files with mod_wsgi and Django”。在
Apache设置:
相关问题 更多 >
编程相关推荐