code-server安装使用

code-server是一款基于VSCode的在线编辑器,它提供了一个web话的在线IDE。

服务端上运行code-server(可以理解为一个在远程服务器上运行的VS Code),客户端就可以使用浏览器打开vscode,vscode上的资源都是服务器上的资源。通过code-server我们可以实现远程编辑调试服务器端的程序,相当于vscode的ssh remote。code-server和直接ssh remote的区别就后者还需要安装vscode软件,而前者连客户端软件都不需要安装。不过code-server也要自己的缺点,那就是网络环境不好的话可能会有些卡顿。

他的玩法也很简单:首先将code-server部署到远程服务器上,然后就可以通过浏览器打开网页版VSCode了。

官网:http://www.coder.com/
github:https://github.com/cdr/code-server

1、服务器安装code-server

#环境
$ cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core) 
 
cd /data/software
#github上的下载连接:https://github.com/cdr/code-server/releases,根据不同环境下载二进制解压即可使用。
wget https://github.com/cdr/code-server/releases/download/3.4.1/code-server-3.4.1-linux-x86_64.tar.gz
 
tar -xvzf code-server-3.4.1-linux-x86_64.tar.gz

2、启动

/data/software/code-server-3.4.1-linux-x86_64/bin

(1)直接“./code-server”启动发现不行.

浏览器输入"http://remoteip:8080"发现访问不了。怀疑这种方式启动智能在远程服务器的本地浏览器才能访问,无法在其他机器的浏览器访问。

(2)--help查看其他启动参数,如下。

./code-server -h
info  Using config file ~/.config/code-server/config.yaml
code-server 3.4.1 48f7c2724827e526eeaa6c2c151c520f48a61259

Usage: code-server [options] [path]

Options
      --auth                The type of authentication to use. [password, none]
      --password            The password for password authentication (can only be passed in via $PASSWORD or the config file).
      --cert                Path to certificate. Generated if no path is provided.
      --cert-key            Path to certificate key when using non-generated cert.
      --disable-telemetry   Disable telemetry.
   -h --help                Show this output.
      --open                Open in browser on startup. Does not work remotely.
      --bind-addr           Address to bind to in host:port. You can also use $PORT to override the port.
      --config              Path to yaml config file. Every flag maps directly to a key in the config file.
      --socket              Path to a socket (bind-addr will be ignored).
   -v --version             Display version information.
      --user-data-dir       Path to the user data directory.
      --extensions-dir      Path to the extensions directory.
      --list-extensions     List installed VS Code extensions.
      --force               Avoid prompts when installing VS Code extensions.
      --install-extension   Install or update a VS Code extension by id or vsix.
      --uninstall-extension Uninstall a VS Code extension by id.
      --show-versions       Show VS Code extension versions.
      --proxy-domain        Domain used for proxying ports.
 -vvv --verbose             Enable verbose logging.

 (3)于是使用如下方式启动:

#两者皆可
./code-server --bind-addr 0.0.0.0:8888
./code-server --port 8888 --host 0.0.0.0

3、本地浏览器访问

之后就可以在本地浏览器输入  http://9.134.XX.94:8888/ 访问了。首次访问的时候,需要输入登陆密码,这个登陆密码就在"~/.config/code-server/config.yaml"文件中,粘贴上去即可。

然后就可以像使用vscode一样使用了。

其他使用问题:

(1)code-server在使用上和vscode"一毛一样",而且目前的code-server也已经支持在线安装插件了(在线商店安装插件)。

注:如下是SSH remote玩法的一些点

(1)关于C++开发常用的插件工具大概如下:

(2)还需要安装 “clang” ,安装方法参见 这里

(3)关于错误提示。如果不行的话可以尝试下  这里 

(4)为了能让其跳转、提示,在每次启动的时候界面上方都是弹出一个类似于让你编译的选项(截图错过去了)。我这里选择了“/usr/bin/x86_64-redhat-linux-gcc -v”,然后 错误提示、跳转这些好像就都好了。点击选择后会在下方有如下“输出”。

猜你喜欢

转载自blog.csdn.net/mijichui2153/article/details/118880283
今日推荐