一聚教程网:一个值得你收藏的教程网站

热门教程

nginx与fastcgi分离实现开发环境统一配置

时间:2022-06-30 18:37:33 编辑:袖梨 来源:一聚教程网

一 背景介绍

由于公司的工程师,每个人都有一套自己的开发环境,php版本不一致,扩展也不统一,在开发的时候很容易出现问题。

二 思考


通过nginx与fastcgi分离,让所有人都使用同一个php环境,实现环境统一。

三 准备

开发环境(windows 192.168.8.119)
fastcgi环境(linux 192.168.8.25)

四 目录挂载

# mount 本地目录至fastcgi所在服务器
# mount 用户使用nobody,保证有足够的权限 uid=99,gid=99

# 挂载
mount -t cifs -o username="[windows用户名]",password="[windows登入密码]",uid=99,gid=99 //192.168.8.119/www /mnt/192.168.8.119/www

# 解除挂载
umount /mnt/192.168.8.119/www

五 Nginx配置

# fastcgi配置

server {
    listen      80;
    server_name localhost 127.0.0.1;
    index       index.html index.htm index.php;
    root        "D:/wamp/www";
 
    location ~ \.php($|/) {
        fastcgi_pass    192.168.8.25:9000; # fastcgi服务器,注意要保护9000端口哦!
        fastcgi_index   index.php;
        fastcgi_param   SCRIPT_FILENAME  /mnt/192.168.8.119/www$fastcgi_script_name; # 注意要配置fastcgi所在服务器路径
        include         fastcgi_params;
    }
 
    error_log   nul;
    access_log  nul;
}


六 题外话


很多大牛也通过这样实现动静分离。

热门栏目