This commit is contained in:
mozzie 2024-03-16 09:20:13 +08:00
parent 348992685d
commit 7b8193f09d
5 changed files with 33 additions and 5 deletions

File diff suppressed because one or more lines are too long

View File

@ -221,7 +221,7 @@
<!-- 文章标题 --> <!-- 文章标题 -->
<h1 class="post-title"></h1> <h1 class="post-title"></h1>
<div class="last-updated"> <div class="last-updated">
上次更新: 2024-03-16 08:51:46 上次更新: 2024-03-16 08:52:22
</div> </div>
<!-- 文章 --> <!-- 文章 -->
<h1 id="stdio-h"><a href="#stdio-h" class="headerlink" title="stdio.h"></a>stdio.h</h1><table> <h1 id="stdio-h"><a href="#stdio-h" class="headerlink" title="stdio.h"></a>stdio.h</h1><table>

View File

@ -266,7 +266,7 @@
<p><a target="_blank" rel="noopener" href="https://baidu.com/">https://baidu.com</a></p> <p><a target="_blank" rel="noopener" href="https://baidu.com/">https://baidu.com</a></p>
<p><a target="_blank" rel="noopener" href="http://www.this-anchor-link.com/">锚点链接</a> </p> <p><a target="_blank" rel="noopener" href="http://www.this-anchor-link.com/">锚点链接</a> </p>
<p><a href="mailto:test.test@gmail.com">mailto:test.test@gmail.com</a></p> <p><a href="mailto:test.test@gmail.com">mailto:test.test@gmail.com</a></p>
<p>GFM a-tail link <a target="_blank" rel="noopener" href="https://my.oschina.net/u/3691274">@pandao</a> 邮箱地址自动链接 <a href="mailto:&#116;&#101;&#115;&#116;&#x2e;&#116;&#x65;&#x73;&#116;&#x40;&#103;&#109;&#x61;&#x69;&#108;&#x2e;&#99;&#111;&#109;">&#116;&#101;&#115;&#116;&#x2e;&#116;&#x65;&#x73;&#116;&#x40;&#103;&#109;&#x61;&#x69;&#108;&#x2e;&#99;&#111;&#109;</a> <a href="mailto:&#x77;&#119;&#x77;&#64;&#118;&#105;&#112;&#46;&#113;&#113;&#46;&#99;&#x6f;&#109;">&#x77;&#119;&#x77;&#64;&#118;&#105;&#112;&#46;&#113;&#113;&#46;&#99;&#x6f;&#109;</a></p> <p>GFM a-tail link <a target="_blank" rel="noopener" href="https://my.oschina.net/u/3691274">@pandao</a> 邮箱地址自动链接 <a href="mailto:&#x74;&#101;&#x73;&#116;&#x2e;&#x74;&#101;&#115;&#116;&#64;&#103;&#x6d;&#97;&#x69;&#108;&#x2e;&#99;&#111;&#109;">&#x74;&#101;&#x73;&#116;&#x2e;&#x74;&#101;&#115;&#116;&#64;&#103;&#x6d;&#97;&#x69;&#108;&#x2e;&#99;&#111;&#109;</a> <a href="mailto:&#119;&#x77;&#119;&#x40;&#x76;&#105;&#x70;&#46;&#x71;&#113;&#46;&#x63;&#111;&#109;">&#119;&#x77;&#119;&#x40;&#x76;&#105;&#x70;&#46;&#x71;&#113;&#46;&#x63;&#111;&#109;</a></p>
<blockquote> <blockquote>
<p>@pandao</p> <p>@pandao</p>
</blockquote> </blockquote>

View File

@ -241,7 +241,7 @@
<!-- 文章标题 --> <!-- 文章标题 -->
<h1 class="post-title">wsl2</h1> <h1 class="post-title">wsl2</h1>
<div class="last-updated"> <div class="last-updated">
上次更新: 2024-03-15 23:14:48 上次更新: 2024-03-16 09:20:04
</div> </div>
<!-- 文章 --> <!-- 文章 -->
<h1 id="安装-wsl"><a href="#安装-wsl" class="headerlink" title="安装 wsl"></a>安装 wsl</h1><p>前置条件,主板 bios 开启 <code>intel 虚拟化</code></p> <h1 id="安装-wsl"><a href="#安装-wsl" class="headerlink" title="安装 wsl"></a>安装 wsl</h1><p>前置条件,主板 bios 开启 <code>intel 虚拟化</code></p>
@ -338,6 +338,19 @@ unstable -<span class="token operator">></span> N/A <span class="token punctuati
<pre class="line-numbers language-bash" data-language="bash"><code class="language-bash">nvm <span class="token function">install</span> <span class="token function">node</span> <pre class="line-numbers language-bash" data-language="bash"><code class="language-bash">nvm <span class="token function">install</span> <span class="token function">node</span>
<span class="token comment"># node -v | npm -v 验证安装版本</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span></span></code></pre> <span class="token comment"># node -v | npm -v 验证安装版本</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span></span></code></pre>
<h1 id="子系统使用宿主机代理"><a href="#子系统使用宿主机代理" class="headerlink" title="子系统使用宿主机代理"></a>子系统使用宿主机代理</h1><ol>
<li><p>clash为例勾选 <code>允许局域网</code> </p>
</li>
<li><p>wsl2 子系统 root 权限</p>
</li>
</ol>
<pre class="line-numbers language-bash" data-language="bash"><code class="language-bash"><span class="token builtin class-name">export</span> <span class="token assign-left variable">hostip</span><span class="token operator">=</span><span class="token variable"><span class="token variable">$(</span><span class="token function">cat</span> /etc/resolv.conf <span class="token operator">|</span><span class="token function">grep</span> <span class="token parameter variable">-oP</span> <span class="token string">'(?&lt;=nameserver\ ).*'</span><span class="token variable">)</span></span>
<span class="token builtin class-name">export</span> <span class="token assign-left variable">https_proxy</span><span class="token operator">=</span><span class="token string">"http://<span class="token variable">$&#123;hostip&#125;</span>:7890"</span>
<span class="token builtin class-name">export</span> <span class="token assign-left variable">http_proxy</span><span class="token operator">=</span><span class="token string">"http://<span class="token variable">$&#123;hostip&#125;</span>:7890"</span>
<span class="token comment"># 生效</span>
<span class="token comment"># source ~/.bashrc</span>
<span class="token comment"># source ~/.zshrc</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>
<h1 id="外网-LAN-访问-wsl2-服务"><a href="#外网-LAN-访问-wsl2-服务" class="headerlink" title="外网&#x2F;LAN 访问 wsl2 服务"></a>外网&#x2F;LAN 访问 wsl2 服务</h1><p><a target="_blank" rel="noopener" href="https://docs.microsoft.com/en-us/windows/wsl/networking">巨硬官方解释</a></p> <h1 id="外网-LAN-访问-wsl2-服务"><a href="#外网-LAN-访问-wsl2-服务" class="headerlink" title="外网&#x2F;LAN 访问 wsl2 服务"></a>外网&#x2F;LAN 访问 wsl2 服务</h1><p><a target="_blank" rel="noopener" href="https://docs.microsoft.com/en-us/windows/wsl/networking">巨硬官方解释</a></p>
<p>When using a WSL 1 distribution, if your computer was set up to be accessed by your LAN, then applications run in WSL could be accessed on your LAN as well.</p> <p>When using a WSL 1 distribution, if your computer was set up to be accessed by your LAN, then applications run in WSL could be accessed on your LAN as well.</p>
<p>This isnt the default case in WSL 2. WSL 2 has a virtualized ethernet adapter with its own unique IP address. Currently, to enable this workflow you will need to go through the same steps as you would for a regular virtual machine. (We are looking into ways to improve this experience.)</p> <p>This isnt the default case in WSL 2. WSL 2 has a virtualized ethernet adapter with its own unique IP address. Currently, to enable this workflow you will need to go through the same steps as you would for a regular virtual machine. (We are looking into ways to improve this experience.)</p>
@ -427,7 +440,7 @@ Ubuntu2004 config --default-user root<span aria-hidden="true" class="line-number
<span>目录</span> <span>目录</span>
</p> </p>
<!-- 文章toc --> <!-- 文章toc -->
<ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%AE%89%E8%A3%85-wsl"><span class="toc-number">1.</span> <span class="toc-text">安装 wsl</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#ubuntu%E8%BD%AF%E4%BB%B6%E6%BA%90"><span class="toc-number">2.</span> <span class="toc-text">ubuntu软件源</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%AE%89%E8%A3%85-zsh"><span class="toc-number">3.</span> <span class="toc-text">安装 zsh</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%AE%89%E8%A3%85-oh-my-zsh"><span class="toc-number">4.</span> <span class="toc-text">安装 oh-my-zsh</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE-oh-my-zsh-%E4%B8%BB%E9%A2%98-%E6%8F%92%E4%BB%B6-alias"><span class="toc-number">5.</span> <span class="toc-text">配置 oh-my-zsh 主题&#x2F;插件&#x2F;alias</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%AE%89%E8%A3%85-Nodejs"><span class="toc-number">6.</span> <span class="toc-text">安装 Nodejs</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%A4%96%E7%BD%91-LAN-%E8%AE%BF%E9%97%AE-wsl2-%E6%9C%8D%E5%8A%A1"><span class="toc-number">7.</span> <span class="toc-text">外网&#x2F;LAN 访问 wsl2 服务</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#netsh-%E7%AB%AF%E5%8F%A3%E6%98%A0%E5%B0%84"><span class="toc-number">7.1.</span> <span class="toc-text">netsh 端口映射</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE-windows-defender-%E9%98%B2%E7%81%AB%E5%A2%99%E5%85%A5%E7%AB%99%E8%A7%84%E5%88%99"><span class="toc-number">7.2.</span> <span class="toc-text">配置 windows defender 防火墙入站规则</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#docker"><span class="toc-number">8.</span> <span class="toc-text">docker</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#mysql-%E5%AE%B9%E5%99%A8"><span class="toc-number">8.1.</span> <span class="toc-text">mysql 容器</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#mongo-%E5%AE%B9%E5%99%A8"><span class="toc-number">8.2.</span> <span class="toc-text">mongo 容器</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E9%BB%98%E8%AE%A4-wsl-root-%E7%94%A8%E6%88%B7%E7%99%BB%E5%BD%95"><span class="toc-number">9.</span> <span class="toc-text">默认 wsl root 用户登录</span></a></li></ol> <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%AE%89%E8%A3%85-wsl"><span class="toc-number">1.</span> <span class="toc-text">安装 wsl</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#ubuntu%E8%BD%AF%E4%BB%B6%E6%BA%90"><span class="toc-number">2.</span> <span class="toc-text">ubuntu软件源</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%AE%89%E8%A3%85-zsh"><span class="toc-number">3.</span> <span class="toc-text">安装 zsh</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%AE%89%E8%A3%85-oh-my-zsh"><span class="toc-number">4.</span> <span class="toc-text">安装 oh-my-zsh</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE-oh-my-zsh-%E4%B8%BB%E9%A2%98-%E6%8F%92%E4%BB%B6-alias"><span class="toc-number">5.</span> <span class="toc-text">配置 oh-my-zsh 主题&#x2F;插件&#x2F;alias</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%AE%89%E8%A3%85-Nodejs"><span class="toc-number">6.</span> <span class="toc-text">安装 Nodejs</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%AD%90%E7%B3%BB%E7%BB%9F%E4%BD%BF%E7%94%A8%E5%AE%BF%E4%B8%BB%E6%9C%BA%E4%BB%A3%E7%90%86"><span class="toc-number">7.</span> <span class="toc-text">子系统使用宿主机代理</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%A4%96%E7%BD%91-LAN-%E8%AE%BF%E9%97%AE-wsl2-%E6%9C%8D%E5%8A%A1"><span class="toc-number">8.</span> <span class="toc-text">外网&#x2F;LAN 访问 wsl2 服务</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#netsh-%E7%AB%AF%E5%8F%A3%E6%98%A0%E5%B0%84"><span class="toc-number">8.1.</span> <span class="toc-text">netsh 端口映射</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E9%85%8D%E7%BD%AE-windows-defender-%E9%98%B2%E7%81%AB%E5%A2%99%E5%85%A5%E7%AB%99%E8%A7%84%E5%88%99"><span class="toc-number">8.2.</span> <span class="toc-text">配置 windows defender 防火墙入站规则</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#docker"><span class="toc-number">9.</span> <span class="toc-text">docker</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#mysql-%E5%AE%B9%E5%99%A8"><span class="toc-number">9.1.</span> <span class="toc-text">mysql 容器</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#mongo-%E5%AE%B9%E5%99%A8"><span class="toc-number">9.2.</span> <span class="toc-text">mongo 容器</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E9%BB%98%E8%AE%A4-wsl-root-%E7%94%A8%E6%88%B7%E7%99%BB%E5%BD%95"><span class="toc-number">10.</span> <span class="toc-text">默认 wsl root 用户登录</span></a></li></ol>
</div> </div>
</div> </div>
</cosy-drag-box> </cosy-drag-box>

View File

@ -138,6 +138,21 @@ nvm install node
# node -v | npm -v 验证安装版本 # node -v | npm -v 验证安装版本
``` ```
# 子系统使用宿主机代理
1. clash为例勾选 `允许局域网`
2. wsl2 子系统 root 权限
```bash
export hostip=$(cat /etc/resolv.conf |grep -oP '(?<=nameserver\ ).*')
export https_proxy="http://${hostip}:7890"
export http_proxy="http://${hostip}:7890"
# 生效
# source ~/.bashrc
# source ~/.zshrc
```
# 外网/LAN 访问 wsl2 服务 # 外网/LAN 访问 wsl2 服务
[巨硬官方解释](https://docs.microsoft.com/en-us/windows/wsl/networking) [巨硬官方解释](https://docs.microsoft.com/en-us/windows/wsl/networking)