将win共享目录挂载到linux 利用远程PHP-CGI调试本地代码

2023-06-12,,

最近需要在win上做几个PHP项目,但又不想在win上搭建各种运行环境,正好局域网中有一台LINUX,所以将项目所需的环境全装在LINUX上,本地win上只需要一个NGINX做代理即可。

实现方式如下:

WIN:192.168.0.107

LINUX:192.168.0.108

一、在win下创建PHP项目目录c:/web,并设置为共享文件夹,共享名为web

二、登录LINUX将WIN共享目录挂载到/mnt/web

mount -t cifs //192.168.0.107/web /mnt/web -o username=jxh,password=jxh,noserverinfo

三、修改PHP-FPM监听IP及端口

vim /usr/local/webserver/php/etc/php-fpm.conf

listen = 192.168.0.108:9000   #默认的127.0.0.1:9000不支持远程访问

四、在WIN上配置NGINX

server {
        listen       80;
        server_name  localhost;

        location / {
            root   C:/web;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        location ~ \.php$ {
            root           /mnt/web;
            fastcgi_pass   192.168.0.108:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /mnt/web$fastcgi_script_name;
            include        fastcgi_params;
        }

}

五、启动NGINX,使localhost可访问c:/web/中的php代码