1

I'm trying to use docker but I have a lot of problem. Now i Want to use an apache container and use a volume of my php

my images are

  • nimmis/apache
  • 5.6-fpm

my docker ps is:

85e592d46fcc        nimmis/apache       "/my_init"               3 minutes ago       Up 3 minutes        0.0.0.0:8080->80/tcp   apacheBarno
c9bc486563bc        php:fpm             "php-fpm"                15 minutes ago      Up 15 minutes       9000/tcp               app_php

and I Started my apache with this command

docker run --name apacheFoo --volumes-from app_php -p 8080:80 -v `pwd`:/var/www/html --rm nimmis/apache

When I visit http://192.168.99.100:8080/ ( im on mac ) I can see the apache page.

when I visit http://192.168.99.100:8080/index.php I get <?php echo "hello" ?>

instead of "hello"

5
  • Is the php enable? It looks like the server serves the webpage as it instead of executing it. Commented Jun 11, 2016 at 17:38
  • @Auzias, sorry but I don't understand Commented Jun 11, 2016 at 18:01
  • @monkeyUser You may benefit from trying one of the non-english stackoverflow sites. Commented Jun 12, 2016 at 0:09
  • See the answers. Apache does not support PHP if the PHP support is not installed or enabled. Commented Jun 12, 2016 at 8:03
  • Why don't you use the official php image (php:5-apache)? Commented Jun 12, 2016 at 22:04

2 Answers 2

2

The reason of the behavior is that the apache image you are using (https://hub.docker.com/r/nimmis/apache/, right?) is a plain apache without php support. So it just serves your php code as plain text.

You don't need two images in this case. Instead you need one image running Apache with php module. You can use the official php image (https://hub.docker.com/_/php/).

Your Docker file can look like this:

```
# see https://hub.docker.com/_/php/
FROM php:5.6-apache

# copy your source into the /var/www/html inside the container
COPY . /var/www/html/
```

Now you can build and run it like this

```
docker build -t apache-foo-docker .
docker run -d -p 8080:80 -v $(pwd):/var/www/html --name apacheFoo apache-foo-docker
```
Sign up to request clarification or add additional context in comments.

Comments

0

I guess you are trying to serve PHP with generic apache image. PHP pages should be interpreted on the server side, which is apache in your case. This means apache (and its container) should have PHP configured and enabled. Maybe you could try https://hub.docker.com/r/nimmis/apache-php5/ instead?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.