一、安装 Termux
在手机上安装 Termux,并启动。
1、安装基础软件包
$ pkg install vim curl wget openssh
2、启动 ssh
3、查看当前系统帐号
4、设置登录密码
5、使用 ssh 客户端工具连接
默认端口:8022
6、解决锁屏断网问题
命令输完后,在手机上允许。
7、设置自动开启 ssh,并解决锁屏断网问题
8、允许访问手机存储
命令输完后,在手机上允许。
9、更换清华大学镜像源
$ pkg update
10、升级版本
11、解决 vim 右键复制粘贴问题
添加如下内容:
二、安装 mysql
默认端口:3306
1、启动 mysql
2、停止 mysql
3、登录 mysql
以当前系统用户身份登录 mysql,没有密码。
(1)查看用户
(2)设置 root 密码
MariaDB [mysql]> set password for 'root'@'localhost'=password('p2022#DBA');
MariaDB [mysql]> grant all on *.* to root@'%' identified by 'p2022#DBA' with grant option;
MariaDB [mysql]> flush privileges;
MariaDB [mysql]> quit
(3)使用 root 帐号登录 mysql
三、安装 nginx
默认端口:8080
1、启动 nginx
2、停止 nginx
四、安装 php7-fpm
1、配置 php7-fpm
定位到 listen,即如下一行:
修改为:
2、配置 nginx
定位到如下几行代码,标红为新增处:
root /data/data/com.termux/files/usr/share/nginx/html;
index index.html index.htm index.php;
}
定位到如下几行代码,标红为修改处:
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/data/com.termux/files/usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}
3、添加测试页
网站的根目录默认为:$PREFIX/share/nginx/html。当然,可以通过上述 nginx 配置文件进行修改。
在根目录下添加一个 info.php 文件,内容如下:
phpinfo();
4、测试
先启动 php-fpm,再启动 nginx:
$ nginx
访问测试页:http://IP:8080/info.php
五、修改 nginx 配置
为了方便部署,在家目录下进行如下操作:
1、创建网站目录、日志存放目录
$ mkdir -pv weblogs
2、创建 nginx 配置文件目录的软链接
3、创建站点配置文件存放目录
4、修改 nginx 配置文件
$ vi nginx/nginx.conf
内容如下:
worker_processes 1;
error_log /data/data/com.termux/files/home/weblogs/error.log crit;
pid /data/data/com.termux/files/home/weblogs/nginx.pid;
worker_rlimit_nofile 51200;
events {
worker_connections 51200;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
client_header_timeout 15;
client_body_timeout 15;
reset_timedout_connection on;
send_timeout 15;
server_names_hash_bucket_size 512;
client_header_buffer_size 128k;
large_client_header_buffers 4 128k;
client_max_body_size 2000M;
client_body_buffer_size 128K;
types_hash_max_size 2048;
fastcgi_intercept_errors on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 128k;
fastcgi_buffers 8 128k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
include vhosts/*.conf;
gzip on;
gzip_disable "msie6";
gzip_proxied any;
gzip_min_length 1k;
gzip_buffers 16 64k;
gzip_http_version 1.1;
gzip_comp_level 6;
gzip_types text/plain text/css application/javascript text/javascript application/json application/x-javascript text/xml application/xml application/xml+rss;
gzip_vary on;
}
5、创建站点配置文件
内容如下:
server {
listen 8080;
server_name localhost;
access_log /data/data/com.termux/files/home/weblogs/127.0.0.1_access.log main;
error_log /data/data/com.termux/files/home/weblogs/127.0.0.1_error.log crit;
ssi on;
ssi_silent_errors on;
ssi_types text/shtml;
error_page 403 /403.html;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location / {
root /data/data/com.termux/files/home/websites;
index index.html index.htm index.php;
}
location = /50x.html {
root /data/data/com.termux/files/home/websites;
}
location = /403.html {
root /data/data/com.termux/files/home/websites;
allow all;
}
location = /404.html {
root /data/data/com.termux/files/home/websites;
}
location ~ \.php$ {
root /data/data/com.termux/files/home/websites;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/data/com.termux/files/home/websites$fastcgi_script_name;
include fastcgi_params;
}
}
Copyright © 2005-2023 by www.ricensoftwares.com.cn All Rights Reserved.