zoukankan      html  css  js  c++  java
  • 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.101\Downloads" -U 账号%密码
    smbclient //192.168.1.101/Downloads -U 账号%密码 -W domain

    安装mariadb
    pkg isntall mariadb
    mysql_install_db
    You can start the MariaDB daemon with:
    cd '/data/data/com.termux/files/usr' ; /data/data/com.termux/files/usr/bin/mysqld_safe --datadir='/data/data/com.termux/files/usr/var/lib/mysql'

    You can test the MariaDB daemon with mysql-test-run.pl
    cd '/data/data/com.termux/files/usr/mysql-test' ; perl mysql-test-run.pl

    关闭数据库

     mysqladmin shutdown -p

    查看mysql状态

    mysqld status

    查看mysql进程

    ps aux|grep mysql

     mariadb 刚创建的时候没有密码,无法登录,需要先执行mysql进入命令,

    然后执行 SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');

    alter user 'root'@'localhost' IDENTIFIED BY 'YourPassword';

     启动mysql

    mysqld

    直接使用php内置服务发布

     php -S 0.0.0.0:8080 -t ./www

    启动php
    php-fpm
    关闭php
    killall php-fpm

    查看端口占用情况

     netstat -tunlp |grep 8000

  • 相关阅读:
    写一些,给2013
    C# DateTime变量不能赋null值
    31222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222
    王爽《汇编语言》第三版 第十五章 外中断
    王爽《汇编语言》第三版 第十四章 端口
    王爽《汇编语言》第三版 第十二章 内中断
    王爽《汇编语言》第三版 第十一章 标志寄存器
    王爽《汇编语言》第三版 第十章 call和ret指令
    王爽《汇编语言》第三版 第九章 转移指令的原理
    王爽《汇编语言》第三版 第八章 数据处理的两个基本问题
  • 原文地址:https://www.cnblogs.com/jisikeji/p/15498835.html
Copyright © 2011-2022 走看看