<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>ngrok - 标签 - 菠菜眾長</title><link>https://lruihao.cn/tags/ngrok/</link><description>ngrok - 标签 - 菠菜眾長</description><generator>Hugo -- gohugo.io</generator><language>zh-CN</language><managingEditor>1024@lruihao.cn (Lruihao)</managingEditor><webMaster>1024@lruihao.cn (Lruihao)</webMaster><lastBuildDate>Wed, 03 Apr 2019 19:29:43 +0000</lastBuildDate><atom:link href="https://lruihao.cn/tags/ngrok/" rel="self" type="application/rss+xml"/><item><title>本地搭建网站服务器并穿透内网</title><link>https://lruihao.cn/posts/ngrok/</link><pubDate>Wed, 03 Apr 2019 19:29:43 +0000</pubDate><author>Lruihao</author><guid>https://lruihao.cn/posts/ngrok/</guid><description><![CDATA[<blockquote>
<p>一直都想在自己电脑上搭建一个网站或者把自己的电脑做成服务器，今天终于简单实现了。还有很多知识需要学习，简单记录一下。</p>
</blockquote>
<h2 id="搭建环境">搭建环境</h2>
<p>我的电脑是<code>ubuntu+windows</code>双系统的，所以我先在 ubuntu 上面装了一个宝塔面板，方便通过 web 管理电脑，宝塔安装好后安装相关的环境<code>mysql,php,nginx</code>等。我们现在只能通过本地 ip<code>127.0.0.1:8888</code>访问面板。</p>
<h2 id="ngrok-穿透">ngrok 穿透</h2>
<p>去 ngrok 注册登录，购买隧道（有免费的），然后绑定端口，绑定域名，这里我们拿端口<code>8888</code>和域名<code>test.lruihao.cn</code>做实验，也就是宝塔面板的端口，这样我们就可以透过域名远程访问本地服务器，这样是不是开始有云服务器的感觉了。然后宝塔面板设置也绑定好域名<code>test.lruihao.cn</code>,dns 服务商那里做好相应的解析。<br>
然后在 ngrok 那里下载 sunny 客户端文件，我们是 ubuntu 选择<code>linux-64bits</code>版本。解压后在 ubuntu 打开终端进入 sunny 文件目录，权限给到 755，运行命令<code>./sunny clientid xxxxxxx</code> 后面的你的隧道订单的 id。</p>
<p>现在就可以通过互联网访问我的 ubuntu 服务器了。</p>
<h2 id="搭建网站">搭建网站</h2>
<p>前面两步搞定，搭建网站就没问题了。<br>
我们只要把网站的端口按第二步的在 ngrok 设置好就可以穿透了。</p>
<h2 id="注意">注意</h2>
<p>访问本地网站的必要条件是你的电脑得是开机状态而且有网络。</p>]]></description></item></channel></rss>