I'm testing the official image docker PHP:
docker run -d -p 8000:80 --name test php:7-apache
Then, I test http://localhost:8000, I find this:
Forbidden
You don't have permission to access / on this server.
What am I doing wrong?
docker run -d -p 8000:80 --name test php:7-apache -v "$PWD":/var/www/html
Go to your project folder and run the above command or replace $PWD with your project directory. -v will sync your project to the docker container.
Or create a Docker file and use copy to run your project within the container.
Any one of the above will solve your problem. The probable reason for the error is the fact that there is no project to render.
There's no hello world included with this image, /var/www/html/
is empty so there's no content to view. You need to bundle your own code in as the page on this image instructs:
We recommend that you add a custom php.ini configuration. COPY it into /usr/local/etc/php by adding one more line to the Dockerfile above and running the same commands to build and run:
FROM php:7.0-apache
COPY config/php.ini /usr/local/etc/php/
COPY src/ /var/www/html/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With