settings.py中
----
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR,'static')
#STATIC_PATH = os.path.join(BASE_DIR, 'static')
#STATICFILES_DIRS = (
# os.path.join(BASE_DIR,'static'),
#)
uc_nginx.conf中
location /static {
alias /home/ubuntu/Mxonline/static; # 指向django的static目录
}
uwsgi.ini中
# mysite_uwsgi.ini file
[uwsgi]
# Django-related settings
# the base directory (full path)
chdir = /home/ubuntu/MxOnline
# Django's wsgi file
module = MxOnline.wsgi
# the virtualenv (full path)
# process-related settings
# master
master = true
# maximum number of worker processes
processes = 10
# the socket (use the full path to be safe
socket = 127.0.0.1:8000
# ... with appropriate permissions - may be needed
# chmod-socket = 664
# clear environment on exit
vacuum = true
virtualenv = /home/ubuntu/.virtualenvs/mxonline2
启动服务后,外网ip正常访问,但是无法加载css、image、js等静态文件。
直接访问css文件路径 ip/static/css/style.css,显示404错误。