termux搭建服务器方式


pkg install vim

apt update

安装debian系统
apt install proot-distro
proot-distro install debian
proot-distro login debian

df -h 查看磁盘空间

安装linux
pkg install proot
termux-chroot
pkg install wget
mkdir CentOS && cd CentOS && pkg install wget openssl-tool proot -y && hash -r && wget https://raw.fastgit.org/EXALAB/AnLinux-Resources/master/Scripts/Installer/CentOS/centos.sh && sed -i 's/githubusercontent.com/fastgit.org/' centos.sh && bash centos.sh && rm centos.sh
ls
./start-centos.sh
exit退出

使用ssh连接
apt install openssh
sshd

cp storage/dcim/公钥文件名.pub ./.ssh
cat .ssh/公钥文件名.pub >> .ssh/authorized_keys

whoami
ifconfig

ssh连接时候需要连接同一个,都可以上网的wifi
echo "sshd" >> ~/.bashrc

安装jdk
yum install java-1.8.0-openjdk* -y
java -version

安装tomcat
https://tomcat.apache.org/download-80.cgi
/data/data/com.termux/files/home/CentOS/centos-fs/usr
/usr/local/tomcat8
直接将本地tomcat考到termux中,然后解压
yum install unzip
unzip tomcat

或者tar zxvf apache-tomcat-8.0.53.tar.gz

启动tomcat时如果无法启动提示权限不足,需要执行命令:chmod u+x *.sh
ls -l 文件名,查看文件权限

/data/data/com.termux/files/home/CentOS/centos-fs/usr/lib

JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.302.b08-0.el8_4.aarch64/

修改环境变量
配置vim ~/.zshrc,增加如下内容:

#JDK8
export JAVA_HOME=/data/data/com.termux/files/home/java/jdk8
export PATH=$PATH:$JAVA_HOME/bin:.
export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.

java 安装目录 /data/data/com.termux/files/home/CentOS/centos-fs/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.302.b08-0.el8_4.aarch64/
tomcat 安装目录 /data/data/com.termux/files/home/CentOS/centos-fs/usr/local/apache-tomcat-8.0.26/bin/startup.sh

安装postgresql
pkg install postgresql
PGDATA=/data/data/com.termux/files/var/lib/pgsql/data
export PGDATA
initdb --encoding=utf-8

修改postgresql.conf,pg_hba.conf允许Navicat连接
pg_ctl start
pg_ctl restart重启数据库
createuser postgres
createdb mydb
psql mydb

访问外部存储卡

termux-setup-storage
CentOS 同目录的storage 中的3233-3434目录就是外部存储卡
进入外部存储卡的方式:
全目录地址为:/storage/3233-3434/Android/data/com.termux/files
也是目录地址:/data/data/com.termux/files/home/storage/external-1
也是目录地址:~/storage/external-1
ln -s ~/storage/external-1 CentOS/centos-fs/usr/local/external-1

termux中的linux 访问termux文件
https://blog.csdn.net/qq_35425070/article/details/8604119

nginx

pkg install nginx
nginx
nginx -s reload
nginx -s stop
nginx -s quit
kill -9 `pgrep nginx`
nginx配置,参考:
vim $PREFIX/etc/nginx/nginx.conf
https://www.sqlsec.com/2018/05/termux.html?tdsourcetag=s_pctim_aiomsg
cp -r /data/data/com.termux/files/usr/share/nginx/html /storage/3233-3434/Android/data/com.termux/files/html

创建文件软连接
ln -s /data/data/com.termux/files/home/storage/shared/tencent/QQfile_recv QQ
~ $ cd
~ $ ls

访问win10共享文件
apt install samba*
使用时提示smb.conf文件,需要手动创建
smbclient -L "\192.168.1.101Downloads" -U 账号%密码
smbclient //192.168.1.101/Downloads -U 账号%密码 -W domain

原文地址:https://www.cnblogs.com/943711466qq/p/15498835.html