最近需要在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-tcifs//192.168.0.107/web/mnt/web-ousername=jxh,password=jxh,noserverinfo


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

vim/usr/local/webserver/php/etc/php-fpm.conflisten=192.168.0.108:9000#默认的127.0.0.1:9000不支持远程访问


四、在WIN上配置NGINX

server{listen80;server_namelocalhost;location/{rootC:/web;indexindex.htmlindex.htm;}error_page500502503504/50x.html;location=/50x.html{roothtml;}location~\.php${root/mnt/web;fastcgi_pass192.168.0.108:9000;fastcgi_indexindex.php;fastcgi_paramSCRIPT_FILENAME/mnt/web$fastcgi_script_name;includefastcgi_params;}}


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