donglinxia1541 2017-09-20 22:57 采纳率: 0%
浏览 764

在一个dockerfile中结合PHP-fpm和nginx

我需要将php-fpm与nginx结合在一个dockerfile中进行生产部署。

所以更好的方法是:

(1)使用php:7.1.8-fpm启动dockerfile,然后在其之上安装nginx映像层?

(2)还是建议使用Nginx映像,然后使用apt-get安装php-fpm?

PS:我没有用于生产部署的docker-compose构建选项。 在我的开发环境中,我已经使用docker-compose并从两个映像轻松构建多容器应用程序。 我们的组织开发人员不支持针对产品环境的基于docker-compose的部署。

  • 写回答

2条回答 默认 最新

  • doudao9896 2017-09-20 23:28
    关注

    You should deploy two container, one with fpm, the other with nginx, and you should link them. Even though you can use supervisor in order to monitore multiple processes within the same container, Docker philosophy is to have one process per container.

    Something like:

    docker run --name php -v ./code:/code php:7-fpm
    docker run --name nginx -v ./code:/code -v site.conf:/etc/nginx/conf.d/site.conf --link php nginx:latest
    

    With site.conf with

    server {
        index index.php index.html;
        server_name php-docker.local;
        error_log  /var/log/nginx/error.log;
        access_log /var/log/nginx/access.log;
        root /code;
    
        location ~ \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass php:9000;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param PATH_INFO $fastcgi_path_info;
        }
    }
    

    (Shamefully inspired by http://geekyplatypus.com/dockerise-your-php-application-with-nginx-and-php7-fpm/)

    评论

报告相同问题?

悬赏问题

  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常
  • ¥15 关于风控系统,如何去选择
  • ¥15 这款软件是什么?需要能满足我的需求
  • ¥15 SpringSecurityOauth2登陆前后request不一致