Code-Server 安装部署教程, 可以在网页中使用的VSCode

本文介绍了Code-Server的安装与部署方法,包括通过脚本和GitHubrelease包,以及如何在Ubuntu环境中设置开机启动、配置文件管理和VSCode插件市场。详细步骤帮助开发者便捷地实现远程协作和自托管开发环境。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、Code-Server

        安装Code-Server的主要是为了远程协作更加方便,编译机和OA机之间通过远程桌面使用,会比较卡顿,而VSCode自身的ssh工具,使用起来总是不够顺手。直到遇到了由Coder开发的Code-Server, 基本可以和VSCode无缝切换,各种插件,主题基本都能直接使用,上手难度为0.

        本人编译机环境介绍:

[15:31:32 (48) jacob@jacob-hp code-server] $ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 20.04.6 LTS
Release:	20.04
Codename:	focal
[15:31:45 (49) jacob@jacob-hp code-server] $ uname -a
Linux jacob-hp 5.15.0-94-generic #104~20.04.1-Ubuntu SMP Tue Jan 16 13:34:09 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

二、安装与部署

        1、官网 

                (1)Coder官网: Coder | Cloud Development Environment: Remote & Self Hosted

                (2)Code-Server: Home - code-server Docs

        2、安装方式

                (1)使用脚本的方式进行安装

1、如果需要预览安装过程中会出现的异常,使用如下命令
    curl -fsSL https://code-server.dev/install.sh | sh -s -- --dry-run
2、如果不关注安装过程,使用如下命令:
    curl -fsSL https://code-server.dev/install.sh | sh
3、可以使用如下命令仅下载安装脚本,然后手动执行脚本进行安装:
    curl -fsSL https://code-server.dev/install.sh -o code-server-install.sh

该脚本有以下参数可以使用,根据需要修改即可:
--dry-run: echo the commands for the install process without running them.
--method: choose the installation method.
--method=detect: detect the package manager but fallback to --method=standalone.
--method=standalone: install a standalone release archive into ~/.local.
--prefix=/usr/local: install a standalone release archive system-wide.
--version=X.X.X: install version X.X.X instead of latest version.
--help: see usage docs.
--edge: install the latest edge version (i.e. pre-release)

                (2)直接下载github上的release包:
https://github.com/coder/code-server/releasesicon-default.png?t=N7T8https://github.com/coder/code-server/releases

export VERSION=4.23.1
curl -fOL https://github.com/coder/code-server/releases/download/v$VERSION/code-server_${VERSION}_amd64.deb
sudo dpkg -i code-server_${VERSION}_amd64.deb

        3、环境部署

                (1)执行如下命令,可以在开机的时候启动:

sudo systemctl enable --now code-server@$USER

                (2)修改配置文件, 配置文件路径:~/.config/code-server/config.yaml

                         bind-addr: 可以修改port为需要的port

                         auth: 可以指定为password或者none

                         password:如果auth为password, 需要设置password, 也支持Argon2加密的密码, 这两个二选一即可

bind-addr: 0.0.0.0:28080
auth: password
# password: 123456
hashed-password: $argon2i$v=19$m=16,t=2,p=2$eVYwb1VGMjRoQWNwNVpGMw$gjQJtCekg0w0JEoqqrrBmA
cert: false

                        Argon2在线加密:Argon2 Hash Generator, Validator & Verifier

                        以234567为明文加密:

                         (a)在Plain Text Input下面的框输入自己的密码

                         (b)点击Salt下方框里面的齿轮,会随机生成一串字符串, 其他信息根据自己需要修改

                         (c)点击最下方的'GENERATE HASH'的按钮,会生成两种不同格式的密文, 选择Encoded类型的密文copy到配置文件里面

                (3)在/usr/lib/code-server/lib/vscode/product.json里面加入如下内容, 可以使用VSCode的插件市场

  "extensionsGallery": {
    "serviceUrl": "https://marketplace.visualstudio.com/_apis/public/gallery",
    "cacheUrl": "https://vscode.blob.core.windows.net/gallery/index",
    "itemUrl": "https://marketplace.visualstudio.com/items",
    "controlUrl": "",
    "recommendationsUrl": ""
  }

        到此,部署完成,code-server还有其他参数,可以根据需要自行了解和配置

三、使用教程

        在任意浏览器输入部署code-server的机器的ip(在本机可以直接使用127.0.0.1)及对应的port, 然后会要求输入密码,密码校验之后就会进入欢迎页面,可以按照自己的喜好进行配置

Visual Studio Code (VSCode) Server是一种可以让VSCode在远程机器上运行并编辑代码的服务,它允许你在本地开发环境之外的地方访问代码。如果你想在Windows服务器上离线安装VSCode Server,你需要按照以下步骤操作: 1. **下载安装文件**:由于是离线安装,首先需要从VSCode官网下载适用于Windows的VSCode Server安装包。访问https://code.visualstudio.com/docs/setup/download-server,选择合适的版本(可能会有针对特定操作系统和架构的版本),然后保存到本地。 2. **部署到服务器**:将下载的`.zip`文件上传到Windows服务器,解压到你希望存放Server的位置,例如`C:\Program Files\Visual Studio Code Server`。 3. **配置启动命令**:创建一个批处理文件(如`code-server.cmd`)或者添加启动脚本到系统环境变量的路径中,以便通过命令行快速启动Server。例如,如果安装在默认位置,启动命令可能是类似这样的: ``` code-server --auth none --host 0.0.0.0 --port <your_port> ``` 其中`--auth none`表示无需身份验证,`--host 0.0.0.0`让Server监听所有网络接口,`--port`替换为实际使用的端口号。 4. **启动和管理**:使用服务器的默认命令或自定义的批处理文件启动Server,并根据需要管理其服务,比如设置开机启动、查看日志等。 注意:离线安装通常意味着没有自动更新功能,你需要手动检查是否有新的版本发布,并将其替换到服务器上。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值