推荐使用较新的 Windows 版本,截止到最近一次更新,是 Windows 10 1803,里面带的 Ubuntu 是 16.04LTS
- 设置 -> 更新和安全 -> 针对开发人员 -> 开发人员模式
- 设置 -> 应用和功能 -> 程序和功能(右侧相关设置下)-> 启用或关闭 Windows 功能 -> 「适用于 Linux 的 Windows 子系统」
- 重启。开始,输入
bash
回车,按提示安装,新建用户,正常使用 Linux
sudo vim /etc/apt/source.list
sudo apt update
sudo apt upgrade
/etc/apt/source.list
需要更新的内容
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
# 源码
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
备份自己的 ~/.ssh/id_rsa
和 ~/.ssh/id_rsa.pub
,方便到处用
WSL 直接复制到 ~/.ssh/
下
Windows 复制到 %UserProfile%\.ssh\
下
sudo apt-get install python python-pip
mkdir ~/.pip
vim ~/.pip/pip.conf
sudo pip install --upgrade pip
sudo pip install virtualenv virtualenvwrapper
~/.pip/pip.conf
的内容
[global]
trusted-host = mirrors.aliyun.com
index-url = http://mirrors.aliyun.com/pypi/simple/
下载安装: https://www.python.org/downloads/windows/
配置源: %USERPROFILE%\pip\pip.ini
参考 https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions ,通过 apt-get
直接获取的 node 和 npm 版本太老
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
npm config set registry https://registry.npm.taobao.org
sudo npm install grunt-cli -g
直接下载安装 https://nodejs.org/en/#download
sudo apt-get install redis-server
sudo service redis-server start
sudo apt-get install mongodb
sudo service mongodb start
直接用 Ubuntu 默认源装的是比较老的版本,可以考虑按 MongoDB 官方说的方式走
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
https://yarnpkg.com/lang/en/docs/install/#debian-stable
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn
yarn config set registry https://registry.npm.taobao.org
https://www.docker.com/community-edition#/download
Settings -> Daemon 里在 Registry mirrors 加入 https://registry.docker-cn.com
Settings -> General 里把 Expose daemon on tcp://localhost:2375 without TLS
打开
参考 https://docs.docker.com/install/linux/docker-ce/ubuntu/ 卸载 apt 里的旧版本,添加源并获取新版本
修改 /etc/docker/daemon.json
{
"registry-mirrors": ["https://registry.docker-cn.com"]
}
在 ~/.bashrc
加入
export DOCKER_HOST="tcp://0.0.0.0:2375
相对好用的终端 http://cmder.net/
sudo apt-get install zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
让 cmder 默认启动 zsh
https://gingter.org/2016/11/16/running-windows-10-ubuntu-bash-in-cmder/
vim ~/.tmux.conf
tmux source ~/.tmux.conf
~/.tmux.conf
的内容
set-option -g default-shell /usr/bin/zsh
set -g default-terminal "screen-256color"
bind-key -n F8 new-window
bind-key -n F9 command-prompt 'rename-window %%'
bind-key -n F10 detach
bind-key -n F11 previous-window
bind-key -n F12 next-window
bind-key b send-prefix
set-window-option -g window-status-current-fg brightyellow
set -g status-right "#h %Y-%m-%d %H:%M"
详细参考 http://www.yewen.us/blog/2018/02/mount-disk-in-wsl/
sudo mkdir /c
sudo mount --bind /mnt/c /c
按 https://nickjanetakis.com/blog/setting-up-docker-for-windows-and-wsl-to-work-flawlessly 的提示来加到 ~/.bashrc 里或 ~/.zshrc 里,并把 /bin/mount 改成所有用户都可启用
echo "sudo mount --bind /mnt/c /c" >> ~/.bashrc && source ~/.bashrc
sudo echo "yourname ALL=(root) NOPASSWD: /bin/mount" >> /etc/sudoers
在 VS Code 的项目设置里加入
{
"python.pythonPath": "C:\\workspace\\ve\\proj\\Scripts\\python.exe",
"python.formatting.provider": "autopep8"
}
另 pylint 必须安装到虚拟环境下,VS Code 的一些补全什么的都依赖虚拟环境
需要依赖 C/C++ 库编译,直接去网站下载安装
参考 https://stackoverflow.com/a/11405769/1979585
从 http://www.voidspace.org.uk/python/pycrypto-2.6.1/ 下载对应的 .exe 文件后,在虚拟环境下用 easy_install xxx.exe
的方式安装
参考 https://stackoverflow.com/questions/29440482/how-to-install-lxml-on-windows
从 https://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml 下载对应的 .whl 文件后,在虚拟环境下用 pip install xxx.whl
的方式安装
使用 pipenv https://github.com/pypa/pipenv
- 直接用 macOS 的 monaco
- 使用雅黑加 Consolas 的结合体
- 真等宽的
微软雅黑改加宽等宽
https://1drv.ms/u/s!AiVBQ-4Gw6h6hcsVFH663ZlqpQDtiQ
Windows 防火墙加规则