部署靜態文件:
靜態文件有兩種方式
1:通過django路由訪問
2:通過nginx直接訪問
方式1:
需要在根目錄的URL文件中增加 url(r'^$', TemplateView.as_view(template_name="index.html")),作為入口,在setting中更改靜態資源位置,
STATIC_URL = '/static/'STATICFILES_DIRS = (os.path.join(BASE_DIR, "dist/static"), # 靜態文件目錄位置
)
方式2:
配置nginx: cd /etc/nginx
首先在 nginx的可用配置目錄下新建我們的配置文件
cd sites-available/
vim mysite.confserver {listen 80;server_name iotplatform;charset utf-8;client_max_body_size 75M; location /static {alias /home/iot/IOTPlatform/dist/static;} location /media {alias /home/iot/media;} location / {root /home/iot/IOTPlatform/dist; index index.html;try_files $uri $uri/ /index.html;}
}