抱歉這個站台的網站之前如有出現不穩定的狀況
之前的因素為linux的系統日誌塞爆了硬碟
所以我把這些log清掉整理一下就可以正常顯示和登錄了

df -h
sudo du -h --max-depth=1 -x

find /var/log -type f | grep "alternatives"  | xargs rm
find /var/log -type f | grep "dpkg.log"  | xargs rm
find /var/log -type f | grep "php7.0-fpm.log"  | xargs rm
find /var/log -type f | grep "php7.2-fpm.log"  | xargs rm
find /var/log/nginx -type f | grep "access.log"  | xargs rm
find /var/log/nginx -type f | grep "error.log"  | xargs rm

用這些指令刪了12G的日誌檔

另外這次我重新部署這個站台並改寫程式原有的做法
改將所有作品整合到同一個domain並用nginx rewirte導向

2021/4/24 另外發現nginx rewirte 寫法錯誤,導致會無限導向
衍伸/var/log/nginx access.log會被快速塞爆的bug
起因為

location /herbs-laravel {
return 301 https://$host$request_uri/public;
}

錯誤的網址遇到這樣的寫法會讓laravel一直導向下一個public網址
例如
https://rubyworks.site/PunchRecord/pub/會導向至https://rubyworks.site/PunchRecord/pub/public
然後無限導向下去

後來改寫成這樣的就好了

location /herbs-laravel {
return 301 https://$host/herbs-laravel/public;
}

另外我也注意到了之前為了模擬定期爬打卡記錄的程式也會導致每分鐘更新/var/log/nginx access.log
目前因為沒有這個需求,所以先關閉
但是也讓我學習到了之後使用crontab時也要多注意這部分的log並寫定期刪除或備份log的程式以免同樣的事再發生

crontab -l

* * * * * php /var/www/PunchRecord/artisan schedule:run

最終結果

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *