程序员开发环境配置, WSL安装

329 阅读1分钟

1. 打开虚拟化功能。

打开控制面板 -> 点击程序与功能 -> 点击启动启动或关闭Windows功能 -> 勾选Hyper-V

image.png

2. 下载wsl

以管理员身份打开powershell或者cmd运行命令

wsl --install

安装linux发行版,这里我选择ubuntu

wsl --install -d Ubuntu

输入wsl --list查看安装的子系统

image.png

输入ubuntu即可进入ubuntu系统

3.安装oh my zsh

ubuntu中输入以下命令即可安装on my zsh

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

安装语法高亮插件zsh-syntax-highlighting

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

安装自动提示插件zsh-autosuggestions

git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

使用sudo nano ~/.zshrc打开配置文件, 加入如下配置,再保存即可。最后再source ~/.zshrc 让配置生效。

image.png

4.安装docker

先安装docker desktop官网下载即可

安装完后,打开docker desktop设置,勾选Expose daemon on tcp://localhost:2375 without TLS

image.png

打开ubuntu, 运行下列命令下载docker

sudo apt update
sudo apt install docker.io 
sudo usermod -aG docker $USER

下载完后,打开~/.zshrc配置文件,设置DOCKER_HOST的环境变量,保存,再source ~/.zshrc 使其生效。

image.png

需要docker desktop打开,输入docker run hello-world运行成功则环境配置成功了。

image.png