安卓本地搭建说明.md 3.6 KB
Newer Older
H
hjdhnx 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
#### 基于 ZeroTermux 搭建
###### qq官群1:714730084
###### qq官群3:878847174
#### 教程开始
1. 准备工作-termux通过tome搭建完整的ubuntu1804系统(基于proot容器技术)
ZeroTermux左侧边栏按住手指右滑出现操作面板  
点击面板的切换源-北京源并确定,之后出现的任何提示都回车或者y确定    
再次进入面板,手指上拉滑到侧边栏下方的MOE全能并点击,之后各种一路回车或者确定  
然后跟着提示一步步安装proot-ubutun1804系统并不需要gui界面  
完毕后输入debian进入系统后才进行如下操作进行搭建项目(exit命令可以退出Ubuntu1804并回到termux)  
2. ubuntu1804换源及python换源和依赖安装
手机浏览器访问: [https://mirrors.bfsu.edu.cn/help/ubuntu-ports/](https://mirrors.bfsu.edu.cn/help/ubuntu-ports/)  
选择ubuntu版本为1804,并复制其中的源地址,或者用下面的源代码也行  
```shell
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.bfsu.edu.cn/ubuntu-ports/ bionic main restricted universe multiverse
# deb-src https://mirrors.bfsu.edu.cn/ubuntu-ports/ bionic main restricted universe multiverse
deb https://mirrors.bfsu.edu.cn/ubuntu-ports/ bionic-updates main restricted universe multiverse
# deb-src https://mirrors.bfsu.edu.cn/ubuntu-ports/ bionic-updates main restricted universe multiverse
deb https://mirrors.bfsu.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse
# deb-src https://mirrors.bfsu.edu.cn/ubuntu-ports/ bionic-backports main restricted universe multiverse
deb https://mirrors.bfsu.edu.cn/ubuntu-ports/ bionic-security main restricted universe multiverse
# deb-src https://mirrors.bfsu.edu.cn/ubuntu-ports/ bionic-security main restricted universe multiverse

# 预发布软件源,不建议启用
# deb https://mirrors.bfsu.edu.cn/ubuntu-ports/ bionic-proposed main restricted universe multiverse
# deb-src https://mirrors.bfsu.edu.cn/ubuntu-ports/ bionic-proposed main restricted universe multiverse
```
然后换源可能需要用到下面的命令:
```shell
vi /etc/apt/sources.list # 编辑源列表
dd # 在非输入模式下,vim中输入dd可以删除整行
i # 进入vim的编辑插入模式,记得复制粘贴源进入
:wq # 保存
apt update # 更新软件包列表
apt upgrade # 升级本地软件包
```
 换源完毕后进行安装项目需要的相关环境
```shell
apt install net-tools  # ifconfig查Ip命令需要
apt install python3-pip # python3依赖管理器,装依赖需要
pip3 install -i https://mirrors.cloud.tencent.com/pypi/simple --upgrade pip # 用腾讯源临时升级pip
pip config set global.index-url https://mirrors.cloud.tencent.com/pypi/simple # python换腾讯源

```
然后把dr_py项目搞到内存卡以下目录:  
/storage/emulated/0/Download/pywork/dr_py  
cd 到该目录进行安装依赖:  
```shell
cd /sd/pywork/dr_py
pip3 install -r requirements.txt
```
3. 运行dr_py项目
两种方法,一条命令对应一种
```shell
python3 app.py # 需要shell上运行调试,并且也可以 nohup python3 app.py &
. <(cat app.sh) # 用于生产环境正式运行,更加强大的进程启动和在线日志
```
4. termux配置启动命令
如果在debian里面记得先 exit回到termux里
```shell
apt install openssh vim -y
vi ~/.bashrc

echo "用户:"$(whoami)

if pgrep -x "sshd" >/dev/null
  then
    echo "sshd运行中..."
  else
    sshd
    echo "自动启动sshd"
fi
:wq
echo "debian" >> ~/.bashrc
```
这套命令配置完了下次打开termux会自动进入debian虚拟机(ubuntu1804)

5. 启动成功访问查看
[本地地址](http://localhost:5705)
[进程管理地址](http://localhost:9001)