Android/Hongmeng mobile phones use termux to install mariaDB, Centos is equipped with jdk, and Tomcat is used to create a personal mobile server.

Article directory

  • Preface
  • 1. Preparation work
  • 2. Prepare the installation package
  • 3. Install termux
  • 4. Install Centos using termux (too much nonsense, let’s start the real installation)
  • 5. Upload and decompress tomcat and jdk (it is recommended to operate on a computer)
  • 6. Centos configures jdk and Tomcat environment (start Centos first)
  • 7. Install mariaDB under termux (the installation of mysql in Centos failed)
  • 8. Install cpolar under termux (public network secure remote connection, intranet penetration)
  • 9. Display

Foreword

  • Android/Hongmeng mobile phone uses termux to install mariaDB, Centos

  • Centos is equipped with jdk, and Tomcat is used to create a personal mobile server.

  • I originally wanted to put the database on Centos, but the installation failed, which was embarrassing…

  • I had to put the database on termux (it works for personal testing, but the performance is poor)

  • Termux comes with jdk. You should be able to put Tomcat on termux. Try again when you have time.

  • The following actions are purely mobile phone operations (it is much more convenient to install openssh and connect to the computer, type commands, copy, paste, and decompress)

  • Reference article

  • https://blog.csdn.net/m0_61581389/article/details/123201462

  • https://blog.csdn.net/m0_63684

  • https://blog.csdn.net/weixin_45853881/article/details/126940611

  • https://blog.csdn.net/qq_48652579/article/details/130982404

1. Preparation

  • Charge your mobile phone
  • Back up mobile phone data first
  • -Back up mobile phone data first
  • -Back up mobile phone data first (say important things three times)

2. Prepare installation package

Termux installation package: termux-app_v0.118.0 + github-debug_arm64-v8a.apk
jdk compressed package: jdk-8u301-linux-aarch64.tar.gz
Tomcat compressed package: apache-tomcat-9.0.80.tar.gz
Download to the download directory of your mobile phone
Link: https://pan.baidu.com/s/1-btv8HHbo8IkOgKzU3EQwg
Extraction code: 1122

3. Install termux

  • Direct installation on mobile phone: termux-app_v0.118.0 + github-debug_arm64-v8a.apk

  • Introduction to termux command:

  •  Shortcut key table
     Ctrl + A -> Move the cursor to the beginning of the line
     Ctrl + C -> Abort current process
     Ctrl + D -> Log out of terminal session
     Ctrl + E -> Move cursor to end of line
     Ctrl + K -> Delete from cursor to end of line
     Ctrl + U -> Delete from cursor to beginning of line
     Ctrl + L -> Clear Terminal
     Ctrl + Z -> Suspend (send SIGTSTP to) the current process
     Ctrl + alt + C -> Open new session (only for Hacker Keyboard)
     Volume up + E -> Esc key
     Volume up + T -> Tab key
     Volume plus + 1 -> F1 (Volume plus + 2 → F2...and so on)
     Volume plus + 0 -> F10
     Volume + B -> Alt + B, returns a word when using readline
     Volume + F -> Alt + F, forward a word when using readline
     Volume Plus + X -> Alt + X
     Volume Plus + W -> Up Arrow Key
     Volume Plus + A -> Left Arrow
     Volume up + S -> Down arrow key
     Volume Plus + D -> Right Arrow Key
     Volume plus + L -> | (pipe character)
     Volume plus + H -> ? (tilde character)
     Volume plus + U -> _ (underline character)
     Volume plus + P -> Previous page
     Volume plus + N -> Next page
     Volume plus + . -> Ctrl + \(SIGQUIT)
     Volume plus + V -> Show volume control
     Volume + Q -> Switch the displayed function key view
     Volume + K -> Toggle displayed function key view
     basic commands
     pkg search [package name] # Search package
     pkg install [package name] # Installation package
     pkg uninstal [package name] # Uninstall package
     pkg reinstall [package name] # Reinstall the package
     pkg update [package name] # Update source
     pkg upgrade # Upgrade software package
     pkg list-all # List all packages available for installation
     pkg list-installed # List installed packages
     pkg show # Display detailed information of a package
     pkg files # Display the related folder path of a package
     dpkg -l # View installed packages
     man dpkg View detailed documentation
     cp #copy #cp -r /home/___/file1.txt /home/___
     mv #Move, rename #mv /home/___/file1.txt /home/___
     rm #Delete (use with caution) #rm -rf /home/___
     tar #decompression #tar -xvf ___.tar.gz /home/___
     mkdir #Create folder #mkdir software
     chmod #File-level permissions #chmod -R 777 /home/___
     ps #process snapshot #ps -ef
    
  • termux interface directory:
    Interface

  • Directory Structure:

     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
    
  • Basic operations

     Zoom text
     Use two fingers to zoom in or out
     Long press the screen
     ├── COPY: # copy
     ├── PASTE: # Paste
     ├── More: # more
     ├── Select URL: # Extract all URLs on the screen
     └── Share transcipt: # Share command script
     └── Reset: # Reset
     └── Kill process: # Kill the current session process
     └── Style: # Style color matching needs to be installed by yourself
     └── Keep screen on: # Keep the screen always on
     └── Help: # Help document
     Swipe from left to right
     call out session
    
  • Install basic tools

     pkg update
     pkg install vim curl wget git tree proot tar openssh nmap php php-fpm nginx -y
    
  • Terminal color scheme

     sh -c "$(curl -fsSL https://github.com/Cabbagec/termux-ohmyzsh/raw/master/install.sh)" or
     sh -c "$(curl -fsSL https://html.sqlsec.com/termux-install.sh)"
    
  • Mount mobile phone storage

     termux-setup-storage
    
  • Set color style:

     Enter the chcolor command to change the color style, or execute the ~/.termux/colors.sh command
    
  • Set font

     Run the chfont command to change the font, or execute the ~/.termux/fonts.sh command
    
  • zsh theme color matching (edit the .zshrc configuration file in the home directory)

     $ vim .zshrc
    
  • Modify startup greeting

     vim $PREFIX/etc/motd
    
  • backup

     termux-setup-storage
     cd /data/data/com.termux/files
     tar -zcf /sdcard/termux-backup.tar.gz home usr
    
  • recover

     termux-setup-storage
     cd /data/data/com.termux/files
     tar -zxf /sdcard/termux-backup.tar.gz --recursive-unlink --preserve-permissions
    

4. Install Centos with termux (too much nonsense, let’s start the real installation)

  • After installing termux, you need to change the source (Termux uses foreign mirror sources by default. Accessing foreign servers in China will be very slow or even impossible to connect, so you need to change the mirror source to China’s Tsinghua mirror source)
sed -i 's@^\(deb.*stable main\)$@#\1\
deb https://mirrors.tuna.tsinghua.edu.cn/termux/termux-packages-24 stable main@ ' $PREFIX/etc/apt/sources.list

sed -i 's@^\(deb.*games stable\)$@#\1\
deb 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\
deb https://mirrors.tuna.tsinghua.edu.cn/termux/science-packages-24 science stable@' $PREFIX /etc/apt/sources.list.d/science.list

pkg update
  • View the list of optional sources (the interface is for reference only, the above operation is the actual source replacement)
termux-change-repo


  • Install basic tools (the update installation will take a while, and the installation update will ask you to enter y to confirm)
pkg update & amp; & amp; pkg upgrade
pkg install vim curl wget git tree proot tar nmap python -y
 #Function: vim editor, curl download, wget download, git, tree, proot administrator identity, tar decompression, nmap, python
  • Install Centos (wait patiently)
    Pulling resources from github will be a bit slow and may not be connected. Solution:
    Modify the /etc/hosts file and add the IP address of GitHub. If you don’t have permission, authorize it (as an administrator).
termux-chroot
cd /etc
ls -l
chmod 777 hosts
vim hosts
#Edit hosts, enter i (edit mode, add the following content), press ESC to exit edit mode (reading mode)

20.205.243.166github.com
192.30.253.112 github.com
140.82.113.4github.com
103.224.182.241github.com
140.82.114.4 gist.github.com
192.30.253.119 gist.github.com
151.101.100.133 assets-cdn.github.com
151.101.100.133 raw.githubusercontent.com
151.101.100.133 gist.githubusercontent.com
#Enter colon wq (:wq) to save and exit
  • Pull resources from github (just pull it a few times. If you see the termux-install-linux folder, it means the pull is successful, and then use python to install it)
git clone https://github.com/sqlsec/termux-install-linux
cd ~
ls -l
cd termux-install-linux
python termux-linux-install.py

Enter 7 to install Centos

  • Start Centos
cd ~/Termux-Liux/CentOS/
./start-centos.sh
  • Check Centos version
cat /etc/redhat-release
exit #Exit the system

5. Upload and decompress tomcat and jdk (it is recommended to operate on a computer)

  • Mount the mobile phone storage (termux-setup-storage, read files in the mobile phone), copy to software, and unzip
cd ~/Termux-Liux/CentOS/
chmod +w centos-fs
cd centos-fs
mkdir software
cd ~
termux-setup-storage
cd ~/storage/downloads/
cp -r apache-tomcat-9.0.80.tar.gz ~/Termux-Linux/CentOS/centos-fs/software/
cp -r jdk-8u301-linux-aarch64.tar.gz ~/Termux-Linux/CentOS/centos-fs/software/
#Unzip, move to...
tar -xvf apache-tomcat-9.0.80.tar.gz ~/Termux-Linux/CentOS/centos-fs/usr/local/tomcat
tar -xvf jdk-8u301-linux-aarch64.tar.gz ~/Termux-Linux/CentOS/centos-fs/usr/local/jdk

6. Centos configures jdk and Tomcat environment (start Centos first)

  • Configure JAVA_HOME environment variable
  • -Edit the /etc/profile file
vim /etc/profile
#Insert the following content at the end of the file (PgDn key to turn pages)
export JAVA_HOME=/usr/local/jdk
export PATH=$PATH:$JAVA_HOME/bin
#Delete the java program that comes with the system (you can ignore this command if it does not come with it)
#-f /usr/bin/java
#Soft link to the java program we installed ourselves
#-s /export/server/jdk/bin/java /usr/bin/java
source /etc/profile
  • Perform verification:
java-version
javac-version
  • Start tomcat, (it seems that there is no need to configure a firewall)

     Enter the tomcat/bin directory and execute ./startup.sh
    

7. Install mariaDB under termux (the installation of mysql in Centos failed)

  • Install

     Install in the home directory. If you boot into the environment, please use exit to exit the environment.
    
pkg install mariadb -y
  • start up

     Note: The mysql program is divided into server and client. The server is mysqld and the client is mysql.
    
nohup mysqld > mysql.log & amp;
  • Configuration
mysql -hlocalhost -uroot -p
use mysql;
set password for 'root'@'localhost' = password('root');
grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
flush privileges;

8. Install cpolar under termux (public network secure remote connection, intranet penetration)

pkg install cpolar
pkg install termux-services
  • Install the termux service. Note: After the installation is complete, remember to close and restart termux for it to take effect.
sv up cpolar
sv-enable cpolar

9. Display

  • The phone screen is too small, let’s see how it looks on an Android tablet