Termux是一个适用于 Android 的终端模拟器,其环境类似于 Linux 环境。 无需Root或设置即可使用。 Termux 会自动进行最小安装 - 使用 APT 包管理器即可获得其他软件包。
sed -i 's@^\(deb.*stable main\)$@#\1\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-main stable main@' $PREFIX/etc/apt/sources.list
apt update && apt upgrade
三、安装必要的软件包
pkg install nginx
pkg install wget
pkg install vim
四、配置 NGINX
安装完成后,NGINX 的配置文件位于 /data/data/com.termux/files/usr/etc/nginx/
目录下。你可以使用 vim
或 nano
编辑 nginx.conf
文件:
vim /data/data/com.termux/files/usr/etc/nginx/nginx.conf
你可以根据需要修改配置文件。例如,你可以更改监听端口(默认是 8080)或设置根目录:
server {
listen 8080;
server_name localhost;
location / {
root /data/data/com.termux/files/usr/share/nginx/html;
index index.html;
}
}
五、启动 NGINX
nginx
六、要获取手机的 IP 地址,可以在 Termux 中运行:
ifconfig
七、停止和重启 NGINX
停止:
nginx -s stop
重启:
nginx -s reload
八、保持 Termux 运行
为了确保 Termux 在后台持续运行,你可以使用 termux-wake-lock
命令防止系统休眠:
termux-wake-lock
九、使用 SSH 远程管理
pkg install openssh
sshd