平板上敲代码code-server

iruan / 2024-11-17 / 原文

1.linux服务器安装code-server

curl -fsSL https://code-server.dev/install.sh | sh

2.配置启动端口和密码

vim ~/.config/code-server/config.yaml

内容如下:
端口默认为8080,可自己更改,auth为password表示有密码,

bind-addr: 0.0.0.0:8080
auth: password
password: your_password
cert: false

3.启动

code-server

4.设置开机自启动(如果需要)

设置 code-server 作为服务
为了让 code-server 在系统启动时自动运行,你可以将它配置为一个系统服务。

(1)创建一个新的 systemd 服务文件:

sudo nano /etc/systemd/system/code-server.service
添加以下内容:

[Unit]
Description=code-server
After=nginx.service

[Service]
Type=simple
User=<your-username>
ExecStart=/usr/bin/code-server
Restart=always

[Install]
WantedBy=multi-user.target

替换为你的用户名root。

(2)启用并启动服务:

sudo systemctl enable code-server
sudo systemctl start code-server