寫過資料分析的人應該都對jupyter notebook不陌生
他是一種Web Service的編輯器
可以提供localhost 或 遠端固定ip 或 domain name連線
code-server專案 https://github.com/cdr/code-server/
就是在遠端Linux架設一個Web Service遠端vscode編輯器
你就算用ipad或chromebook 只要是有瀏覽器的設備
打開瀏覽器 就等同在遠端Linux編輯程式 不需安裝任何editor
code-server 有很多安裝方式 這邊聚焦在遠端Linux的安裝
- 首先先安裝tmux
# debian ubuntu
sudo apt install tmux
# Centos Fedora RedHat SUSE
sudo yum install tmux
安裝code-server 有很多方法
- Ubuntu Debian Centos Fedora RedHat SUSE 安裝或升級code-server
建議使用官方script 最簡單
curl -fsSL https://code-server.dev/install.sh | sh --method=detect
他會用apt install或yum install最新的deb或rpm
刪除也容易
sudo apt autoremove code-server
# or
sudo yum auoremove code-server
- 若沒有root權限 下載免安裝壓縮檔 解壓縮到你想要的路徑
https://github.com/cdr/code-server/releases 請自行找你要的OS壓縮檔 右鍵複製連結
# Donwload linux_x64
curl -O -L https://github.com/cdr/code-server/releases/download/v3.4.1/code-server-3.4.1-linux-amd64.tar.gz
解壓縮
tar -xvzf code-server-3.4.1-linux-amd64.tar.gz
改名 且 移動到你想要的任何路徑
mv code-server-3.4.1-linux-amd64 code-server
mv code-server ~/.local # 移動到~/.local當做例子
寫入環境變數 自行更改成你要的路徑
mkdir ~/.local/bin
ln -s ~/.local/code-server/bin/code-server ~/.local/bin/code-server
echo 'export PATH="~/.local/bin:$PATH"' >> ~/.bashrc# orecho 'export PATH="~/.local/bin:$PATH"' >> ~/.bash_profile
刪除
rm -rf ~/.local/code-server
- conda安裝
conda create -n codenv
conda activate codenv
conda install -c conda-forge code-server
刪除
conda deactivate
conda remove -n codenv --all
另外還有其他方法例如
npm yarn brew 安裝方式 就不一一贅述 請自行瀏覽 https://github.com/cdr/code-server/blob/master/doc/install.md
執行code-server
- 先用tmux 開一個名為codeserver的session
tmux new -s codeserver
- 執行code-server (0.0.0.0是指所有ip 可自行改port)
code-server --host=0.0.0.0 --port=8080 --cert
- Ctrl+b+d 跳出此tmux session
預設密碼在config.yaml裡面
vim ~/.config/code-server/config.yaml
預設會是
bind-addr: 127.0.0.1:8080 # 可自行改 例如 0.0.0.0:8081
auth: password
password: 7607c5ef0936e7eefbbd # 請改成你要的密碼
cert: false
- 打開瀏覽器使用你的固定ip 如:
輸入密碼
之後就可以使用囉
coder server當然也可以安裝vscode的外掛
外裝預設安裝路徑在~/.local/share/code-server/extensions
ls ~/.local/share/code-server/extensions
關掉Service
- 進入原tmux session
tmux ls
tmux attach -t codeserver
- Ctrl+c (關Service)
- 關閉tmux session
exit