简介
Windows Subsystem for Linux(简称 WSL)是一个在 Windows 10 上能够运行原生 Linux 二进制可执行文件(ELF 格式)的兼容层。有了 WSL 你就能在 Windows 下愉快的使用 Linux 了。
一、安装
1.1 管理员 Windows PowerShell 运行
右键 开始菜单 -> Windows PowerShell(管理员) ,执行命令:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
1.2 或者
控制面板 -> 程序和功能 -> 启用或关闭 Windows 功能 -> 勾选 适用于 Linux 的 Windows 子系统
![44e39d0413bc30aded5f7951bb81e29b.png](https://img-blog.csdnimg.cn/img_convert/44e39d0413bc30aded5f7951bb81e29b.png)
2 重启电脑
3 打开 应用商城
搜索 “Linux” ,选择安装一个或多个 Linux 系统,(如Ubuntu)
![f102cb5d193dba61618ce096170a88bb.png](https://img-blog.csdnimg.cn/img_convert/f102cb5d193dba61618ce096170a88bb.png)
4 初始化用户名和密码
开始菜单运行Ubuntu
Installing, this may take a few minutes...
过程略过...
Enter new UNIX username:(用户名)
New password:(密码)
Retype new password:(确认密码)
#设置ROOT密码
$ sudo passwd
二、快捷设置基础软件及配置
说明:因为在 Windows 系统启动后运行(WSL)Ubuntu,Ubuntu不会自动启动服务(大部分),所以需要手动开启所需服务(如 Php、Mysql、ssh 等),推荐使用 alias 管理启动。
GITHUB:
https://github.com/zoang/wsl-ubuntu
# 进入root 用户,执行下面命令即可:
wget -qO- https://raw.githubusercontent.com/zoang/wsl-ubuntu/master/download.sh -
本 Shell 操作有:设置时区,替换成阿里源,安装 PHP 及依赖,安装Composer,安装NPM,安装其他软件,并设置了一个快捷alias命令 wsl 来启动所需服务。
三、要点记录
NGINX 记录 *
1. 在 /etc/nginx/nginx.conf 文件 http {} 内加入下面代码(重要,解决未知Unix Socket BUG):
http{
#其他配置不用修改,下面必须加入,解决未知Unix Socket BUG
fastcgi_buffering off;
}
其他记录
1.Ubuntu 目录与 Windows 的映射
# C盘
/mnt/c
# D盘
/mnt/d
# 类推
2.host 说明
直接修改 Windows host 即可映射
# C:WindowsSystem32driversetchosts
127.0.0.1 larabbs.test
3. 默认主机
默认主机:127.0.0.1
适用 Xshell Mysql 连接
4. 重启 Windows 10 子系统(WSL) ubuntu
直接关闭窗口,或者 Windows PowerShell(管理员) ,执行命令:
#Windows PowerShell(管理员模式)
net stop LxssManager
net start LxssManager