源来页 公告 登陆

termux运行nginx+php经验

南墙 @Ta
2025-09-01 08:33

借鉴:termux运行nginx+php
【termux配置nginx+php - CSDN App】
nginx启动命令
nginx
nginx -s reload
killall nginx
killall php-fpm

1。安装php和 php-fpm
pkg install php
pkg install php-fpm

2。执行两次php-fpm
复制文件路径:
/data/data/com.termux/files/usr/var/run/php-fpm.sock
3。修改nginx配置文件
vim /data/data/com.termux/files/usr/etc/nginx/nginx.conf
找到类似下面的去掉前面注释,修改成如下
location ~ \.php$ {
            root           html;
            fastcgi_pass   unix:/data/data/com.termux/files/usr/var/run/php-fpm.sock;                                   
            fastcgi_index  index.php; 
            fastcgi_param  SCRIPT_FILENAME  /sdcard/project$fastcgi_script_name;                                        
            include        fastcgi_params;
        }

4。重启nginx 
在安卓0目录下创建project文件夹,并将index.php放入
/storage/emulated/0/project/index.php
访问http://127.0.0.1:18080即可


过程中遇到的问题
1.An error occurred.
只能以默认用户运行,不知道怎么解决执行php-fpm两次,突然就好了。
2.NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
[01-Sep-2025 17:06:55] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root

正常常通知[非错误],再次执行php-fpm

最后编辑:2025-09-01 17:24
阅:307 发表于2025-09-01 08:33
#Linux
评论:

返回源来页/返回首页


天合之作 曲在人意

心灵鸡汤:
      

®2019-2026 all power by Zlproject3.8
川公网安备 51192202000151号
蜀ICP备2021014921号-2 首页 #top

本网站由edge one提供CDN加速服务

天合之作 曲在人意