ubunu安裝code-server: v4.14.1 在線VS Code開(kāi)發(fā)工具
code-server是什么
Run VS Code on any machine anywhere and access it in the browser.
code-server 是一個(gè)可以在遠(yuǎn)程服務(wù)器上運(yùn)行 VS Code 的工具。 通過(guò)瀏覽器訪問(wèn),它可以讓你: 在 Chromebook、平板電腦和筆記本電腦上都有一致的開(kāi)發(fā)環(huán)境。

項(xiàng)目地址:https://github.com/coder/code-server/
下載頁(yè)面:https://github.com/coder/code-server/releases/
在線安裝:
curl -fsSL https://code-server.dev/install.sh | sh
手動(dòng)安裝:
一般情況下由于網(wǎng)絡(luò)原因在線安裝會(huì)失敗,就只能通過(guò)本地下載安裝包,傳到服務(wù)器,再手動(dòng)安裝
以u(píng)buntu為例:
#sudo dpkg -i code-server_4.14.1_amd64.deb
Selecting previously unselected package code-server.
(Reading database ... 160924 files and directories currently installed.)
Preparing to unpack code-server_4.14.1_amd64.deb ...
Unpacking code-server (4.14.1) ...
Setting up code-server (4.14.1) ...
#安裝完成
首次命令行輸入code-server
, 會(huì)生成一個(gè)本地配置文件,ctrl+C關(guān)閉,再去改配置文件:
vim ~/.config/code-server/config.yaml
===============
bind-addr: 0.0.0.0:8080 # 訪問(wèn)地址和端口默認(rèn)127.0.0.1只能本機(jī)訪問(wèn)
auth: password
password: 123456 #訪問(wèn)密碼
cert: false
完成配置后再次輸入code-server
命令啟動(dòng)
root@root:~/.config/code-server# code-server
[2023-07-11T09:13:02.103Z] info ?code-server 4.14.1 5c199629305a0b935b4388b7db549f77eae82b5a
[2023-07-11T09:13:02.104Z] info ?Using user-data-dir ~/.local/share/code-server
[2023-07-11T09:13:02.118Z] info ?Using config file ~/.config/code-server/config.yaml
[2023-07-11T09:13:02.118Z] info ?HTTP server listening on http://0.0.0.0:8088/
[2023-07-11T09:13:02.118Z] info ? ?- Authentication is enabled
[2023-07-11T09:13:02.118Z] info ? ? ?- Using password from ~/.config/code-server/config.yaml
[2023-07-11T09:13:02.118Z] info ? ?- Not serving HTTPS
[2023-07-11T09:13:02.118Z] info ?Session server listening on /root/.local/share/code-server/code-server-ipc.sock
配置守護(hù)進(jìn)程
vim /usr/lib/systemd/system/code-server.service
# 輸入以下配置
[Unit]
Description=code-server
After=network.target
[Service]
Type=exec
Environment=HOME=/root
ExecStart=/usr/bin/code-server
Restart=always
然后就可以通過(guò)以下命令來(lái)啟動(dòng)和關(guān)閉code-server服務(wù)了
# start code-server
systemctl start code-server
# stop code-server
systemctl stop code-server
# code-server status
systemctl status code-server
設(shè)置中文
和VScode一樣左下角齒輪—擴(kuò)展搜索chinese安裝即可
查看原文:https://www.cnuu.net/?p=853