gpt4 book ai didi

php - AH01276 : Cannot serve directory/var/www/html/: No matching DirectoryIndex (index. php,index.html) 找到

转载 作者:行者123 更新时间:2023-12-02 18:38:55 26 4
gpt4 key购买 nike

我试图在 docker 容器中使用 docker-compose 获取 php:apache 服务器以工作。但是在组合之后,我收到以下错误消息:

[client 172.21.0.1:49230] AH01276: Cannot serve directory /var/www/html/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive

我的码头文件:
FROM php:7.1-apache

RUN apt-get update -y
RUN apt-get upgrade -y

RUN apt-get install -y \
adduser \
ca-certificates \
unzip \
curl \
git \
wget \
openssl

RUN docker-php-ext-install pdo_mysql

# Installiere benötigte PHP Erweiterungen
RUN apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libmcrypt-dev \
libpng12-dev \
&& docker-php-ext-install -j$(nproc) iconv mcrypt \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd

# Install bcmath
RUN docker-php-ext-install bcmath pcntl

# Install Phalcon-PHP
WORKDIR /phalcon/cphalcon

# https://github.com/phalcon/cphalcon/releases
ENV PHALCON_VERSION "v3.2.1"
RUN curl -L -o "phalcon-${PHALCON_VERSION}.tar.gz" "https://api.github.com/repos/phalcon/cphalcon/tarball/${PHALCON_VERSION}" \
&& tar -xvf "phalcon-${PHALCON_VERSION}.tar.gz" --strip 1 \
&& rm "phalcon-${PHALCON_VERSION}.tar.gz" \
&& cd /phalcon/cphalcon/build \
&& ./install

# Install Phalcon Devtools
WORKDIR /usr/local/lib/phalcon-devtools

# https://github.com/phalcon/phalcon-devtools/releases
ENV PHALCON_DEVTOOLS_VERSION "v3.2.0"
RUN curl -L -o "phalcon-devtools-${PHALCON_DEVTOOLS_VERSION}.tar.gz" "https://api.github.com/repos/phalcon/phalcon-devtools/tarball/${PHALCON_DEVTOOLS_VERSION}" \
&& tar -xvf "phalcon-devtools-${PHALCON_DEVTOOLS_VERSION}.tar.gz" --strip 1 \
&& rm "phalcon-devtools-${PHALCON_DEVTOOLS_VERSION}.tar.gz" \
&& ln -s /usr/local/lib/phalcon-devtools/phalcon.php /usr/bin/phalcon \
&& chmod +x /usr/bin/phalcon

# Install Composer
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN chmod +x /usr/local/bin/composer

# Install Dockerize
ENV DOCKERIZE_VERSION v0.5.0
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz

WORKDIR /usr/src/fileserver

COPY config/apache/apache2.conf /etc/apache2/apache2.conf
COPY config/apache/envvars /etc/apache2/envvars
COPY config/apache/site-default.conf /etc/apache2/sites-available/000-default.conf
COPY config/apache/project.conf /etc/apache2/project.conf
COPY config/php.ini /usr/local/etc/php/

COPY run.sh /run.sh
COPY start_safe_perms.sh /start_safe_perms.sh
RUN chmod 755 /*.sh

RUN a2enmod rewrite
RUN a2enmod headers


VOLUME ["/usr/src/fileserver"]

CMD ["/run.sh"]

docker 组成:
version: '3.1'

services:

fileserver:
build: fileServer/docker
container_name: fileServer
volumes:
- ./FileServer/:/usr/src/fileserver #/usr/src/app
ports:
- "5001:80"

我认为错误来自我的 site-default.config,它通常应该覆盖 000-default.conf

但我不知道为什么默认目录是 var/www/html。它应该是/usr/src/fileserver/public/(如果我在这个容器中做 docker exec,它会显示带有 index.php 的文件服务器文件夹)

站点-default.conf
<VirtualHost *:5001>

DocumentRoot /usr/src/fileserver/public

<Directory /usr/src/fileserver/public/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

ErrorLog /usr/src/fileserver/docker/logs/error.log
CustomLog /usr/src/fileserver/docker/logs/access.log combined

</VirtualHost>

有人能帮我吗? (如果需要,请询问更多信息)

最佳答案

看起来您正在将端口 5001 从本地计算机公开到 docker 实例上的端口 80,但随后您在端口 5001 上定义了您的虚拟主机。所以您的 site-default.conf 可能应该是:
<VirtualHost *:80>
请注意,该错误与/var/www/html/(某些 Apache 默认目录)有关,而不是您自己的/usr/src/fileserver/public

关于php - AH01276 : Cannot serve directory/var/www/html/: No matching DirectoryIndex (index. php,index.html) 找到,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49429267/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com