eldios1981
eldios1981

Reputation: 519

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

I trying to get a php:apache server in a docker container with docker-compose to work. But after compose up I get following error message:

[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

my dockerfile:

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-compose:

version: '3.1'

services:

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

I think the error comes from my site-default.config, which should normally overwrites the 000-default.conf

But I don´t know why the default directory is var/www/html. It should be /usr/src/fileserver/public/ (if i do docker exec at this container, it shows the fileserver folder with index.php)

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

Can someone help me? (please ask for more informations, if they needed)

Upvotes: 7

Views: 53448

Answers (1)

Palantir
Palantir

Reputation: 24182

Looks like you are exposing port 5001 from local machine to port 80 on the docker instance, but then you are defining your virtual host on port 5001. So your site-default.conf it probably should read:

<VirtualHost *:80>

Notice that the error is about /var/www/html/ (some Apache default directory) and not your own /usr/src/fileserver/public

Upvotes: 3

Related Questions