0
votes

i successfully created a php_apache image by going to the specified directory with following command docker build -t php_apache

my docker file is

FROM php:7.4-apache
COPY Php_demo_project/ var/www/html/
EXPOSE 80

but while running the image with following command

docker run -it --rm --name php_demo_container -p 80:80 php_apache

am unable to get the page in browser, and when I search for localhost 404 forbidden access like showing enter image description here

when I enter localhost in chrome in command line it is showing as

[Wed Jun 24 01:29:19.895025 2020] [autoindex:error] [pid 16] [client 172.17.0.1:42010] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive

172.17.0.1 - - [24/Jun/2020:01:29:19 +0000] "GET / HTTP/1.1" 403 491 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36"

am unable to find where the error is.. what am I missing?????????

2
can you try COPY Php_demo_project/* var/www/html/ i mean, instead of copying whole folder, just copy the folder content to var/www/htmlTaybur Rahaman
@TayburRahaman , again not showing the page in browser after writing COPY Php_demo_project/* var/www/html/shiva7890

2 Answers

0
votes

Make sure your files have read access rights:

FROM php:7.4-apache
COPY Php_demo_project/ /var/www/html/
RUN chmod -R a+r /var/www/html/
EXPOSE 80
0
votes

I think this will help you:

FROM php:7.4-apache
COPY Php_demo_project/ /var/www/html
RUN chown -R www-data:www-data /var/www
EXPOSE 80