0

first of all i pulled apache image:

docker pull httpd

then i ran my apache on 8080 port

docker run -dit --name httpd -p 8080:80 -v "$PWD":/usr/local/apache2/htdocs/ httpd

i opened 127.0.0.1:8080 and it is ok i have a file named info.php and it exists in PWD and when i open it in my browser i see php code and it had not been compiled

how can it use php and apache together in docker and how i am able to run php in my browser

im new comer to docker

1 Answer 1

1

you can use this image php:<version>-apache

php:-apache

This image contains Debian's Apache httpd in conjunction with PHP (as mod_php) and uses mpm_prefork by default.

docker run -d -p 80:80 --name my-apache-php-app -v "$PWD":/var/www/html php:7.2-apache

Or you can copy PHP files at build times.

Tree

├── Dockerfile
└── src
    └── info.php

Dockerfile

FROM php:7.2-apache
COPY src/ /var/www/html/

Run container

docker run -d -p 80:80 --name my-apache-php-app my_image
Sign up to request clarification or add additional context in comments.

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.