安装 SSH 并开启外部访问
sudo apt install openssh-server
启动
sudo service ssh start
编辑配置文件
vim etc/ssh/sshd_config
找到 passwordAuthentication no 把 no 改为 yes
去掉注释并将 PermitRootLogin without-password 改为 PermitRootLogin yes
Windows 子系统 WSL 开机启动服务
Linux 中创建执行脚本
sudo vim /etc/init.wsl
编辑器编写保存并赋予权限
#! /bin/sh
/etc/init.d/ssh start
/etc/init.d/mysql start
/etc/init.d/php-fpm start
/etc/init.d/nginx start
sudo chmod +x /etc/init.wsl
在Windows中创建脚本 linux-start.vbs
Set ws = WScript.CreateObject("WScript.Shell")
ws.run "wsl -d ubuntu -u root /etc/init.wsl"
其中 ubuntu 修改为系统安装的 wsl 版本名称,查看方法 cmd 中 wsl -l
vbs 脚本保存后移动到Windows开机启动项
Win+R 输入 shell:startup
将 linux-start.vbs 文件 移动其中即可
WSL 下 Nginx PHP 访问严重卡慢
原因
用 Unix Socket 方式连接 Nginx 和 PHP,然而,WSL 对 Unix Socket 的支持不好
解决方法
在 nginx.conf 的 http 节点添加:
fastcgi_buffering off;
然后重启nginx