1. 程式人生 > >搭建手機web伺服器-----內網穿透(無需Root)

搭建手機web伺服器-----內網穿透(無需Root)

# 搭建手機web伺服器-----內網穿透(無需Root) ## 一、內網穿透部分 ### 前言: * 網上內網穿透的方法很多,像花生殼、Ngrok、Frp等等,但是大多都需要獲取手機root許可權 * 本文使用的軟體是Termux(一款強大的安卓終端模擬器,無需root許可權) ### 1、下載安裝Termux **下載地址**:[https://termux.com/](https://termux.com/) **github地址**:[https://github.com/termux](https://github.com/termux) **注意事項:** * 手機安卓版本要與軟體版本對應,截至博文書寫時間,軟體最新版要求安卓7.0,如果是使用以前的老手機安卓版本較低的可以下載termux之前的比較低的版本,注意檢視軟體安卓的配置要求。 * 安裝完成,開啟termux,他會自動下載一些檔案,但是由於的伺服器在國外,所以需要vpn(怎麼FQ自己解決),否則開啟軟體會一直轉圈installing... * 博主termux版本0.73,安卓版本6.0 ### 2、在termux中安裝並解壓dnsutils工具包 安裝termux成功後會顯示: ![](https://gitee.com/STRSong/NoteImage/raw/master/img/20200608170050.png) ==**注意:歡迎介面有安裝其他工具包的使用方法,網上有說termux版本不同命令會不同,所以安裝的時候注意看歡迎介面的示例**== **安裝dnsutils工具包命令:** ``` pkg install dnsutils ``` ### 3.下載cpolar(ARM版本)並解壓 **下載命令**: ``` curl -O -L https://www.cpolar.com/static/downloads/cpolar-stable-linux-arm.zip ``` **下載完成後會有一個zip壓縮包** ![](https://gitee.com/STRSong/NoteImage/raw/master/img/20200608171703.png) **解壓命令:** ``` unzip cpolar-stable-linux-arm.zip ``` ### 4.註冊cpolar,獲取隧道authtoken **cpolar網址:**[https://www.cpolar.com/](https://www.cpolar.com/) ![](https://gitee.com/STRSong/NoteImage/raw/master/img/20200608172811.png) **登入後選擇套餐資訊(選免費的)** ![](https://gitee.com/STRSong/NoteImage/raw/master/img/20200608173001.png) **複製隧道:** ![](https://gitee.com/STRSong/NoteImage/raw/master/img/20200608173157.png) **將複製的隧道資訊命令複製到termux手機終端:** ``` ./cpolar authtoken xxxxxxxxxx ``` ### 5.內網穿透 * #### 對映本地8080埠到公網 ``` ./cpolar http 8080 ``` ![](https://gitee.com/STRSong/NoteImage/raw/master/img/20200608174848.png) * #### 外網遠端ssh控制 ``` ./cpolar tcp 22 ``` * #### 更多 請參閱cpolar官網的線上文件及使用教程案例。 線上文件:[https://www.cpolar.com/docs](https://link.zhihu.com/?target=https%3A//www.cpolar.com/docs) 教程案例:[https://www.cpolar.com/blog](https://link.zhihu.com/?target=https%3A//www.cpolar.com/blog) 本部分參考了知乎上的這篇文章:[如何在Android的Termux超級終端下安裝cpolar內網穿透工具](https://www.zhihu.com/tardis/sogou/art/66811824) ## 二、伺服器部分 ### 前言: * 安卓手機伺服器軟體也很多,像KSweb,Linux deploy等(都需要root) * 博主用的是HTTP Server powered by Apachev1.4.4安卓版(無需root) ### 1.下載安裝HTTP Server powered by Apache **下載地址:**[https://m.cr173.com/x/862337](https://m.cr173.com/x/862337) ![](https://gitee.com/STRSong/NoteImage/raw/master/img/20200608181112.png) 如果連結失效可以百度軟體名稱進行下載 ### 2.配置伺服器地址和埠 **具體操作見圖:** ![](https://gitee.com/STRSong/NoteImage/raw/master/img/20200608181428.png) ![](https://gitee.com/STRSong/NoteImage/raw/master/img/20200608181608.png) ### 3.伺服器資料目錄 ![](https://gitee.com/STRSong/NoteImage/raw/master/img/20200608183403.png) ![](https://gitee.com/STRSong/NoteImage/raw/master/img/20200608183431.png) ![](https://gitee.com/STRSong/NoteImage/raw/master/img/20200608183501.png) ### 4.啟動伺服器 * **同時啟動termux對映本地8080埠到公網** ![](https://gitee.com/STRSong/NoteImage/raw/master/img/20200608184742.png) * **啟動**HTTP Server powered by Apache ![](https://gitee.com/STRSong/NoteImage/raw/master/img/20200608184808.png) ### 效果如下: ![](https://gitee.com/STRSong/NoteImage/raw/master/img/20200608184453.png) ![](https://gitee.com/STRSong/NoteImage/raw/master/img/20200608184630.png) ![](https://gitee.com/STRSong/NoteImage/raw/master/img/20200608185006.png) ![](https://gitee.com/STRSong/NoteImage/raw/master/img/20200608185731.png) ## 三、總結 ### 優點: **==免費==、用於學習、測試等沒問題** ### 缺點: 1. 由於是免費的,隧道響應的網速滿 2. 如果需要部署java、php專案還得進行相應的環境配置 3. 等等....

但是免費就好了呀,其他又有什麼關心呢?

### 如果文章軟體連結失效可以關注我的公眾號,回覆“安卓web伺服器”即可獲取本文中的軟體

本文著作權及解釋權歸作者本人所有
如需轉載,請在文章顯眼出標識作者及原文出