1.docker 启动容器命令:
docker run --privileged -dit --restart=always --name vscode -h vscode -u root -p 18086:8080 -p 18087:80 -v /home/data/vscode:/root -e PASSWORD=123456 -v /etc/localtime:/etc/localtime:ro codercom/code-server:v2 --auth password
这里18086是访问code-server的,18087映射的是nginx默认配置的端口,--privileged是必须的.不然gdb会报 127 错误. 123456 是code-server的密码
2. 访问服务器的 18086端口 , 这时候应该可以进入到vscode的主页面了.点击
安装C++插件
按ctrl+shift+` 召唤出控制台 安装C C++ GDB 的环境
首先编辑 /ect/apt/sources.list添加如下内容:
deb http://mirrors.aliyun.com/ubuntu/ vivid main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ vivid-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ vivid-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ vivid-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ vivid-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ vivid main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ vivid-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ vivid-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ vivid-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ vivid-backports main restricted universe multiverse
然后执行: apt-get update
apt-get install -y build-essential
apt-get install -y gcc
apt-get install -y g++
apt-get install -y libpcre3 libpcre3-dev
apt-get install -y zlib1g-dev
apt-get install -y openssl libssl-dev
apt-get install -y gdb
把nginx的源码放入,启动docker映射的目录下/home/data/vscode ,开始编译nginx,在docker改目录会映射到 /root下
cd /root/nginx
chmod +x ./auto/configure
./auto/configure
make CFLAGS="-g -oO"
make install
修改nginx配置文件: /usr/local/nginx/conf/nginx.conf
添加如下配置:
daemon off;
master_process off;
在code-server页面中File->Open Folder打开nginx源码目录,在
选择 c++
创建 launch.json 文件
录入如下:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "nginx-gdb",
"type": "cppdbg",
"request": "launch",
"program": "/usr/local/nginx/sbin/nginx",
"args": ["-c","/usr/local/nginx/conf/nginx.conf"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"logging": { "engineLogging": true },
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
program args 是必须配置上的..就是刚才编译出来的nginx程序相关的启动和配置,然后 logging 推荐配置上,可以输出gdb的相关错误信息等等