<p style=""><a href="https://image.3001.net/images/20180501/15251875958364.png"><img src="https://image.3001.net/images/20180501/15251875958364.png" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20180501/15251875958364.png 1200w, https://image.3001.net/images/20180501/15251875958364.png 400w, https://image.3001.net/images/20180501/15251875958364.png 1600w, https://image.3001.net/images/20180501/15251875958364.png 800w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><p style="">Termux 高级终端安装使用配置教程,刚写这篇文章的时候,当时国内 Termux 相关的文章和资料相对来说还是比较少的,就花了几天写了这一篇文章,没想到居然火了,受宠若惊。所以这篇文章国光就打算定期更新了,想打造成 Termux 的中文文档,希望本文可以帮助到更多对 Termux 感兴趣的朋友,发挥 Android 平台更大的 DIY 空间。</p><h1 style="" id="%E7%89%88%E6%9D%83%E5%A3%B0%E6%98%8E"><strong>版权声明</strong></h1><p style="">17 年开始接触到 Termux,就发现它有很多值得挖掘的潜力,于是抽空在 18 年的某一个法定的整整花了三天假期开才写完第一版文章,然后文章陆陆续续更新到现在,期间有一次误操作不小心把博客所有的评论都删了,否则这篇文章的评论数会更多。现在本文的截图数量达到了 150 张左右了,文字数目已经数万多了。自己花了很长时间写出来的原创文章,抄袭白嫖党直接 Ctrl+C Ctrl+V 只要几秒钟。原创很辛苦,抄袭的成本却很低,维权的成本又很高,虽然国内目前的抄袭风气很严重,但是我相信尊重原创,保护原创从现在做起从大家做起,tomorrow is another day! 如果大面转载引用的话 希望标明文章出处:</p><p style=""><strong>Termux 高级终端安装使用配置教程</strong></p><p style=""><a href="https://www.sqlsec.com/2018/05/termux.html">https://www.sqlsec.com/2018/05/termux.html</a></p><h1 style="" id="%E5%AD%A6%E4%B9%A0%E8%B5%84%E6%BA%90"><strong>学习资源</strong></h1><p style="">考虑到手机用户体验和离线观看教程的需求,国光打包了几种风格的 PDF 版本,并且已经插入好目录,阅读体验会比较友好。</p><p style=""><strong>黑色背景的 PDF</strong> : <a href="https://sqlsec.lanzoux.com/ibuzvna" target="_blank" rel="noopener external nofollow noreferrer">Termux 入门指南(Vue 黑)</a></p><p style=""><strong>白色背景的 PDF</strong> : <a href="https://sqlsec.lanzoux.com/ibuztyj" target="_blank" rel="noopener external nofollow noreferrer">Termux 入门指南(Github 白)</a></p><p style=""><strong>macOS light 风格</strong> : <a href="https://sqlsec.lanzoux.com/ibuzuxe" target="_blank" rel="noopener external nofollow noreferrer">Termux 入门指南(macOS 白)</a></p><p style=""><strong>Gothic 风格</strong> : <a href="https://sqlsec.lanzoux.com/ibuztch" target="_blank" rel="noopener external nofollow noreferrer">Termux 入门指南(简约线条)</a></p><p style="">因为本文内容超级长,也包含了大量的图片,手机浏览起来难免会卡顿,而且如果你浏览比较拮据的话,还是建议看 PDF 版本的,国光还是比较建议有条件的同学使用 PC 端观看本文。</p><p style="">早期我的信息安全交流群里面陆陆续续加了很多 Temux 玩家,然而那是一个信息安全交流群,Termux 的提问经常没有人回答,所以后来我就把博客所有的加群链接给去了。现在国光我单独建立了 1 个 Temux 群,加群链接藏在本文当中,是一个<strong>彩蛋</strong>,缘妙不可言,随缘入群吧。好了话不多说,教程开始了,希望本文可以帮助到大家。</p><h1 style="" id="termux-%E7%AE%80%E4%BB%8B"><strong>Termux 简介</strong></h1><p style=""><strong>文档相关</strong></p><ul><li><p style=""><a href="https://termux.com/" target="_blank" rel="noopener external nofollow noreferrer">Termux 官网</a></p></li><li><p style=""><a href="https://github.com/termux/termux-app" target="_blank" rel="noopener external nofollow noreferrer">Github 项目地址</a></p></li><li><p style=""><a href="https://wiki.termux.com/wiki/Main_Page" target="_blank" rel="noopener external nofollow noreferrer">官方英文 WiKi 文档</a></p></li></ul><p style=""><strong>下载地址</strong></p><ul><li><p style=""><a href="https://f-droid.org/packages/com.termux/" target="_blank" rel="noopener external nofollow noreferrer">F-Droid 下载地址</a></p></li><li><p style=""><a href="https://play.google.com/store/apps/details?id=com.termux" target="_blank" rel="noopener external nofollow noreferrer">Google Play 下载地址</a></p></li><li><p style=""><a href="https://www.coolapk.com/apk/com.termux" target="_blank" rel="noopener external nofollow noreferrer">酷安 下载地址</a></p></li></ul><blockquote><p style="">F-Droid 市场版本下载的版本比 Google Play (貌似 1 年多没有更新了)下载的要新,而且插件这块安装也很方便,有能力的朋友建议首先考虑下载 F-Droid 版本的,然后考虑 Google Play 版本,最后再考虑酷安的版本。</p></blockquote><p style="">Termux 是一个 Android 下一个高级的终端模拟器,开源且不需要 root,支持 apt 管理软件包,十分方便安装软件包,完美支持 Python、 PHP、 Ruby、 Nodejs、 MySQL 等。随着智能设备的普及和性能的不断提升,如今的手机、平板等的硬件标准已达到了初级桌面计算机的硬件标准,用心去打造 DIY 的话完全可以把手机变成一个强大的极客工具。</p><p style=""><strong>初始化</strong></p><p style="">第一次启动 Termux 的时候需要从远程服务器加载数据,然而可能会遇到这种问题:</p><pre><code class="language-verilog">Ubable to install
Termux was unable to install the bootstrap packages.
Check your network connection and try again.</code></pre><p style="">这里的 Termux 官方远程的服务器地址是: <a href="http://termux.net/bootstrap/" target="_blank" rel="noopener external nofollow noreferrer">http://termux.net/bootstrap/</a></p><p style=""><a href="https://image.3001.net/images/20200418/15871943464391.png"><img src="https://image.3001.net/images/20200418/15871943464391.png" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20200418/15871943464391.png 400w, https://image.3001.net/images/20200418/15871943464391.png 800w, https://image.3001.net/images/20200418/15871943464391.png 1200w, https://image.3001.net/images/20200418/15871943464391.png 1600w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><p style="">目前解决方法有两种:</p><ol><li><p style="">VPN 全局代理 (成功率很高)</p></li><li><p style="">如果你是 WiFi 的话尝试切换到运营商流量 (有一定成功率)</p></li><li><p style="">① F-Droid > ② Google Play > ③ 酷安 根据这个顺序尝试安装,如果不行再重复 1、2 步骤操作</p></li></ol><h1 style="" id="%E5%9F%BA%E6%9C%AC%E6%93%8D%E4%BD%9C"><strong>基本操作</strong></h1><p style="">基本操作还是要学习一下的,可以事半功倍。</p><h2 style="" id="%E7%BC%A9%E6%94%BE%E6%96%87%E6%9C%AC"><strong>缩放文本</strong></h2><p style="">可以使用缩放手势来调整其字体大小。 对就是 「双指放大缩小」照片那样操作。</p><p style=""><a href="https://image.3001.net/images/20200418/15872024914185.png"><img src="https://image.3001.net/images/20200418/15872024914185.png" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20200418/15872024914185.png 400w, https://image.3001.net/images/20200418/15872024914185.png 800w, https://image.3001.net/images/20200418/15872024914185.png 1200w, https://image.3001.net/images/20200418/15872024914185.png 1600w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><h2 style="" id="%E9%95%BF%E6%8C%89%E5%B1%8F%E5%B9%95"><strong>长按屏幕</strong></h2><p style="">长按屏幕会调出显示菜单项(包括复制、粘贴、更多),方便我们进行复制或者粘贴:</p><p style=""><a href="https://image.3001.net/images/20200418/15872022768181.png"><img src="https://image.3001.net/images/20200418/15872022768181.png" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20200418/15872022768181.png 800w, https://image.3001.net/images/20200418/15872022768181.png 1600w, https://image.3001.net/images/20200418/15872022768181.png 400w, https://image.3001.net/images/20200418/15872022768181.png 1200w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><p style=""><code>More</code> 菜单的说明如下:</p><pre><code class="language-bash">长按屏幕
├── COPY: # 复制
├── PASTE: # 粘贴
├── More: # 更多
├── Select URL: # 提取屏幕所有网址
└── Share transcipt: # 分享命令脚本
└── Reset: # 重置
└── Kill process: # 杀掉当前会话进程
└── Style: # 风格配色 需要自行安装
└── Keep screen on: # 保持屏幕常亮
└── Help: # 帮助文档</code></pre><h2 style="" id="%E4%BC%9A%E8%AF%9D%E7%AE%A1%E7%90%86"><strong>会话管理</strong></h2><p style="">显示隐藏式导航栏,可以新建、切换、重命名会话 session 和调用弹出输入法:</p><p style=""><a href="https://image.3001.net/images/20200418/15872022029549.png"><img src="https://image.3001.net/images/20200418/15872022029549.png" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20200418/15872022029549.png 400w, https://image.3001.net/images/20200418/15872022029549.png 1200w, https://image.3001.net/images/20200418/15872022029549.png 1600w, https://image.3001.net/images/20200418/15872022029549.png 800w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><p style="">同时在 Android 的通知栏中也可以看到当前 Termux 运行的会话数:</p><p style=""><a href="https://image.3001.net/images/20200418/15872026639062.png"><img src="https://image.3001.net/images/20200418/15872026639062.png" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20200418/15872026639062.png 400w, https://image.3001.net/images/20200418/15872026639062.png 800w, https://image.3001.net/images/20200418/15872026639062.png 1200w, https://image.3001.net/images/20200418/15872026639062.png 1600w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><h2 style="" id="%E5%B8%B8%E7%94%A8%E6%8C%89%E9%94%AE"><strong>常用按键</strong></h2><p style="">常用键是 PC 端常用的按键如: ESC 键、Tab 键、CTR 键、ALT 键,有了这些按键后可以提高我们日常操作的效率,所以 Termux 后面的版本默认都是显示这个扩展功能按键的。 (18 年的时候默认是不显示的):</p><p style=""><a href="https://image.3001.net/images/20200418/15872018464605.png"><img src="https://image.3001.net/images/20200418/15872018464605.png" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20200418/15872018464605.png 800w, https://image.3001.net/images/20200418/15872018464605.png 400w, https://image.3001.net/images/20200418/15872018464605.png 1600w, https://image.3001.net/images/20200418/15872018464605.png 1200w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><p style="">打开和隐藏这个扩展功能按键目前有下面两种方法:</p><p style=""><strong>方法一</strong></p><p style="">从左向右滑动,显示隐藏式导航栏,长按左下角的 <code>KEYBOARD</code></p><p style=""><strong>方法二</strong></p><p style="">使用 <code>Termux</code> 快捷键: <code>音量+</code>+<code>Q</code> 键 或者 <code>音量+</code>+<code>K</code> 键</p><p style="">当然这个常用按键在 Termux 后面的版本也支持自定义的,详情见本文的「进阶配置」-「定制常用按键」这一小节。</p><h1 style="" id="%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86"><strong>基础知识</strong></h1><p style="">这些基础知识简单了解一下就可以了,Linux 用的多了就会慢慢熟悉理解了。</p><h2 style="" id="%E5%BF%AB%E6%8D%B7%E9%94%AE%E8%A1%A8"><strong>快捷键表</strong></h2><p style=""><code>Ctrl</code> 键是终端用户常用的按键,但大多数触摸键盘都没有这个按键,因此 Termux 使用<code>音量减小按钮</code>来模拟 <code>Ctrl</code> 键。<br>例如,在触摸键盘上按<code>音量减小</code> + <code>L</code> 就相当于是键盘上按 <code>Ctrl + L</code> 的效果一样,达到清屏的效果。</p><ul><li><p style=""><code>Ctrl + A</code> -> 将光标移动到行首</p></li><li><p style=""><code>Ctrl + C</code> -> 中止当前进程</p></li><li><p style=""><code>Ctrl + D</code> -> 注销终端会话</p></li><li><p style=""><code>Ctrl + E</code> -> 将光标移动到行尾</p></li><li><p style=""><code>Ctrl + K</code> -> 从光标删除到行尾</p></li><li><p style=""><code>Ctrl + U</code> -> 从光标删除到行首</p></li><li><p style=""><code>Ctrl + L</code> -> 清除终端</p></li><li><p style=""><code>Ctrl + Z</code> -> 挂起(发送 SIGTSTP 到)当前进程</p></li><li><p style=""><code>Ctrl + alt + C</code> -> 打开新会话(仅适用于 黑客键盘)</p></li></ul><p style=""><code>音量加键</code>也可以作为产生特定输入的<code>特殊键</code>.</p><ul><li><p style=""><code>音量加 + E</code> -> Esc 键</p></li><li><p style=""><code>音量加 + T</code> -> Tab 键</p></li><li><p style=""><code>音量加 + 1</code> -> F1(<code>音量增加 + 2</code> → F2… 以此类推)</p></li><li><p style=""><code>音量加 + 0</code> -> F10</p></li><li><p style=""><code>音量加 + B</code> -> Alt + B,使用 readline 时返回一个单词</p></li><li><p style=""><code>音量加 + F</code> -> Alt + F,使用 readline 时转发一个单词</p></li><li><p style=""><code>音量加 + X</code> -> Alt+X</p></li><li><p style=""><code>音量加 + W</code> -> 向上箭头键</p></li><li><p style=""><code>音量加 + A</code> -> 向左箭头键</p></li><li><p style=""><code>音量加 + S</code> -> 向下箭头键</p></li><li><p style=""><code>音量加 + D</code> -> 向右箭头键</p></li><li><p style=""><code>音量加 + L</code> -> | (管道字符)</p></li><li><p style=""><code>音量加 + H</code> -> 〜(波浪号字符)</p></li><li><p style=""><code>音量加 + U</code> -> _ (下划线字符)</p></li><li><p style=""><code>音量加 + P</code> -> 上一页</p></li><li><p style=""><code>音量加 + N</code> -> 下一页</p></li><li><p style=""><code>音量加 + .</code> -> Ctrl + \(SIGQUIT)</p></li><li><p style=""><code>音量加 + V</code> -> 显示音量控制</p></li><li><p style=""><code>音量加 + Q</code> -> 切换显示的功能键视</p></li><li><p style=""><code>音量加 + K</code> -> 切换显示的功能键视图</p></li></ul><p style="">快捷键用的熟悉的话也可以极大提高操作的效率。</p><h2 style="" id="%E5%9F%BA%E6%9C%AC%E5%91%BD%E4%BB%A4"><strong>基本命令</strong></h2><p style="">Termux 除了支持 <code>apt</code> 命令外,还在此基础上封装了 <code>pkg</code> 命令,<code>pkg</code> 命令向下兼容 <code>apt</code> 命令。<code>apt</code> 命令大家应该都比较熟悉了,这里直接简单的介绍下 <code>pkg</code> 命令:</p><pre><code class="language-bash">pkg search <query> # 搜索包
pkg install <package> # 安装包
pkg uninstall <package> # 卸载包
pkg reinstall <package> # 重新安装包
pkg update # 更新源
pkg upgrade # 升级软件包
pkg list-all # 列出可供安装的所有包
pkg list-installed # 列出已经安装的包
pkg show <package> # 显示某个包的详细信息
pkg files <package> # 显示某个包的相关文件夹路径</code></pre><blockquote><p style="">国光建议大家使用 pkg 命令,因为 pkg 命令每次安装的时候自动执行 apt update 命令,还是比较方便的。</p></blockquote><h2 style="" id="%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85"><strong>软件安装</strong></h2><p style="">除了通过上述的 <code>pkg</code> 命令安装软件以外,如果我们有 <code>.deb</code> 软件包文件,也可以使用 <code>dpkg</code> 进行安装。</p><pre><code class="language-bash">dpkg -i ./package.de # 安装 deb 包
dpkg --remove [package name] # 卸载软件包
dpkg -l # 查看已安装的包
man dpkg # 查看详细文档</code></pre><h2 style="" id="%E7%9B%AE%E5%BD%95%E7%BB%93%E6%9E%84"><strong>目录结构</strong></h2><pre><code class="language-bash">echo $HOME
/data/data/com.termux/files/home
echo $PREFIX
/data/data/com.termux/files/usr
echo $TMPPREFIX
/data/data/com.termux/files/usr/tmp/zsh</code></pre><p style="">长期使用 Linux 的朋友可能会发现,这个 HOME 路径看上去和我们电脑端的不太一样,这是为了方便 Termux 提供的特殊的环境变量。</p><p style=""><a href="https://image.3001.net/images/20180502/15252398558622.png"><img src="https://image.3001.net/images/20180502/15252398558622.png" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20180502/15252398558622.png 800w, https://image.3001.net/images/20180502/15252398558622.png 400w, https://image.3001.net/images/20180502/15252398558622.png 1200w, https://image.3001.net/images/20180502/15252398558622.png 1600w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><h2 style="" id="%E7%AB%AF%E5%8F%A3%E6%9F%A5%E7%9C%8B"><strong>端口查看</strong></h2><h3 style="" id="android-10-%E4%BB%A5%E4%B8%8B%E7%89%88%E6%9C%AC"><strong>Android 10 以下版本</strong></h3><p style="">Andorid 10 以下的版本是可以正常使用 netstat 命令的,这样可以方便的查看端口开放信息:</p><pre><code class="language-bash"># 查看所有端口
netstat -an
# 查看3306端口的开放情况
netstat -an|grep 3306</code></pre><p style=""><a href="https://image.3001.net/images/20200420/15873514956494.jpg"><img src="https://image.3001.net/images/20200420/15873514956494.jpg" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20200420/15873514956494.jpg 400w, https://image.3001.net/images/20200420/15873514956494.jpg 800w, https://image.3001.net/images/20200420/15873514956494.jpg 1200w, https://image.3001.net/images/20200420/15873514956494.jpg 1600w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><h3 style="" id="android-10-%E7%89%88%E6%9C%AC"><strong>Android 10 版本</strong></h3><p style="">Andorid 10 版本的 Termux 下无法正常使用 netstat -an 命令,国光的解决方法是安装一个 nmap,然后扫描本地端口(弯道超车):</p><pre><code class="language-bash"># 安装nmap端口扫描神器
pkg install nmap
# 扫描本地端口
nmap 127.0.0.1</code></pre><p style="">使用 nmap 操作 纯属无奈之举,但是又不是不能用(源于:罗永浩名言 :-))</p><p style=""><a href="https://image.3001.net/images/20200420/15873522318400.jpg"><img src="https://image.3001.net/images/20200420/15873522318400.jpg" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20200420/15873522318400.jpg 400w, https://image.3001.net/images/20200420/15873522318400.jpg 800w, https://image.3001.net/images/20200420/15873522318400.jpg 1200w, https://image.3001.net/images/20200420/15873522318400.jpg 1600w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><h1 style="" id="%E8%BF%9B%E9%98%B6%E9%85%8D%E7%BD%AE"><strong>进阶配置</strong></h1><p style="">要想使用体验好,进阶配置少不了。(单押)</p><h2 style="" id="%E6%9B%B4%E6%8D%A2%E5%9B%BD%E5%86%85%E6%BA%90"><strong>更换国内源</strong></h2><p style="">使用 <code>pkg update</code> 更新一下的时候发现默认的官方源网速有点慢,在这个喧嚣浮躁的时代,我们难以静下心等待,这个时候就得更换成国内的 <code>Termux</code> 清华大学源了,加快软件包下载速度。</p><h3 style="" id="%E6%96%B9%E6%B3%95%E4%B8%80%EF%BC%9A%E8%87%AA%E5%8A%A8%E6%9B%BF%E6%8D%A2%EF%BC%88%E6%8E%A8%E8%8D%90%EF%BC%89"><strong>方法一:自动替换(推荐)</strong></h3><p style="">可以使用如下命令自动替换官方源为 TUNA 镜像源</p><blockquote><p style=""><code>pkg update</code> 卡住的话多按几次回车 不要傻乎乎的等</p></blockquote><pre><code class="language-bash">sed -i 's@^\(deb.*stable main\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/termux-packages-24 stable main@' $PREFIX/etc/apt/sources.list
sed -i 's@^\(deb.*games stable\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/game-packages-24 games stable@' $PREFIX/etc/apt/sources.list.d/game.list
sed -i 's@^\(deb.*science stable\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/science-packages-24 science stable@' $PREFIX/etc/apt/sources.list.d/science.list
pkg update</code></pre><p style="">更换源几秒钟就可以执行完 <code>pkg update</code> 了,心里顿时乐开了花。</p><h3 style="" id="%E6%96%B9%E6%B3%95%E4%BA%8C%EF%BC%9A%E6%89%8B%E5%8A%A8%E4%BF%AE%E6%94%B9"><strong>方法二:手动修改</strong></h3><p style="">请使用内置或安装在 Termux 里的文本编辑器,例如 <code>vi</code> / <code>vim</code> / <code>nano</code> 等直接编辑源文件,<strong>不要使用 RE 管理器等其他具有 ROOT 权限的外部 APP</strong> 来修改 Termux 的文件</p><p style="">编辑 <code>$PREFIX/etc/apt/sources.list</code> 修改为如下内容</p><pre><code class="language-bash"># The termux repository mirror from TUNA:
deb https://mirrors.tuna.tsinghua.edu.cn/termux/termux-packages-24 stable main</code></pre><p style="">编辑 <code>$PREFIX/etc/apt/sources.list.d/science.list</code> 修改为如下内容</p><pre><code class="language-bash"># The termux repository mirror from TUNA:
deb https://mirrors.tuna.tsinghua.edu.cn/termux/science-packages-24 science stable</code></pre><p style="">编辑 <code>$PREFIX/etc/apt/sources.list.d/game.list</code> 修改为如下内容</p><pre><code class="language-bash"># The termux repository mirror from TUNA:
deb https://mirrors.tuna.tsinghua.edu.cn/termux/game-packages-24 games stable</code></pre><p style=""><strong>安装基础工具</strong></p><p style="">更换源之后来赶紧来下载安装一些基本工具吧,这些工具基本上是 Linux 系统自带的,因为 Termux 为了体积不过大,默认是没有带这些工具的,执行下面的命令来安装:</p><pre><code class="language-bash">pkg update
pkg install vim curl wget git tree -y</code></pre><h2 style="" id="%E7%BB%88%E7%AB%AF%E9%85%8D%E8%89%B2%E6%96%B9%E6%A1%88"><strong>终端配色方案</strong></h2><p style=""><strong>脚本项目地址</strong>:<a href="https://github.com/Cabbagec/termux-ohmyzsh/" target="_blank" rel="noopener external nofollow noreferrer">https://github.com/Cabbagec/termux-ohmyzsh/</a></p><p style="">该脚本主要使用了 <code>zsh</code> 来替代 <code>bash</code> 作为默认 shell,并且支持色彩和字体样式,同时也激活了外置存储,可以直接访问 SD 卡下的目录。主题默认为 agnoster,颜色样式默认为 Tango,字体默认为 Ubuntu。</p><blockquote><p style="">执行下面这个命令确保已经安装好了 curl 命令</p></blockquote><pre><code class="language-bash">sh -c "$(curl -fsSL https://github.com/Cabbagec/termux-ohmyzsh/raw/master/install.sh)" </code></pre><p style="">如果因为不可抗力的原因,出现 <code>port 443: Connection refused</code> 网络超时的情况,那么执行下面国光迁移到国内的地址的命令即可:</p><pre><code class="language-bash">sh -c "$(curl -fsSL https://html.sqlsec.com/termux-install.sh)" </code></pre><p style="">Android6.0 以上会弹框确认是否授权访问文件,点击<code>始终允许</code>授权后 Termux 可以方便的访问 SD 卡文件。</p><p style=""><a href="https://image.3001.net/images/20200418/1587207468173.png"><img src="https://image.3001.net/images/20200418/1587207468173.png" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20200418/1587207468173.png 400w, https://image.3001.net/images/20200418/1587207468173.png 800w, https://image.3001.net/images/20200418/1587207468173.png 1200w, https://image.3001.net/images/20200418/1587207468173.png 1600w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><p style="">手机 App 默认只能访问自己的数据,如果要访问手机的存储,需要请求权限,如果你刚刚不小心点了拒绝的话,那么可以执行以下命令来重新获取访问权限:</p><pre><code class="language-bash">termux-setup-storage</code></pre><p style="">脚本允许后先后有如下两个选项:</p><pre><code class="language-bash">Enter a number, leave blank to not to change: 14
Enter a number, leave blank to not to change: 6</code></pre><p style="">分别选择<code>色彩样式</code>和<code>字体样式</code>,重启 Termux app 后生效配置。不满意刚刚的效果,想要继续更改配色方案的话,可以根据下面命令来更改对应的色彩配色方案:</p><p style=""><strong>设置色彩样式</strong>:</p><p style="">输入 <code>chcolor</code> 命令更换色彩样式,或者执行 <code>~/.termux/colors.sh</code> 命令</p><p style=""><strong>设置字体</strong></p><p style="">运行 <code>chfont</code> 命令更换字体,或者执行 <code>~/.termux/fonts.sh</code> 命令</p><h2 style="" id="%E5%88%9B%E5%BB%BA%E7%9B%AE%E5%BD%95%E8%BD%AF%E8%BF%9E%E6%8E%A5"><strong>创建目录软连接</strong></h2><p style="">执行过上面的一键配置脚本后,并且授予 Termux 文件访问权限的话,会在家目录生成 <code>storage</code> 目录,并且生成若干目录,软连接都指向外置存储卡的相应目录:</p><p style=""><a href="https://image.3001.net/images/20200418/15872083523807.png"><img src="https://image.3001.net/images/20200418/15872083523807.png" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20200418/15872083523807.png 800w, https://image.3001.net/images/20200418/15872083523807.png 400w, https://image.3001.net/images/20200418/15872083523807.png 1600w, https://image.3001.net/images/20200418/15872083523807.png 1200w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><p style=""><strong>创建 QQ 文件夹软连接</strong></p><p style="">手机上一般经常使用手机 QQ 来接收文件,这里为了方便文件传输,直接在 <code>storage</code> 目录下创建软链接.<br><strong>QQ</strong></p><pre><code class="language-bash">ln -s /data/data/com.termux/files/home/storage/shared/tencent/QQfile_recv QQ</code></pre><p style=""><strong>TIM</strong></p><pre><code class="language-bash">ln -s /data/data/com.termux/files/home/storage/shared/tencent/TIMfile_recv TIM</code></pre><p style=""><a href="https://image.3001.net/images/20200418/15872085834532.png"><img src="https://image.3001.net/images/20200418/15872085834532.png" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20200418/15872085834532.png 1200w, https://image.3001.net/images/20200418/15872085834532.png 400w, https://image.3001.net/images/20200418/15872085834532.png 800w, https://image.3001.net/images/20200418/15872085834532.png 1600w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><p style="">这样可以直接在 <code>home</code> 目录下去访问 QQ 文件夹,大大提升了文件操作的工作效率。</p><h2 style="" id="%E5%AE%9A%E5%88%B6%E5%B8%B8%E7%94%A8%E6%8C%89%E9%94%AE"><strong>定制常用按键</strong></h2><p style="">在 Termux v0.66 的版本之后我们可以通过 <code>~/.termux/termux.properties</code> 文件来定制我们的常用功能按键,默认是不存在这个文件的,我们得自己配置创建一下这个文件。</p><p style="">下面做尝试简单配置一下这个文件:</p><pre><code class="language-bash"># 新建并编辑配置文件
vim ~/.termux/termux.properties</code></pre><p style="">内容为:</p><pre><code class="language-bash">extra-keys = [ \
['ESC','|','/','HOME','UP','END','PGUP','DEL'], \
['TAB','CTRL','ALT','LEFT','DOWN','RIGHT','PGDN','BKSP'] \
]</code></pre><blockquote><p style="">如果无法创建这个文件,那么得首先新建一下这个目录 <code>mkdir ~/.termux</code></p></blockquote><p style="">修改完成保存文件后,重启 Termux app 生效配置:</p><p style=""><a href="https://image.3001.net/images/20200420/15873594933774.jpg"><img src="https://image.3001.net/images/20200420/15873594933774.jpg" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20200420/15873594933774.jpg 400w, https://image.3001.net/images/20200420/15873594933774.jpg 800w, https://image.3001.net/images/20200420/15873594933774.jpg 1200w, https://image.3001.net/images/20200420/15873594933774.jpg 1600w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><p style="">可以直接输入特殊的字符串,例如上面的例子中的 <code>|</code> 就是一个字符串,此外 Termux 还有封装了一些特殊按键,入上面例子中的 <code>ESC</code> 就是 Termux 自带的按键,完整的特殊按键表如下:</p><div style="overflow-x: auto; overflow-y: hidden;"><table style="width: 200px"><colgroup><col style="width: 100px"><col style="width: 100px"></colgroup><tbody><tr style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box;"><th colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">按键</p></th><th colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">说明</p></th></tr><tr style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box;"><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style=""><code>CTRL</code></p></td><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style=""><code>特殊按键</code></p></td></tr><tr style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box;"><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style=""><code>ALT</code></p></td><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style=""><code>特殊按键</code></p></td></tr><tr style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box;"><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style=""><code>FN</code></p></td><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style=""><code>特殊按键</code></p></td></tr><tr style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box;"><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">ESC</p></td><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">退出键</p></td></tr><tr style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box;"><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">TAB</p></td><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">表格键</p></td></tr><tr style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box;"><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">HOME</p></td><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">原位键</p></td></tr><tr style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box;"><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">END</p></td><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">结尾键</p></td></tr><tr style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box;"><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">PGUP</p></td><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">上翻页键</p></td></tr><tr style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box;"><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">PGDN</p></td><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">下翻页键</p></td></tr><tr style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box;"><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">INS</p></td><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">插入键</p></td></tr><tr style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box;"><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">DEL</p></td><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">删除键</p></td></tr><tr style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box;"><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">BKSP</p></td><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">退格键</p></td></tr><tr style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box;"><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">UP</p></td><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">方向键 上</p></td></tr><tr style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box;"><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">LEFT</p></td><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">方向键 左</p></td></tr><tr style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box;"><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">RIGHT</p></td><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">方向键 右</p></td></tr><tr style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box;"><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">DOWN</p></td><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">方向键 下</p></td></tr><tr style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box;"><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">ENTER</p></td><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">回车键</p></td></tr><tr style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box;"><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">BACKSLASH</p></td><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">反斜杠 <code>\</code></p></td></tr><tr style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box;"><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">QUOTE</p></td><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">双引号键</p></td></tr><tr style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box;"><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">APOSTROPHE</p></td><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">单引号键</p></td></tr><tr style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box;"><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">F1~F12</p></td><td colspan="1" rowspan="1" colwidth="100" style="scrollbar-width: thin; scrollbar-color: rgb(28, 167, 238) rgba(0, 0, 0, 0); box-sizing: border-box; padding: 6px 12px; border-color: rgb(238, 238, 238); border-style: solid; border-width: 1px; border-image: none 100% / 1 / 0 stretch; vertical-align: middle;"><p style="">F1-F12 按键</p></td></tr></tbody></table></div><p style="">上面列出的三个<strong>特殊键</strong>中的每一个最多只能在附加键定义中列出一次,超过次数将会报错。</p><p style="">下面是国光我自用的按键表:</p><pre><code class="language-bash">extra-keys = [ \
['ESC','|','/','`','UP','QUOTE','APOSTROPHE'], \
['TAB','CTRL','~','LEFT','DOWN','RIGHT','ENTER'] \
]</code></pre><p style="">实际效果如下:</p><p style=""><a href="https://image.3001.net/images/20200420/15873610423256.jpg"><img src="https://image.3001.net/images/20200420/15873610423256.jpg" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20200420/15873610423256.jpg 400w, https://image.3001.net/images/20200420/15873610423256.jpg 1200w, https://image.3001.net/images/20200420/15873610423256.jpg 800w, https://image.3001.net/images/20200420/15873610423256.jpg 1600w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><h2 style="" id="zsh-%E4%B8%BB%E9%A2%98%E9%85%8D%E8%89%B2"><strong>zsh 主题配色</strong></h2><p style="">编辑家目录下的<code>.zshrc</code> 配置文件</p><pre><code class="language-bash">$ vim .zshrc</code></pre><p style="">第一行可以看到,默认的主题是 <code>agnoster</code> 主题:</p><p style=""><a href="https://image.3001.net/images/20200418/15872087339756.png"><img src="https://image.3001.net/images/20200418/15872087339756.png" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20200418/15872087339756.png 400w, https://image.3001.net/images/20200418/15872087339756.png 800w, https://image.3001.net/images/20200418/15872087339756.png 1200w, https://image.3001.net/images/20200418/15872087339756.png 1600w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><p style="">实际上这个主题也蛮酷的,如果你还想更换其他主题的话,那么在<code>.oh-my-zsh/themes</code> 目录下放着 <code>oh-my-zsh</code> 所有的主题配置文件,只要将默认的 agnoster 更换为其他的主题文件名即可。<br>下面是国光认为还不错的几款主题</p><p style=""><a href="https://image.3001.net/images/20200418/15872089685912.png"><img src="https://image.3001.net/images/20200418/15872089685912.png" alt="agnoster" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20200418/15872089685912.png 800w, https://image.3001.net/images/20200418/15872089685912.png 1200w, https://image.3001.net/images/20200418/15872089685912.png 1600w, https://image.3001.net/images/20200418/15872089685912.png 400w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><p style=""><a href="https://image.3001.net/images/20200418/15872091524140.png"><img src="https://image.3001.net/images/20200418/15872091524140.png" alt="ys" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20200418/15872091524140.png 1600w, https://image.3001.net/images/20200418/15872091524140.png 400w, https://image.3001.net/images/20200418/15872091524140.png 800w, https://image.3001.net/images/20200418/15872091524140.png 1200w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><p style=""><a href="https://image.3001.net/images/20200418/15872092946550.png"><img src="https://image.3001.net/images/20200418/15872092946550.png" alt="robbyrussell" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20200418/15872092946550.png 400w, https://image.3001.net/images/20200418/15872092946550.png 1600w, https://image.3001.net/images/20200418/15872092946550.png 800w, https://image.3001.net/images/20200418/15872092946550.png 1200w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><p style="">主题比较多,国光这里就不列举了,感兴趣大家可以一个个尝试去看看。 当然如果你是个变态的话,可以尝试 <code>random</code> 主题,每打开一个会话配色主题都是随机的。</p><pre><code class="language-bash">ZSH_THEME="random"</code></pre><blockquote><p style="">如果 oh-my-zsh 主题满足不了你们的话,Github 上还有很多高度定制的主题,感兴趣的朋友可以自己去折腾研究看看。</p></blockquote><h2 style="" id="zsh-%E6%8F%92%E4%BB%B6%E6%8E%A8%E8%8D%90"><strong>zsh 插件推荐</strong></h2><p style="">zsh 之所以受欢迎除了好看的配色以为,另一个原因就是强大的插件了。下面国光列举一款比较实用的插件的安装方法,更多强大的插件等待大家自己去探索。</p><h3 style="" id="autosuggestions"><strong>autosuggestions</strong></h3><p style="">根据用户的平时使用习惯,终端会自动提示接下来可能要输入的命令,这个实际使用效率还是比较高的:</p><pre><code class="language-bash"># 拷贝到 plugins 目录下
git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions</code></pre><p style="">在 <code>~/.zshrc</code> 中配置:</p><pre><code class="language-ini">plugins=(其他的插件 zsh-autosuggestions)</code></pre><p style=""><a href="https://image.3001.net/images/20200418/15872114762117.png"><img src="https://image.3001.net/images/20200418/15872114762117.png" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20200418/15872114762117.png 800w, https://image.3001.net/images/20200418/15872114762117.png 400w, https://image.3001.net/images/20200418/15872114762117.png 1200w, https://image.3001.net/images/20200418/15872114762117.png 1600w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><p style="">输入 <code>zsh</code> 命令生效配置:</p><p style=""><a href="https://image.3001.net/images/20200419/15872692273991.png"><img src="https://image.3001.net/images/20200419/15872692273991.png" alt="效果图" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20200419/15872692273991.png 800w, https://image.3001.net/images/20200419/15872692273991.png 1200w, https://image.3001.net/images/20200419/15872692273991.png 400w, https://image.3001.net/images/20200419/15872692273991.png 1600w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><p style="">可以看到国光我只敲了一个 <code>v</code> 后面的命令就自动提示补全了,这时候只要按<code>右方向键</code>,在 Termux 里面的快捷键是 <code>音量加 + D</code>,就可以直接补全命令了。</p><h2 style="" id="%E4%BF%AE%E6%94%B9%E5%90%AF%E5%8A%A8%E9%97%AE%E5%80%99%E8%AF%AD"><strong>修改启动问候语</strong></h2><p style="">默认的启动问候语如下:</p><p style=""><a href="https://image.3001.net/images/20200418/15872126727686.jpg"><img src="https://image.3001.net/images/20200418/15872126727686.jpg" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20200418/15872126727686.jpg 1600w, https://image.3001.net/images/20200418/15872126727686.jpg 400w, https://image.3001.net/images/20200418/15872126727686.jpg 1200w, https://image.3001.net/images/20200418/15872126727686.jpg 800w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><p style="">这个启动问候语在前期对于初学者有一定的帮助,但是随着你们 Termux 的熟悉,这个默认的问候语就会显得比较臃肿。编辑问候语文件可以直接修改启动显示的问候语:</p><pre><code class="language-bash">vim $PREFIX/etc/motd</code></pre><p style="">修改完的效果如下:</p><p style=""><a href="https://image.3001.net/images/20200418/1587213178823.jpg"><img src="https://image.3001.net/images/20200418/1587213178823.jpg" alt="本文版本归国光所有 转载注明出处哦" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20200418/1587213178823.jpg 400w, https://image.3001.net/images/20200418/1587213178823.jpg 1200w, https://image.3001.net/images/20200418/1587213178823.jpg 1600w, https://image.3001.net/images/20200418/1587213178823.jpg 800w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><p style="">这样启动新的会话的时候看上去就会简洁很多。什么你也想要这个效果? 呐~下面是国光自己生成的,可以直接复制粘贴:</p><pre><code class="language-ini"> _____
|_ _|__ _ __ _ __ ___ _ ___ __
| |/ _ \ '__| '_ ` _ \| | | \ \/ /
| | __/ | | | | | | | |_| |> <
|_|\___|_| |_| |_| |_|\__,_/_/\_\</code></pre><h2 style="" id="%E8%B6%85%E7%BA%A7%E7%AE%A1%E7%90%86%E5%91%98%E8%BA%AB%E4%BB%BD"><strong>超级管理员身份</strong></h2><p style="">实际上 Termux 不需要 root 权限也可以折腾各种各样的操作的,大家不必对 root 抱有啥幻想,本文的操作基本上没有涉及到手机要用到 root 的地步。</p><h3 style="" id="%E6%89%8B%E6%9C%BA%E6%B2%A1%E6%9C%89-root"><strong>手机没有 root</strong></h3><p style="">利用 <code>proot</code> 可以为手机没有 root 的用户来模拟一个 root 的环境,这里主要是经典的 Linux 文件系统布局上的模拟。</p><pre><code class="language-bash">pkg install proot -y</code></pre><p style="">然后终端下面输入:</p><pre><code class="language-bash">termux-chroot</code></pre><p style="">即可模拟 <code>root</code> 环境,该环境模仿 Termux 中的常规 Linux 文件系统,但是不是真正的 root。</p><p style=""><a href="https://image.3001.net/images/20200418/15872139633024.jpg"><img src="https://image.3001.net/images/20200418/15872139633024.jpg" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20200418/15872139633024.jpg 400w, https://image.3001.net/images/20200418/15872139633024.jpg 800w, https://image.3001.net/images/20200418/15872139633024.jpg 1600w, https://image.3001.net/images/20200418/15872139633024.jpg 1200w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><p style="">输入 <code>exit</code> 可回到普通用户的文件系统。</p><h3 style="" id="%E6%89%8B%E6%9C%BA%E5%B7%B2%E7%BB%8F-root"><strong>手机已经 root</strong></h3><p style="">安装 <code>tsu</code>,这是一个 <code>su</code> 的 Termux 版本,是一个真正的 root 权限,用来在 Termux 上替代 <code>su</code>,操作不慎可能对手机有安全风险,因为官方封装了,所以安装也很简单:</p><pre><code class="language-bash">pkg install tsu -y</code></pre><p style="">然后终端下面输入:</p><pre><code class="language-bash">tsu</code></pre><p style="">即可切换 <code>root</code> 用户,这个时候会弹出 <code>root</code> 授权提示,给予其 <code>root</code> 权限,效果图如下:</p><p style=""><a href="https://image.3001.net/images/20180501/15251567018423.png"><img src="https://image.3001.net/images/20180501/15251567018423.png" alt="18年的老图了 将就着看吧" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20180501/15251567018423.png 1200w, https://image.3001.net/images/20180501/15251567018423.png 800w, https://image.3001.net/images/20180501/15251567018423.png 1600w, https://image.3001.net/images/20180501/15251567018423.png 400w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><p style="">在管理员身份下,输入 <code>exit</code> 可回到普通用户身份。不过本文没有设计到 root 权限的操作,一些底层的工具可能才会需要,考虑到 root 的不安全性 和 那些工具的冷门性,国光这里就没有继续拓展。</p><h2 style="" id="%E5%A4%87%E4%BB%BD%E4%B8%8E%E6%81%A2%E5%A4%8D"><strong>备份与恢复</strong></h2><p style="">评论区有网友提问 Termux 有办法打个镜像或者快照吗?😂 怕折腾坏了。也有网友分享了官方 WiKi 已经更新了备份和恢复的方法了,原文是:<a href="https://wiki.termux.com/wiki/Backing_up_Termux" target="_blank" rel="noopener external nofollow noreferrer">https://wiki.termux.com/wiki/Backing_up_Termux</a></p><p style="">下面国光简单搬运过来:</p><p style="">强烈建议在复制粘贴之前了解对应命令的作用。误操作可能会不可挽回地损坏您的数据,数据无价,谨慎操作。</p><h3 style="" id="%E5%A4%87%E4%BB%BD"><strong>备份</strong></h3><p style="">确保已经获取了存储访问的权限,如果没有获取的话,执行以下命令来重新获取访问权限:</p><pre><code class="language-bash">termux-setup-storage</code></pre><p style="">然后去 Termux 根目录下:</p><pre><code class="language-bash">cd /data/data/com.termux/files</code></pre><p style="">备份配置文件为 termux-backup.tar.gz:</p><pre><code class="language-bash">tar -zcf /sdcard/termux-backup.tar.gz home usr</code></pre><p style="">备份应该完成,没有任何错误。除非用户滥用 root 权限,否则不应有任何权限拒绝。</p><blockquote><p style=""><strong>警告</strong>:不要将备份文件存储在 Termux 私有目录中,因为从设置中清除 Termux 数据后,这些目录也将被删除。(类似于 Windows 准备重新安装系统,却把资料备份存储在 C 盘一个道理)</p></blockquote><p style="">这些私有目录看上去类似如下的目录:</p><pre><code class="language-bash">/data/data/com.termux
/sdcard/Android/data/com.termux
/storage/XXXX-XXXX/Android/data/com.termux
${HOME}/storage/external-1</code></pre><p style="">珍爱数据,远离私有目录。</p><h3 style="" id="%E6%81%A2%E5%A4%8D"><strong>恢复</strong></h3><p style="">这里假设您已将 Termu 之前备份的 home 和 usr 目录备份到同一个备份文件中。请注意,在此过程中所有文件都将被覆盖现有的配置:</p><p style="">确保已经获取了存储访问的权限,如果没有获取的话,执行以下命令来重新获取访问权限:</p><pre><code class="language-bash">termux-setup-storage</code></pre><p style="">然后去 Termux 根目录下:</p><pre><code class="language-bash">cd /data/data/com.termux/files</code></pre><p style="">解压提取之前备份的内容,覆盖现存的文件并删除之前的备份文件:</p><pre><code class="language-bash">tar -zxf /sdcard/termux-backup.tar.gz --recursive-unlink --preserve-permissions</code></pre><p style="">操作完成重启 Termux 即可恢复数据。</p><h1 style="" id="%E5%BC%80%E5%8F%91%E7%8E%AF%E5%A2%83"><strong>开发环境</strong></h1><p style="">Termux 支持的开发环境很强,可以完美的运行 C、Python、Java、PHP、Ruby 等开发环境,建议读者朋友们选择自己需要的开发环境折腾。</p><h2 style="" id="%E7%BC%96%E8%BE%91%E5%99%A8"><strong>编辑器</strong></h2><p style="">写代码前总得折腾一下编辑器,毕竟磨刀不误砍柴工嘛。Termux 支持多种编辑器,完全可以满足日常使用需求。</p><h3 style="" id="emacs"><strong>Emacs</strong></h3><p style="">据说 Emacs 是神的编辑器,国光我这种小菜鸡还不会使用哎,但是 Termux 官方已经封装好了 Emacs 了,我们安装起来就会简单很多:</p><pre><code class="language-bash">pkg install emacs </code></pre><h3 style="" id="nano"><strong>nano</strong></h3><p style="">nano 是一个小而美的编辑器。具有如下:打开多个文件,每行滚动,撤消 / 重做,语法着色,行编号等功能</p><p style="">同样安装起来也很简单:</p><pre><code class="language-bash">pkg install nano</code></pre><h3 style="" id="vim"><strong>Vim</strong></h3><p style="">Vim 被称为编辑器之神,基本上 Linux 发行版都会自带 Vim,这个在前文基本工具已经安装了,如果你没有安装的话,可以使用如下命令安装:</p><pre><code class="language-bash">pkg install vim</code></pre><p style="">并且官方也已经封装了 <code>vim-python</code>,对 Python 相关的优化。</p><pre><code class="language-bash">pkg install vim-python</code></pre><h4 style="" id="%E8%A7%A3%E5%86%B3%E6%B1%89%E5%AD%97%E4%B9%B1%E7%A0%81"><strong>解决汉字乱码</strong></h4><p style="">如果你的 Vim 打开汉字出现乱码的话,那么在家目录 (<code>~</code>) 下,新建<code>.vimrc</code> 文件</p><pre><code class="language-bash">vim .vimrc</code></pre><p style="">添加内容如下:</p><pre><code class="language-ini">set fileencodings=utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1
set enc=utf8
set fencs=utf8,gbk,gb2312,gb18030</code></pre><p style="">然后 <code>source</code> 下变量:</p><pre><code class="language-bash">source .vimrc</code></pre><p style=""><strong>效果图</strong></p><p style=""><a href="https://image.3001.net/images/20180501/15251690917140.png"><img src="https://image.3001.net/images/20180501/15251690917140.png" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20180501/15251690917140.png 1600w, https://image.3001.net/images/20180501/15251690917140.png 400w, https://image.3001.net/images/20180501/15251690917140.png 1200w, https://image.3001.net/images/20180501/15251690917140.png 800w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><h4 style="" id="vim-%E9%85%8D%E8%89%B2"><strong>Vim 配色</strong></h4><p style="">Termux Vim 自带了如下的配色:</p><pre><code class="language-bash">ls /data/data/com.termux/files/usr/share/vim/vim82/colors
desert.vim morning.vim shine.vim blue.vim elflord.vim murphy.vim slate.vim darkblue.vim evening.vim pablo.vim industry.vim peachpuff.vim torte.vim delek.vim koehler.vim ron.vim zellner.vim </code></pre><p style="">配色可以自己一个个尝试一下,还是向上面的汉字乱码那样,编辑家目录下的<code>.vimrc</code> 文件:</p><pre><code class="language-bash">vim ~/.vimrc</code></pre><p style="">新增如下内容:</p><pre><code class="language-ini">set nu " 显示行号
colorscheme desert " 颜色主题
syntax on " 打开语法高亮</code></pre><p style="">下面是国光随便找的几个颜色主题效果,感兴趣的朋友可以自己一个个尝试:</p><p style=""><a href="https://image.3001.net/images/20200419/15872622533864.jpg"><img src="https://image.3001.net/images/20200419/15872622533864.jpg" alt="slate" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20200419/15872622533864.jpg 400w, https://image.3001.net/images/20200419/15872622533864.jpg 1600w, https://image.3001.net/images/20200419/15872622533864.jpg 800w, https://image.3001.net/images/20200419/15872622533864.jpg 1200w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><p style=""><a href="https://image.3001.net/images/20200419/15872621751148.jpg"><img src="https://image.3001.net/images/20200419/15872621751148.jpg" alt="murphy" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20200419/15872621751148.jpg 400w, https://image.3001.net/images/20200419/15872621751148.jpg 1200w, https://image.3001.net/images/20200419/15872621751148.jpg 1600w, https://image.3001.net/images/20200419/15872621751148.jpg 800w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><p style=""><a href="https://image.3001.net/images/20200419/15872625401164.jpg"><img src="https://image.3001.net/images/20200419/15872625401164.jpg" alt="peachpuff" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20200419/15872625401164.jpg 800w, https://image.3001.net/images/20200419/15872625401164.jpg 1200w, https://image.3001.net/images/20200419/15872625401164.jpg 400w, https://image.3001.net/images/20200419/15872625401164.jpg 1600w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><h2 style="" id="apache"><strong>Apache</strong></h2><p style="">Apache 是一个开源网页服务器软件,由于其跨平台和安全性,被广泛使用,是最流行的 Web 服务器软件之一。</p><h3 style="" id="%E5%AE%89%E8%A3%85-apache"><strong>安装 Apache</strong></h3><pre><code class="language-bash">pkg install apache2</code></pre><h3 style="" id="%E5%90%AF%E5%8A%A8-apache"><strong>启动 Apache</strong></h3><pre><code class="language-bash">apachectl start</code></pre><p style="">然后浏览器访问: <code>http://127.0.0.1:8080</code> 访问是否成功启动:</p><p style=""><a href="https://image.3001.net/images/20200424/15876870133939.jpg"><img src="https://image.3001.net/images/20200424/15876870133939.jpg" width="100%" height="100%" style="display: inline-block" srcset="https://image.3001.net/images/20200424/15876870133939.jpg 1600w, https://image.3001.net/images/20200424/15876870133939.jpg 400w, https://image.3001.net/images/20200424/15876870133939.jpg 800w, https://image.3001.net/images/20200424/15876870133939.jpg 1200w" sizes="(max-width: 400px) 400px, (max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px"></a></p><p style="">Termux 自带的 Apache 的网站默认路径为:</p><p style=""><strong>$PREFIX/share/apache2/default-site/htdocs/index.html</strong></p><h3 style="" id="%E5%81%9C%E6%AD%A2-apache"><strong>停止 Apache</strong></h3><pre><code class="language-bash">apachectl stop</code></pre><h3 style="" id="%E9%87%8D%E5%90%AF-apache"><strong>重启 Apache</strong></h3><pre><code class="language-bash">apachectl restart</code></pre><h2 style="" id="apache-%E8%A7%A3%E6%9E%90-php"><strong>Apache 解析 PHP</strong></h2><p style="">既然 Apache、PHP、MySQL 都可以成功安装的话,那么现在只要配置好 Apache 解析 PHP 之后就可以打造一个 Android 平台上的 LAMPP 平台了,配置本小节的内容得确保 Termux 已经配置好了 PHP 开发环境,没有配置好的可以参加下面 PHP 小节部分。</p>
评论区