dousidan1279 2019-03-29 11:42
浏览 317

我可以在主机上使用NginX,在docker容器中使用多个版本的PHP

I found a similar question here but it didn't quite answer my question.

I've always installed my stack locally for development, NginX, PHP7, MySQL, and Couchbase. No Problems.

Now I have to work on a project that requires a lower version of PHP... And my team will have to work on it as well, so I've looked to Docker to try to find the solution.

In my existing NGINX conf files I send the requests off to php-fpm like this

   location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  
        $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_ignore_client_abort on;
        fastcgi_param  SERVER_NAME $http_host;
    }

See the line

fastcgi_pass   127.0.0.1:9000;

?

I was hoping to be able to create a docker container running a specific version of PHP and write it into the server block as above but with

fastcgi_pass   172.17.0.1:9000;

Where 172.17.0.1 is the IP of the container.

I have used, very simply,

FROM php:7.1-fpm
EXPOSE 9000

As my dockerfile. I can build an image, run the container, run bash in the container and see that PHP -I and PHP -v return what I expect.

Running docker inspect has given me two IP addresses, 172.17.0.1, and 172.17.0.2 (I've tried both in the example above)

However, this set up is not working - when I try to visit the site in a browser I get an NGINX 504 gateway timeout error.

Guessing I'm missing something, but not sure what.

Happy to use docker compose if I need to, happy to mount volumes into the container if I need to. Just not sure what I need!:)

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条
    • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
    • ¥15 perl MISA分析p3_in脚本出错
    • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
    • ¥15 ubuntu虚拟机打包apk错误
    • ¥199 rust编程架构设计的方案 有偿
    • ¥15 回答4f系统的像差计算
    • ¥15 java如何提取出pdf里的文字?