Win10 支持将Ubuntu Linux承载在Windows系统中,将Ubuntu Linux作为Win10的子系统运行。
通过Ubuntu人性化的apt-get命令,只需几行代码就可以在Windows下面快速构建各种Linux应用。
1.开始
命令安装: lxrun /install /y
手动安装:windows bash
2. 构建应用
目前Windows Bash基于Ubuntu 16.04 LTS。
Ubuntu官方软件源速度不佳,首先将软件源更改为清华大学Ubuntu软件源:
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
Mysql
由于Windows Bash跟实际的Linux系统还是有所区别,下面展示一下安装Mysql的正确姿势。
参考了: BashOnWindows
#更新
sudo apt-get update
#跳过所有的提示,创建一个用户名为root,密码为空的用户
sudo DEBIAN_FRONTEND=noninteractive apt-get -y install mysql-server
#启动mysql服务
sudo service mysql start
#登录
mysql -u root
Redis
#安装
sudo apt-get install redis-server
#启动
redis-server --daemonize yes
rabbitmq
#安装
sudo apt-get install rabbitmq-server
#启动
service rabbitmq-server start
3.已知问题
不以守护线程运行的话关闭Windows Bash命名窗口,Mysql、Redis等服务也会随之关闭。