Vagrant 可以配置本地開發環境(虛擬機),同時管理遠端主機(Digital Ocean),在一個專案目錄下、只用一個 Vagrantfile。
首先安裝外掛:
vagrant plugin install vagrant-digitalocean
#!/bin/bash | |
# install xcode command tool | |
xcode-select --install | |
# check | |
xcode-select -p | |
# install brew | |
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" |
Vagrant 可以配置本地開發環境(虛擬機),同時管理遠端主機(Digital Ocean),在一個專案目錄下、只用一個 Vagrantfile。
首先安裝外掛:
vagrant plugin install vagrant-digitalocean
if [ -f ~/.bashrc ]; then | |
source ~/.bashrc | |
fi | |
function git_branch { | |
ref=$(git symbolic-ref HEAD 2> /dev/null) || return; | |
echo "("${ref#refs/heads/}") "; | |
} | |
function git_since_last_commit { |
var http = require('http'), | |
fs = require('fs'); | |
function serveStaticFile(res, path, contentType, responseCode) { | |
if(!responseCode) responseCode = 200; | |
fs.readFile(__dirname + path, function(err, data){ | |
if(err) { | |
res.writeHead(500, {'Content-Type': 'text/plain'}); | |
res.end('500 - Internal Error'); | |
} else { |
Let's Encrypt client (Certbot
) 有兩種運行模式:
Webroot 模式比較好 因為不需要替換 Nginx 服務的 80 埠。
#!/bin/bash | |
echo "Update Homebrew" | |
echo "brew update && brew upgrade --all" | |
brew update && brew upgrade | |
echo "brew cleanup" | |
brew cleanup -s | |
echo "Update NPM global" |
_default
。package.json
。/Users/xxx/.nvm/versions/node/v10.15.3/lib
├── @vue/[email protected]
├── @vue/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
# dev | |
SECRET_KEY=4(hf^my1$a*dwf^78^x0zl-z)*)p&)40z#o307o*)p_x2ker^v | |
DEBUG=True | |
ALLOWED_HOSTS=.localhost,127.0.0.1 | |
# for PostgreSQL | |
# DATABASE_URL=postgres://dba:password@localhost:5432/db | |
# for Gmail | |
# EMAIL_BACKEND="django.core.mail.backends.console.EmailBackend" |
由 Linode 後台介面新增主機時,會要求設置 root 密碼,也可以增加 SSH Key、讓 root 能使用 SSH Key 無密碼登入,由於後面會關閉 root 的登入權限,因此選擇不設置金鑰。
ssh root@your_ip
以 root 身份登入乾淨的新創主機adduser new_user
建立例行登入使用的新用戶,設置密碼與必要資訊adduser new_user sudo
將新用戶加入 sudo 群組ssh-copy-id -i ~/.ssh/id_ed25519.pub new_user@your_ip
替新用戶增加公鑰ssh new_user@your_ip
確認新用戶能以金鑰模式登入無誤