2

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?????????

shiva7890
  • 41
  • 1
  • 7
  • 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/html – Taybur Rahman Jun 24 '20 at 03:10
  • @TayburRahaman , again not showing the page in browser after writing COPY Php_demo_project/* var/www/html/ – shiva7890 Jun 24 '20 at 19:21

2 Answers2

1

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
Obsidian
  • 3,719
  • 8
  • 17
  • 30
parsa mpsh
  • 11
  • 1
0

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
Mihai
  • 9,526
  • 2
  • 18
  • 40
  • is there any manual permissions needed for chrome browser and docker – shiva7890 Jun 24 '20 at 19:31
  • my index.php file is present in Php_demo_project/src but i mention only Php_demo_project not Php_demo_project/src ,that's why the browser not found my index.php file and it is showing as forbidden access. after writing COPY Php_demo_project/src in docker file the web page is showing in browser. thank you...... – shiva7890 Jun 24 '20 at 19:47
  • That makes sense too. Glad you fixed it! – Mihai Jun 24 '20 at 19:53