简体   繁体   English

运行Docker PHP-apache:禁止您无权访问此服务器上的/

[英]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. 我有一个文件夹: my-php-app ,它包含一个Dockerfile和一个src/文件夹。 The Dockerfile is very simple: Dockerfile非常简单:

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 我的src/包含一个index.php index.php包含

<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: 但是当我访问我的本地主机时:80我看到:

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. 我在这做错了什么。

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. 你没有共享你的php.ini文件,所以我尝试使用PHP项目提供的默认生产文件并使用该配置文件,我能够正常运行你的项目。

I suspect your issue lies there. 我怀疑你的问题就在那里。

您也可以将文件“chown -R”改为www-data而不是本地用户名!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM