4

docker 部署的 nginx PHP 找不到 PHP 文件问题

 2 years ago
source link: https://www.v2ex.com/t/846141
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

V2EX  ›  云计算

docker 部署的 nginx PHP 找不到 PHP 文件问题

  yagamil · 14 小时 27 分钟前 · 274 次点击

搜了不少资料,还没有没有解决问题。

docker run --name my-php-fpm -v D:/www:/www -d php:7.3-fpm

docker run --name my-nginx -p 8080:80 -d \
    -v D:/www:/usr/share/nginx/html:ro \
    -v D:/conf/conf.d:/etc/nginx/conf.d:ro \
    --link my-php-fpm:php \
    nginx

nginx 配置文件

server {
    listen       80;
    server_name  localhost;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm index.php;
    }

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

    location ~ \.php$ {
        fastcgi_pass   php:9000; #启动 nginx 容器时--link my-php-fpm:设置的值 php
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}

index.php 内容

<?php
echo phpinfo();

浏览器打开 http://localhost:8080/index.php

提示找不到文件,在请求头看到的服务器是 php ,应该是 php 那边没有找到文件?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK