開發(fā)環(huán)境
git push
服務(wù)器環(huán)境
git reset --hard HEAD //忽略服務(wù)器端修改
git pull
*常用命令
sudo service nginx restart
//重啟nginx服務(wù)
*tips
添加靜態(tài)文件jpg后政溃,本地開發(fā)環(huán)境可正常訪問,服務(wù)器端圖片加載失敯涨?解決方法:settings.py中需配置STATIC_URL和STATICFILES_DIRS,指定STATIC_ROOT路徑,
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'common_static'), #主文件下靜態(tài)文件
)
STATIC_ROOT = os.path.join(BASE_DIR, "static")
服務(wù)器端部署時(shí)運(yùn)行python manage.py collecstatic
將所有靜態(tài)文件收集到STATIC_ROOT 指定的路徑;
nginx配置文件中需指定靜態(tài)文件路徑棘脐,否則無法訪問(切記路徑名稱static也會(huì)拼接到root指定的路徑中去,請勿重復(fù)指定龙致,導(dǎo)致無法找到路徑。)
假設(shè)我要訪問的地址是:127.0.0.1/images/tmp.jpg
靜態(tài)資源地址是:/usr/local/static/images/tmp.jpg
http://www.reibang.com/p/87954346b7bb
//root配置
//127.0.0.1/images/tmp.jpg = /usr/local/static/images/tmp.jpg
location /images/ {
root /usr/local/static/
}
//alias配置
//127.0.0.1/images/tmp.jpg = /usr/local/static/images/tmp.jpg
location /images/ {
alias /usr/local/static/images/
}