ubunu安装code-server: v4.14.1 在线VS Code开发工具

code-server是什么
Run VS Code on any machine anywhere and access it in the browser.
code-server 是一个可以在远程服务器上运行 VS Code 的工具。 通过浏览器访问,它可以让你: 在 Chromebook、平板电脑和笔记本电脑上都有一致的开发环境。

图片[1]-ubunu安装code-server: v4.14.1 在线VS Code开发工具-UU技术社区

项目地址:https://github.com/coder/code-server/

下载页面:https://github.com/coder/code-server/releases/

在线安装:

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

手动安装:

一般情况下由于网络原因在线安装会失败,就只能通过本地下载安装包,传到服务器,再手动安装

以ubuntu为例:

#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) ...
#安装完成

其他系统安装可查阅官方文档:https://coder.com/docs/code-server/latest/install

首次命令行输入code-server, 会生成一个本地配置文件,ctrl+C关闭,再去改配置文件:

vim ~/.config/code-server/config.yaml
===============
bind-addr: 0.0.0.0:8080 # 访问地址和端口默认127.0.0.1只能本机访问
auth: password
password: 123456 #访问密码
cert: false

完成配置后再次输入code-server命令启动

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

配置守护进程

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

然后就可以通过以下命令来启动和关闭code-server服务了

# start code-server
systemctl start code-server
# stop code-server
systemctl stop code-server
# code-server status
systemctl status code-server

设置中文

和VScode一样左下角齿轮—扩展搜索chinese安装即可

© Заявление об авторском праве
THE END
Поддерживай, если хочешь.
Похвалить19Высокая оценка Поделиться
Соответствующие рекомендации
Замечания Украсть диван
头像
Добро пожаловать, чтобы оставить ценные идеи!
提交
头像

Прозвище

取消
ПрозвищеЛицоКодФотографии

    Нет комментариев