Mobile phone build server tutorial, I personally test without root

Note: If you don’t want to download in such a trouble, you can move to 八.Termux的备份和恢复this step

1. Cause

The speed of mobile phone replacement is very fast. Even if it takes a long time to change the mobile phone, what do you do with the old mobile phone at home?
Please add a picture descriptionPlease add a picture description
But when you suddenly find out that
Please add a picture description
you don’t need to change the basin, we can use a mobile phone to get a server or a home network disk. There is absolutely no speed limit. The current premise depends on your network speed (there is usually a wireless network at home, right? If you don’t have one, you can get a data card. If you don’t have much, don’t get a network disk. Then upload a few g and you’ll burp if you don’t have data.) What I write here is mainly to use Please add a picture description
Termux software on the mobile phone to install linux and build a java environment to run the jar package on the mobile phone
. Build a java environment, run the jar package on the mobile phone, no root is required, and the external network can also be accessed

It is recommended to read it roughly first, and then operate it, so that external network access can be penetrated through the internal network of the Peanut Shell app

2. Download software

It is recommended to use the official website to download, download first F-Droidand then go to the software to search and Termuxdownload or download
from or , the network is limited, you can use Baidu for details,Google PlayGoogle PlayPersonally recommend using F-Droid, of course it is just a recommendation

F-Droid address: https://f-droid.org/packages/com.termux/
Google Play address: https://play.google.com/store/apps/details?id=com.termux
Termux official website: https ://termux.dev/en/

3. Configuration

1. Replace the installation source

termux-change-repo

Enter the command, the following interface will appear, click ok or enter. At
insert image description here
first it is the picture below. Wait until
insert image description here
it changes to the picture below and then click ok or press enter. If some are not ChinaAll, you can choose Tsinghua(Tsinghua source)
Click to switch
insert image description here

renew

pkg update

Install common software

pkg install vim curl wget tree -y 

2. Grant permission and create a link

3.1 Grant termux the permission to read files.
Enter the command and it will pop up after a while. After allowing it, enter ls and you will find an additional storagefolder. storageEach folder in it points to each folder of the phone, which sharedpoints to the root directory of the internal storage.

termux-setup-storage

insert image description here

3.2 Create a soft link
The purpose of creating a soft link is to facilitate future use. If there is no soft link, you will need to enter a lot to complete the operation of the file. Here,
insert image description here
I create a 1/file file in the root directory of the mobile phone, so it is easy to find

ln -s storage/shared/1/file/ file

Enter ls -land you will find one more mapping file file
insert image description here

3.3 Create an ssh connection
because it is not very convenient to use a mobile phone to operate. Here, install openssh to connect to a computer for operation. Of course, only a mobile phone can also be used. It is just a suggestion

install openssh

pkg install openssh -y

Set a password, it is invisible when entering the password, you need to enter the password twice

passwd

insert image description here
Then ifconfigget the ip address and whoamiget the username
Here it is recommended that the computer turn on the hotspot for the mobile phone, or connect the computer and mobile phone to a wifi at the same time, or use the intranet penetration or... and then use the computer to connect, turn on the wifi of the mobile phone, you can also check the ip
and then you can connect to the computer

3.4 Xshell connects
the mobile phone to start ssh

sshd &

If you start connecting
insert image description here
insert image description here
with a computer, you can watch the big screen on the computer and perform subsequent operations. If you don’t have a computer, you can continue to use your mobile phone.
Please add a picture descriptioninsert image description here

You can not use it, just record the root authority of
the self-starting
pkg install termux-services
sv-enable sshd
termux There are two methods
1. The phone does not have root, use proot to simulate root
pkg install proot
termux-chroot #Enter root
exit#Exit
2. The phone is already rooted, you can Install tsu
pkg install tsu
tsu #Enter root
exit#Exit

3. Download jdk

jdk can download the required version from its official website, or use the recommended download

3.1 command download

Because I want to use jdk1.8 and then...Please add a picture description

1. Query the official JDK

pkg search jdk

The jdk that can be downloaded will be listed, the following is an openjdk-17
insert image description here
2. Install JDK

pkg install openjdk-17

3. Verify that the installation is successful

java -version

3.2 Official website download

Download the jdk version you need, pay attention to choose the linux-aarch64 version
Oracle official website download address: https://www.oracle.com/java/technologies/downloads/
insert image description here
If you don’t want to log in to your account to download, look here. I downloaded jdk- 8u341-linux-aarch64.tar.gz version, the download speed is unlimited, the network speed is fast, it will be downloaded in a few seconds
jdk-8u341-linux-aarch64.tar.gz, click here to download , the password is 1234

3.2.1 Put jdk into termux

After downloading, transfer the installation package to the phone and put it 根目录/1/filein a folder.
cp means copy, mv means move

cp file/jdk-8u341-linux-aarch64.tar.gz ~
mv file/jdk-8u341-linux-aarch64.tar.gz ~

3.2.2 Decompress jdk

Unzip jdk and delete it. If you don’t want to delete it, just remove && and the following code

tar -zxvf jdk-8u341-linux-aarch64.tar.gz && rm -rf jdk-8u341-linux-aarch64.tar.gz

Enter the directory after decompression

cd jdk1.8.0_341

Enter pwdthe acquisition path
The path is: /data/data/com.termux/files/home/jdk1.8.0_341
insert image description here
first install linux, then put the environment in linux

4. Download Linux

4.1 Download using proot-distro

4.1.1 Download and installproot-distro

pkg install proot-distro

4.1.2 Query supported versions

proot-distro list

insert image description here

4.1.3 install ubuntu

proot-distro install ubuntu

insert image description here
Now run ‘proot-distro login ubuntu’ to log in.

4.1.4 run linux

proot-distro login ubuntu

Write a startup script, use the command to start every time, write a running script, run the startup script directly and it will be OK

vi ~/linux-ubuntu-start.sh

Enter i to enter the edit mode, copy the script in, then press esc and use the :wq command to save and exit. The script is as follows:

#启动linux-ubuntu
echo "linux-ubuntu running..."
proot-distro login ubuntu

Set executable permissions for the script

chmod +x ~/linux-ubuntu-start.sh

4.1.5 Start Linux

./linux-ubuntu-start.sh

4.2 Download using script

First install the required git to pull things, proroot will use it to start Centos

pkg install proot git -y

Use git to pull

git clone https://github.com/sqlsec/termux-install-linux

Then you will find an extra termux-install-linuxfolder

cd termux-install-linux

Install the python environment, because the executed script requires python

pkg install python -y

Check if the installation is successful

python -V

Start the script, and then make a selection,

python termux-linux-install.py

Here I install Centos, after selecting, press Enter to download, and then wait,
insert image description heresome people will report CANNOT LINK EXECUTABLE "sh": library "/data/data/com.termux/files/usr/lib/libtermux-exec.so" needed or dlopened by "/system/bin/sh" is not accessible for the namespace "(default)"an error similar to this, exit and close the software, re-enter, rundpkg --configure -ato fix it, then restart the script

After completion, return to the main directory, enter Termux-Linuxthe folder (the downloaded scripts are placed here), and then the corresponding system has a corresponding name

insert image description here

What I downloaded here is CentOS, just go directly to this folder

cd Termux-Linux/CentOS/

start the system
insert image description here

./start-centos.sh 

5. Configure jdk environment

Enter whoamito see if it is roota user

5.1 Edit configuration

vi /etc/profile

5.2 Add jdk configuration

Enter ito enter the edit mode, and then add the following content at the end
Here JAVA_HOMEis pwdthe path obtained before

#set jdk
JAVA_HOME=/data/data/com.termux/files/home/jdk1.8.0_341
CLASS_PATH=$JAVA_HOME/lib/tools.jar
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME CLASS_PATH PATH

5.3 Reload configuration file

source /etc/profile

5.4 Check whether the configuration is successful

java -version

insert image description here

4. Test

1. Transfer files to linux

First put the file under the 根目录/1/filefolder
wx.jarinsert image description here
jar包file/opt

mv /data/data/com.termux/files/home/file/wx.jar /opt

insert image description here

2. Start the jar package

java -jar wx.jar 

Then enter the mobile phone ip: port number to access
insert image description here
insert image description herePlease add a picture description

5. Realize external network access

1. NATAPP

Pros: Use natapp to run commands in linux, exercise linux commands
Cons: This is a mobile phone, we can install apps, but sometimes it will be disconnected, and it is troublesome to close it when you don’t want others to see it

1.1. Intranet penetration

natapp
The official website of NATAPP is used here : https://natapp.cn/
After registering and logging in, add a tunnel
insert image description here
and purchase directly for free
insert image description here
. Record the authtoken that just configured the port.
insert image description here

1.2. Download the executable file

Click the client download in the upper right corner
URL: https://natapp.cn/#download
insert image description here

1.3. Run

After downloading, put the file 手机根目录/1/fileunder the folderinsert image description here

Move natappit into linuxit
and create a file first, I usually put it /usr/localin it

mkdir /usr/local/natapp
cd /usr/local/natapp

mobile natapp

mv /data/data/com.termux/files/home/file/natapp /usr/local/natapp/

Make sure that the jar package you got before is starting. You can start it in the foreground, and then create a new connection, or start it in the background. If it is a mobile phone, use the background start
In this way, wx.jar is started in the background, where a.log is the log directory generated by jar startup and the jar package is at the same level, and the name and directory can be customized

nohup java -jar wx.jar > a.log &

If you test the time and find that the time is wrong, please read this article: https://blog.csdn.net/weixin_45853881/article/details/126890153

Here, in order to intuitively see that it is accessed, use the foreground to run, otherwise it is troublesome to look at the log

1. 3.1 Start intranet penetration

Grant natapp permission to run

chmod +x natapp 
1.3.1.1 Direct boot
 ./natapp  -authtoken=xxx

Then the mapped external network address will be displayed in the foreground

insert image description here
insert image description here

1.3.1.2 Background start

But some people say, run directly in the foreground, what should I do if I want to get some other code, I am not a computer, so it is inconvenient
Please add a picture description
to go to the official website of natapp: https://natapp.cn/article/config_ini
insert image description here
to add a configuration file

vi config.ini

Get the following content up, don't forget to writeauthtoken

#将本文件放置于natapp同级目录 程序将读取 [default] 段
#在命令行参数模式如 natapp -authtoken=xxx 等相同参数将会覆盖掉此配置
#命令行参数 -config= 可以指定任意config.ini文件
[default]
authtoken=                      #对应一条隧道的authtoken
clienttoken=                    #对应客户端的clienttoken,将会忽略authtoken,若无请留空,
log=none                        #log 日志文件,可指定本地文件, none=不做记录,stdout=直接屏幕输出 ,默认为none
loglevel=ERROR                  #日志等级 DEBUG, INFO, WARNING, ERROR 默认为 DEBUG
http_proxy=                     #代理设置 如 http://10.123.10.10:3128 非代理上网用户请务必留空

background start

 nohup ./natapp &

At this time, there is another problem. It is indeed started in the background, but I can’t find the mapped URL. What should I do? Please add a picture description
Please add a picture description
Tell me how to fix it, or I will beat you up

modify config.inifile

vi config.ini

The modified content is as follows:
modify the log log file to stdout
log level and modify it to INFO
authtokenwrite on the official website for yourself

#将本文件放置于natapp同级目录 程序将读取 [default] 段
#在命令行参数模式如 natapp -authtoken=xxx 等相同参数将会覆盖掉此配置
#命令行参数 -config= 可以指定任意config.ini文件
[default]
authtoken= 					   #自己的隧道的authtoken ==>对应一条隧道的authtoken
clienttoken=                   #对应客户端的clienttoken,将会忽略authtoken,若无请留空,
log=stdout                     #log 日志文件,可指定本地文件, none=不做记录,stdout=直接屏幕输出 ,默认为none
loglevel=INFO                  #日志等级 DEBUG, INFO, WARNING, ERROR 默认为 DEBUG
http_proxy=                    #代理设置 如 http://10.123.10.10:3128 非代理上网用户请务必留空

start up

nohup ./natapp &

Query mapped address

cat nohup.out 

This is the mapped address

insert image description here

Check out the runningnatapp

 ps -ef |grep natapp 

insert image description here

Kill the natapp process kill -9 xxx, xxx is to find the corresponding port number

kill -9 18433

If you find it troublesome, you can also write a startup script

vi natapp-start.sh 

Press ito enter edit mode, enter the code below, then press exc, enter:wq

#启动natapp
echo "natapp running..."
nohup ./natapp &

Add permissions

chmod +x natapp-start.sh 

start up

./natapp-start.sh 

The query mapping URL is the same as before

cat nohup.out 

Please add a picture descriptionPlease add a picture description
If you want to use ssh remotely, the configuration is the same as this one. I have no time recently. I will write it in a few days. You can directly use the following app to get it

2. Peanut shells

2.1 Configure the project port

Now we don't need linux commands, let's start downloading apps
Please add a picture descriptionPlease add a picture description

Peanut shell download website: https://hsk.oray.com/download/
The mobile browser and the computer display are not the same, but the problem is not big Please add a picture description
. There are two software in total, it is best to download
insert image description here
the peanut shell management app: for adding , Editing, Management Interface
insert image description here
Peanut Shell Intranet App: Also called Peanut Shell Intranet App, it is mainly used to start the Peanut Shell Management App to add open ports.
The external network address and the access address of the management version are the same. The internal network host needs to map the ip: port number. For the mobile phone’s ip, you can find wifi and then connect to the wifi to find the ip or find -> set -> About mobile phone->status information->IP address, every time the mobile phone connects to wifi, it will have a random ip, which can be fixed for him. The method is Baidu, and then there is a chance to have a mapping
insert image description here
diagnosis. This is a failure
insert image description here
because every time you reconnect to the wifi mobile phone It will change the IP so the connection fails. After modifying from the peanut shell management app, exit the background version of the peanut shell internal version software and re-enter it, and then check it again (Exit the software and re-enter to update and load the data just configured
insert image description here

2.2 Configure ssh port

The configuration items on the mobile phone are also the same, but the interface is different. The
insert image description here
access address here is tcp://xxx:xxx==> tcp://地址:端口号
this tcp://is high-speed. We use tcp connection here http://, https://which means (it should be like this)
insert image description here
computer or other platforms. When connecting remotely, you only need to use 地址and端口号
insert image description here
insert image description here

The peanut shell management app must add a port, and then it must be turned on, that is, the green switch, and the computer configuration can also be used. After that, the management app can be closed, and then open the peanut shell intranet app to check whether it is connected. This intranet app It must be turned on all the time (running in the background) to ensure a constant connection
Please add a picture description

6. Set boot automatically

Look here ===>> https://blog.csdn.net/weixin_45853881/article/details/126930875

Seven. Build a database

Look here ====>> https://blog.csdn.net/weixin_45853881/article/details/126940611

8. Backup and restore of Termux

Look here ====>> https://blog.csdn.net/weixin_45853881/article/details/127427339
insert image description here
Exceeding the limit, I am poor and cannot afford the package.

I have a well-configured cetos system here, and it can be used directly after Russian recovery. It has been uploaded
to csdn, free of charge, and you can download it directly if you need it. /86795325
insert image description here

Guess you like

Origin blog.csdn.net/weixin_45853881/article/details/126864672