ARTICLE · 1299698
Termux安装PHP和nginx配置网站教程,全命令操作
Termux安装PHP和nginx配置网站教程,全命令操作第一步,更新软件包 pkg update && pkg upgrade -y 第二步,改写清华源 sed -i 's|deb https://packages-cf.termux.dev/apt/termux-main/ stable main|#deb https://packages-cf.termux.dev/apt/termux-main/ stable main\ndeb https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-main stable main|g' $PREFIX/etc/apt/sources.list 第三步,安装PHP和nginx pkg install nginx php php-fpm -y 第四步,获取手机外部存储权限 termux-setup-storage 第五步,写入网站目录配置,多网站配置,提前在手机文件管理器里建好对应的网站文件夹 echo 'worker_processes 1;events{worker_connections 1024;}http{include mime.types;default_type application/octet-stream;sendfile on;keepalive_timeout 65;server{listen 8001;listen [::]:8001;server_name localhost;root /storage/emulated/0/007;index index.html index.htm index.php;location /{}location ~ \.php$ {fastcgi_pass unix:/data/data/com.termux/files/usr/var/run/php-fpm.sock;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}}server{listen 8004;listen [::]:8004;server_name localhost;root /storage/emulated/0/006;index index.html index.htm index.php;location /{}location ~ \.php$ {fastcgi_pass unix:/data/data/com.termux/files/usr/var/run/php-fpm.sock;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}}server{listen 8002;listen [::]:8002;server_name localhost;root /storage/emulated/0/008;index index.html index.htm index.php;location /{}location ~ \.php$ {fastcgi_pass unix:/data/data/com.termux/files/usr/var/run/php-fpm.sock;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}}server{listen 8003;listen [::]:8003;server_name localhost;root /storage/emulated/0/009;index index.html index.htm index.php;location /{}location ~ \.php$ {fastcgi_pass unix:/data/data/com.termux/files/usr/var/run/php-fpm.sock;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}}}' > $PREFIX/etc/nginx/nginx.conf 第六步,设置开机自启动,PHP和nginx echo -e "\n# Auto start nginx + php-fpm\npgrep php-fpm >/dev/null || php-fpm -D\npgrep nginx >/dev/null || nginx" >> ~/.bashrc 第七步,重启Termux网站生效 第八步,把对应的PHP文件放到对应的网站文件夹目录















































































