vscode网页端搭建

前言

因为上课需要写代码,也不是同一个教室,也懒得带U盘拷贝

所以就搭建了网页的vscode 把代码都存到自己的服务器上面进行编程

其实vscode也有远程连接服务器的插件Remote - SSH,然后可以进行编程的。


主要是为了水文章!!!!!!!!!


没有自己的服务器或者懒的话就用现成的https://cloudstudio.net/


下载安装

https://github.com/coder/code-server/releases #可以来github获取最新版

1
2
3
➜  ~ wget https://github.com/coder/code-server/releases/download/v4.2.0/code-server-4.2.0-linux-amd64.tar.gz.  #下载软件包
➜ ~ tar -zxvf code-server-4.2.0-linux-amd64.tar.gz #解压
➜ ~ mv code-server-4.2.0-linux-amd64 vscode-web #改个名字
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
➜  ~ cd vscode-web
➜ vscode-web ./code-server --port 9999 --host 0.0.0.0 --auth password
***** Please use the script in bin/code-server instead!
***** This script will soon be removed!
***** See the release notes at https://github.com/coder/code-server/releases/tag/v3.4.0
[2022-03-27T10:28:59.524Z] info Wrote default config file to ~/.config/code-server/config.yaml
[2022-03-27T10:28:59.873Z] info code-server 4.2.0 693b1fac04524bb0e0cfbb93afc85702263329bb
[2022-03-27T10:28:59.874Z] info Using user-data-dir ~/.local/share/code-server
[2022-03-27T10:28:59.888Z] info Using config file ~/.config/code-server/config.yaml
[2022-03-27T10:28:59.888Z] info HTTP server listening on http://0.0.0.0:9999/
[2022-03-27T10:28:59.888Z] info - Authentication is enabled
[2022-03-27T10:28:59.888Z] info - Using password from ~/.config/code-server/config.yaml
[2022-03-27T10:28:59.888Z] info - Not serving HTTPS




–port 9999 指定端口,缺省时为 8080
–host 0.0.0.0 允许公网访问,缺省时为 127.0.0.1,只能本地访问
–auth password 指定访问密码,可通过 export 命令设置,参数为 none 时不启用密码

注意:记得在云服务器上面放行9999端口,不然访问不了。如果服务器还安装有宝塔面板的,记得也要在宝塔上面也放行9999端口

1
2
3
4
5
➜  vscode-web cat  ~/.config/code-server/config.yaml #密码所在的文件
bind-addr: 127.0.0.1:8080
auth: password
password: d47f8811331f9df42fd224b4. #登录网页版vscode用到的密码 可以进行修改
cert: false