pc用ssh连接Termux

电脑和手机都要安装sshd服务并开启

#pc
##电脑生成密匙,无脑回车
ssh-keygen -t rsa
##电脑也开启sshd服务,待会使用手机的ssh连接到电脑拷贝id_rsa.pub内容
systemctl start sshd
#phone
##手机连接拷贝
ssh lxx@192.168.1.18 "cat ~/.ssh/id_rsa.pub" >> $HOME/.ssh/authorized_keys
##查看手机的用户名
whoami
##开启服务
sshd
#pc
连接到手机
ssh u0_a282@192.168.1.14 -p 8022

运行nginx

#安装
pkg install nginx
#启动
nginx
#停止(以端口进行停止)
fuser -k 8080/tcp
#重启
nginx -s reload
#查看占用端口(默认是8080)
netstat   -anp   |   grep nginx
#查看所有TCP端口
netstat   -anp   |   grep tcp
#得到
$ netstat   -anp   |   grep tcp
netstat: showing only processes with your user ID
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      14253/nginx: master
tcp        0      0 0.0.0.0:8022            0.0.0.0:*               LISTEN      8847/sshd
tcp        0      0 0.0.0.0:40790           0.0.0.0:*               LISTEN      -
tcp        0      0 192.168.1.14:45872      222.211.90.180:5062     ESTABLISHED -
tcp        0      0 192.168.1.14:8080       192.168.1.18:51712      FIN_WAIT2   -
tcp      405      0 192.168.1.14:48054      118.89.204.100:443      CLOSE_WAIT  -
tcp        0     92 192.168.1.14:8022       192.168.1.18:41742      ESTABLISHED 12276/sshd

配置

#/home路径
cd $HOME
#/路径
cd $PREFIX

MariaDB(MySQL) 安装

#安装
pkg install mariadb
#初始化数据
mysql_install_db
#启动(这里需要使用screen来创建新的回话启动,以为启动mysql会启动日志模式)
mysqld
#修改密码(因为是空密码, 这里默认回车在输入密码)
mysql_secure_installation
#其他
    Remove anonymous users? [Y/n] Y                #是否移除匿名用户
    Disallow root login remotely? [Y/n] n          #是否不允许root远程登录
    Remove test database and access to it? [Y/n] n #是否移除test数据库
    Reload privilege tables now? [Y/n] y           #是否重新加载表的权限
#登录
mysql -uroot -p

安装php

#安装3个
pkg install php php-cgi php-fpm

配置nginx使用php-fpm

#编辑
nano $PREFIX/etc/php-fpm.d/www.conf
#修改listen = /data/data/com.termux/files/usr/var/run/php-fpm.sock为:
listen = 127.0.0.1:9000

#编辑
nano $PREFIX/etc/nginx/nginx.conf
$取消注释
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}
#默认的网站目录
cd /data/data/com.termux/files/usr/share/nginx/html
#新建index.php文件
<?
phpinfo();
#启动配置
##模拟root
pkg install proot
termux-chroot
#启动服务
php-fpm
nginx

猜你喜欢

转载自blog.csdn.net/HD2killers/article/details/81512491
今日推荐