LAMP-Stack with Docker:如何修改httpd.conf以访问PHP-FPM?

我从apache容器访问Php-fpm时遇到一些麻烦。 我的docker-compose文件准备好了,工作正常。 但我不知道如何修改httpd.conf以便在两个容器(Apache和Php-fpm)之间建立通信。 我在互联网上寻找了一些有用的教程,但每个人都使用Nginx而不是Apache2。 还有一个预配置的Docker镜像,由Docker Hub上的Apache webserver和Php-fpm组成,但由于可替换性,我更喜欢两个分离的图像。</ p>

这是我的docker-compose文件: </ p>

  version:“3.5”

services:
webserver:
build:apache /
ports:

  • “8080:80”
  • “ 443:443“ 卷:
  • 〜/ Docker-Images / example / apache / html:/ usr / local / apache2 / htdocs links:
  • php-fpm

    php-fpm:\ n build:php-fpm /
    ports:

  • “9000:9000”
    links:

  • 数据库

数据库:
build:mysql /
ports:

  • “3306 :3306“ 卷:
  • 〜/ Docker-Images / example / mysql / init-scripts:/ init-scripts

volumes:
webserver:
database:
</ code> < / pre>

如果你需要我的httpd.conf,请告诉我! 我没有添加它,因为它是一个非常长的文件,只有默认值。</ p>
</ div>

展开原文

原文

I have some trouble to get access from my apache container to Php-fpm. My docker-compose file is ready and works fine. But I don't know how to modify the httpd.conf in order to establish communication between both containers (Apache and Php-fpm). I have looked for some useful tutorials on the internet, but everyone uses Nginx instead of Apache2. There is also a preconfigured Docker image consisting of a Apache webserver and Php-fpm on Docker Hub, but I prefer two seperated images, because of replaceability.

Here is my docker-compose file:

version: "3.5"

services:
  webserver:
    build: apache/
    ports:
           - "8080:80"
           - "443:443"
    volumes: 
             - ~/Docker-Images/example/apache/html:/usr/local/apache2/htdocs
    links: 
           - php-fpm

  php-fpm:
    build: php-fpm/
    ports:
           - "9000:9000"
    links: 
           - database


  database:
    build: mysql/
    ports: 
           - "3306:3306"
    volumes:
             - ~/Docker-Images/example/mysql/init-scripts:/init-scripts


volumes:
  webserver:
  database:

If you need my httpd.conf, let me know! I haven't added it, because it is a very long file with only default values.

dongtang1997
dongtang1997 您应该发布httpd.conf,因为它不应该只是默认值。你应该在某处指定php-fpmDNS地址。
2 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐