安装vscode Web版本 本文共有6542个字,关键词: 最简单的docker ```bash mkdir /usr/vs.config mkdir /usr/project docker run -itd --name codeserver -p 8080:8080 \ -p 9000-9100:9000-9100 \ -v "/usr/vs.config:/home/coder/.config" \ -v "/usr/project:/home/coder/project" \ -u "$(id -u):$(id -g)" \ -e "DOCKER_USER=$USER" \ -e PASSWORD=123456 \ --privileged \ mbaisha/code-server:latest ``` ```bash docker exec -it codeserver echo fs.inotify.max_user_watches = 524288 | sudo tee -a /etc/sysctl.conf docker exec -it codeserver sudo sysctl -p ``` ``` docker run -it --name codeserver -p 706:8080 \ -v "/data/vscode/.local:/root/.local" \ -v "/data/vscode/.config:/root/.config" \ -v "/data/vscode/src:/home/coder/project" \ -v "/opt/dotnet:/dotnet" \ -u "$(id -u):$(id -g)" \ -e "DOCKER_USER=$USER" \ codercom/code-server:latest #进容器 sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak sudo sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list sudo sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list sudo sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list sed -i "s@http://deb.debian.org@https://mirrors.163.com@g" /etc/apt/sources.list sed -i 's/security-cdn.debian.org/mirrors.aliyun.com' /etc/apt/sources.list ``` codercom/code-server ```bash docker pull codercom/code-server mkdir -p ~/vs.config docker run -it --name code-server -p 127.0.0.1:8080:8080 \ -v "$HOME/vs.config:/home/coder/.config" \ -v "$PWD:/home/coder/project" \ -u "$(id -u):$(id -g)" \ -e "DOCKER_USER=$USER" \ -e PASSWORD=123456 \ codercom/code-server:latest ``` 接下去安装node() ```bash wget https://nodejs.org/dist/v16.17.0/node-v16.17.0-linux-x64.tar.gz tar -xf node-v16.17.0-linux-x64.tar.gz docker cp node-v16.17.0-linux-x64 dockerId: /usr/local/node-v16.17.0 ``` 设置环境变量 ```bash docker cp dockerId:/etc/bash.bashrc $PWD #write export NODE_HOME=/usr/local/node-v16.17.0 export PATH=$NODE_HOME/bin:$PATH ``` ```bash npm config set registry http://registry.npm.taobao.org/ npm install yarn -g yarn config set registry https://registry.npm.taobao.org -g yarn config set sass_binary_site http://cdn.npm.taobao.org/dist/node-sass -g ``` ```bash rm -rf node_modules rm yarn.lock yarn install -std=c++17 ``` ```bash curl -fsSL https://code-server.dev/install.sh | sh, ``` 完成后修改~/.config/code-server/config.yaml, 再运行code-server命令,就可以开始在线写代码了。 为了安全,该用export PASSWORD="xxx"来配密码。 host 199.232.28.133 raw.githubusercontent.com nginx 代理 ```bash map $http_upgrade $connection_upgrade { default upgrade; '' close; } server { listen 80; server_name vscode.com; #ERROR-PAGE-START 错误页配置,可以注释、删除或修改 #error_page 404 /404.html; #error_page 502 /502.html; #ERROR-PAGE-END #PROXY-START location / { proxy_http_version 1.1; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Real-PORT $remote_port; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header Scheme $scheme; proxy_set_header Server-Protocol $server_protocol; proxy_set_header Server-Name $server_name; proxy_set_header Server-Addr $server_addr; proxy_set_header Server-Port $server_port; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; add_header Cache-Control no-store; proxy_pass http://127.0.0.1:5572/; } #PROXY-END #禁止访问的文件或目录 location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md) { return 404; } #access_log /www/wwwlogs/127.0.0.1.log; #error_log /www/wwwlogs/127.0.0.1.error.log; } ``` ------------ 以下内容在gitee同步 github加速: https://ghproxy.com/ ------------ 最低要求(官方) 启用了 WebSockets、1 GB RAM 和 2 个 vCPU 的 Linux 机器 有四种方法可以开始: 1. 使用[安装脚本](https://gitee.com/link?target=https%3A%2F%2Fgithub.com%2Fcoder%2Fcode-server%2Fblob%2Fmain%2Finstall.sh),它可以自动执行大部分过程。如果可能,该脚本会使用系统包管理器。 2. [手动安装代码服务器](https://gitee.com/link?target=https%3A%2F%2Fcoder.com%2Fdocs%2Fcode-server%2Flatest%2Finstall) 3. 使用[coder/coder](https://gitee.com/link?target=https%3A%2F%2Fcdr.co%2Fcoder-github)将代码服务器部署到您的团队 4. 使用我们的一键式按钮和指南将代码服务器部署到云提供商 如果您使用安装脚本,您可以预览安装过程中发生的情况: ``` curl -fsSL https://code-server.dev/install.sh | sh -s -- --dry-run ``` 要安装,请运行: ``` curl -fsSL https://code-server.dev/install.sh | sh ``` 完成后,安装脚本会打印出运行和启动代码服务器的说明。 你也可以使用Docker部署,我修改过的版本 添加了 -nodejs v16.17.0 -npm v8.15.0 -yarn v1.22.19 ``` docker pull mbaisha/code-server mkdir -p ~/.config docker run -itd --name code-server -p 8080:8080 \ -v "$HOME/.config:/home/coder/.config" \ -v "$PWD:/home/coder/project" \ -u "$(id -u):$(id -g)" \ -e "DOCKER_USER=$USER" \ -e PASSWORD=2022 \ --privileged \ mbaisha/code-server:latest ``` 端口在8080 密码2022 你也可以预留9000-9100端口 添加 -p 9000-9100:9000-9100 \ 或者使用codercom原版 [https://hub.docker.com/r/codercom/code-server](https://hub.docker.com/r/codercom/code-server) ``` docker pull codercom/code-server mkdir -p ~/.config docker run -it --name code-server -p 127.0.0.1:8080:8080 \ -v "$HOME/.config:/home/coder/.config" \ -v "$PWD:/home/coder/project" \ -u "$(id -u):$(id -g)" \ -e "DOCKER_USER=$USER" \ codercom/code-server:latest ``` 更方便: https://github.com/coder/code-server/releases 下载rpm包进行安装 可以使用 https://gh.api.99988866.xyz/ https://ghproxy.com/ 进行下载加速 sudo yum localinstall code-server*.rpm sudo systemctl enable code-server@$USER sudo vim ~/.config/code-server/config.yaml bind-addr:后跟着coder-server绑定的ip:端口号,注意默认是8080,可能会和tomcat冲突,自行修改 password:设置密码 *重启code-server sudo systemctl restart code-server@$USER 防火墙开放端口 firewall-cmd --zone=public --add-port=8080/tcp --permanent 安装git ```bash wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.9.5.tar.gz tar -zxvf git-2.*.tar.gz yum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel yum install -y gcc perl-ExtUtils-MakeMaker # 切换到git目录 cd git-2.9.5 创建要安装的目录 mkdir -p /usr/local/git 编译安装 make prefix=/usr/local/git all make prefix=/usr/local/git install # 添加环境变量 #vim /etc/profile VIM /etc/bashrc #添加以下配置 export PATH=$PATH:/usr/local/git/bin source /etc/bashrc ln -s /usr/local/git/bin/git /usr/bin/git git --version ``` 「一键投喂 软糖/蛋糕/布丁/牛奶/冰阔乐!」 赞赏 × 梦白沙 (๑>ڡ<)☆谢谢老板~ 1元 2元 5元 10元 50元 任意金额 2元 使用微信扫描二维码完成支付 版权声明:本文为作者原创,如需转载须联系作者本人同意,未经作者本人同意不得擅自转载。 随手发现 2022-08-29 评论 330 次浏览