mac用brew安装的nginx与docker中的php配合,比较坑的地方

问题:FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream,

此类问题一般都是nginx配置访问的目录不对。因为nginx访问的是本地文件,而php是在docker里面访问不到本地路径,应在nginx的配置文件中改一下root

location ~ \.php$ {
        #php-fpm映射在本机的端口号
        fastcgi_pass   127.0.0.1:9002;
        fastcgi_index  index.php;
        # php在docker可访问的项目目录
        root /var/www/html/shiziyuduliban172/shiziyuduliban172/backend;

问题:*453 open() "/var/www/html/xxxxx/Themes/Seller/Public/css/bootstrap.css" failed (2: No such file or directory), client: 127.0.0.1

此类问题是因为nginx在访问静态资源的时候不需要通过php-fpm所以没必要去写docker里面的路径。要在server去定义一个root 指向本机的项目地址,例如:

server{
    listen       80;
    server_name  xxx.com;
	autoindex on;
    access_log  /tmp/logs/access_community.log;
    error_log /tmp/logs/error_community.log;
    root /Users/YourName/Documents/phpWorks/xxxx/backend;

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值