LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Containers
User Name
Password
Linux - Containers This forum is for the discussion of all topics relating to Linux containers. Docker, LXC, LXD, runC, containerd, CoreOS, Kubernetes, Mesos, rkt, and all other Linux container platforms are welcome.

Notices


Reply
  Search this Thread
Old 03-24-2024, 01:08 PM   #1
Jason.nix
Member
 
Registered: Feb 2023
Posts: 561

Rep: Reputation: 10
Post Why Apache container can't see PHP container?


Hello,
I have two YAML files as follows:
Code:
version: '3.9'
networks:
  phpnet:
    driver: bridge
    name: My_Network
services:
  web:
    image: nginx:latest
    ports:
      - '8080:80'
    volumes:
      - ./default.conf:/etc/nginx/conf.d/default.conf
      - /var/www/html:/usr/share/nginx/html
    networks:
      - phpnet
    depends_on:
       - php-fpm
  php-fpm:
    image: php:8-fpm
    volumes:
       - /var/www/html:/usr/share/nginx/html/
       - /var/www/html:/usr/local/apache2/htdocs/
    networks:
      - phpnet
And:
Code:
version: '3.9'
networks:
  apache:
    external: true
    name: My_Network
services:
    httpd:
        ports:
            - '80:80'
        volumes:
            - /var/www/html:/usr/local/apache2/htdocs/
            - ./httpd.conf:/usr/local/apache2/conf/httpd.conf
        image: 'httpd:latest'
        networks:
            - apache
The network is also built by Docker:
Code:
# docker network list
NETWORK ID     NAME               DRIVER    SCOPE
b36954410da3   My_Network         bridge    local
385e912fff96   bridge             bridge    local
7b3a9c0ec7dd   host               host      local
fb5635eda3c3   nginx-php_phpnet   bridge    local
d851ead577b7   none               null      local
b13678883aac   redis_default      bridge    local
But:
Code:
# curl http://172.20.2.58:8080/index.php
Testing PHP-FPM on Docker.
#
# curl http://172.20.2.58:80/index.php
<?php
echo "Testing PHP-FPM on Docker."
?>
As you can see, Apache cannot compile PHP file. What is wrong?

Thank you.
 
Old 03-27-2024, 08:42 AM   #2
Jason.nix
Member
 
Registered: Feb 2023
Posts: 561

Original Poster
Rep: Reputation: 10
Hello,
This problem was solved by adding the following lines to the httpd.conf file:
Code:
LoadModule proxy_module modules/mod_proxy.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so

<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>


DocumentRoot "/usr/local/apache2/htdocs"
<Directory "/usr/local/apache2/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride None
Require all granted
</Directory>

<IfModule proxy_module>
    <FilesMatch "\.php$">
        SetHandler  "proxy:fcgi://php-fpm:9000"
    </FilesMatch>
</IfModule>
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Inside the Open Container Project: How Docker plans to unite the container market LXer Syndicated Linux News 0 06-23-2015 04:30 AM
Apache-the-program can't see directiories apache-the-user can see Dims Linux - Newbie 9 04-27-2009 12:24 PM
Please help with Apache Web Server / Apache Tomcat / PHP / Java / PHP-Java Bridge jpmad4it Linux - Server 2 01-05-2009 06:07 AM
php apache or php cgi - php learner rblampain Linux - Security 3 12-17-2004 11:10 PM
why i can see samba in NT4 but i can see in win98 jc3005 Linux - Software 0 04-23-2001 07:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Containers

All times are GMT -5. The time now is 07:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration