user5558501
user5558501

Reputation:

Run Docker PHP-apache: Forbidden You don't have permission to access / on this server

I have a folder: my-php-app and it contains a Dockerfile and a src/ folder. The Dockerfile is very simple:

FROM php:5.6-apache
COPY config/php.ini /usr/local/etc/php/
COPY src/ /var/www/html/

My src/ contains an index.php The index.php contains

<html>
 <body>
 <?php echo '<p>Hello World!</p>'; ?> 
 </body>
</html>

I did the following:

docker build -t my-php-app .

The new image was generated successfully. Now I want to start a container from that image:

docker run -d -p 80:80 my-php-app

But when I'm visiting my localhost:80 I see:

Forbidden

You don't have permission to access / on this server.

So my question is: How do I have to start my container properly? What am I doing wrong here.

Upvotes: 15

Views: 22133

Answers (2)

Projenix
Projenix

Reputation: 147

You could also just "chown -R" your files to www-data instead of your local username!

Upvotes: -1

Thomasleveil
Thomasleveil

Reputation: 103985

You are not sharing your php.ini file, so I tried using the default production one provided by the PHP project and using that config file, I was able to run your project fine.

I suspect your issue lies there.

Upvotes: 9

Related Questions