登录应用程序后内部服务器错误

Internal Server Error after login applicatioin

我正在为我的 yii1 应用程序使用 docker。一切正常。但是在我登录我的应用程序之后。我收到此错误:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at [no address given] to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.

Apache/2.4.53 (Debian) Server at localhost Port 8082

所以这是我的 docker-compose fyle:

version: '3'
services:
  web:
    image: nguyenmanhluu/yii1:1.0
    container_name: dockeryiidisc
    ports:
      - "8082:80"
    build: 
      context: ..
      dockerfile: Dockerfile
      target: dev     
    volumes:
      - ./:/var/www/html       
    command: /bin/sh -c "service apache2 start && while sleep 1000; do :; done"
   
  db:
    container_name: dockeryiimysql
    image: mysql:latest
    volumes:
      - dockeryiimysql:/var/lib/mysql
    ports:
      - "3306:3306"
    environment:
      MYSQL_ALLOW_EMPTY_PASSWORD: 'true'
      MYSQL_DATABASE: sdi      

  phpmyadmin:  
    container_name: dockeryiipma
    image: phpmyadmin:latest
    environment:
      UPLOAD_LIMIT: 300M
      PMA_ARBITRARY: 1
      APACHE_HTTP_PORT_NUMBER: 8080
    ports:
      - 8080:8080
    command: /bin/bash -c "sed -i \"s/80/$$APACHE_HTTP_PORT_NUMBER/g\" /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf && /docker-entrypoint.sh apache2-foreground"

volumes:
  dockeryiimysql: {}

和我的文件 000-default.conf

<VirtualHost *:80>
    DocumentRoot /var/www/public

    <Directory /var/www>
            AllowOverride all
            Require all granted
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

和我的 docker 文件:

FROM php:8.1-apache as dev

ENV DEBIAN_FRONTEND=noninteractive
ENV APP_ENV=development

WORKDIR /var/www/html

RUN apt-get update \
  && apt-get -y install --no-install-recommends apt-utils zip unzip nano ncdu 2>&1 \
    && apt-get -y install --no-install-recommends python graphviz 2>&1 \
  && apt-get -y install git iproute2 procps lsb-release \
  && apt-get install -y -qq software-properties-common \
  && apt-get install -y -qq wget git lynx ack-grep \
  && yes | pecl install xdebug \
  && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
    && apt-get -y install libicu-dev \
    && docker-php-ext-install intl pdo_mysql opcache \
    && pecl install apcu && docker-php-ext-enable apcu \
    && echo "apc.enable_cli=1" > /usr/local/etc/php/php.ini \
    && echo "apc.enable=1" > /usr/local/etc/php/php.ini \
  && echo "post_max_size = 100M" > /usr/local/etc/php/php.ini \
    && a2enmod rewrite \
  && apt-get autoremove -y \
  && apt-get clean -y \
  && rm -rf /var/lib/apt/lists/*

RUN apt-get update && apt-get install gnupg2 -y

RUN rm -rf /etc/apache2/sites-enabled \
    && ln -s /var/www/html/.devcontainer/sites-enabled /etc/apache2/sites-enabled

RUN echo 'alias ll="ls -la --color=auto"' >> ~/.bashrc && \
    echo "alias ack='ack-grep'" >> ~/.bashrc

RUN chown www-data:www-data -R ./

ENV DEBIAN_FRONTEND=dialog

我的问题是:我必须更改什么?

我在哪里可以访问日志文件?

我有这个:

CONTAINER ID   IMAGE                    COMMAND                  CREATED          STATUS          PORTS                               NAMES
06276923b58b   mysql:latest             "docker-entrypoint.s…"   15 minutes ago   Up 15 minutes   0.0.0.0:3306->3306/tcp, 33060/tcp   dockeryiimysql
81055c285fdc   nguyenmanhluu/yii1:1.0   "docker-php-entrypoi…"   15 minutes ago   Up 15 minutes   0.0.0.0:8083->80/tcp                dockeryiidisc
eb7bd150d254   phpmyadmin:latest        "/docker-entrypoint.…"   15 minutes ago   Up 15 minutes   80/tcp, 0.0.0.0:8080->8080/tcp      dockeryiipma
PS C:\xampp\htdocs\webScraper> docker exec -it 81055c285fdc bash
root@81055c285fdc:/var/www/html#

并且我在文件 main.php 中使用了正确的主机作为容器名称:

'db'=> [
            'pdoClass' => 'NestedPDO',
            'connectionString' => 'mysql:host=dockeryiimysql;dbname=sdi',
            'emulatePrepare' => true,
            'username' => 'root',
            'password' => '',
            'charset' => 'utf8',
            'enableProfiling'=>true,
        ],

在 phpmyadmin 容器上我发现了这个:

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.21.0.3. Set the 'ServerName' directive globally to suppress this message
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.21.0.3. Set the 'ServerName' directive globally to suppress this message
[Mon May 23 07:06:13.275555 2022] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.53 (Debian) PHP/8.0.19 configured -- resuming normal operations
[Mon May 23 07:06:13.275613 2022] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
172.21.0.1 - - [23/May/2022:07:06:36 +0000] "GET /index.php?route=/&route=%2F HTTP/1.1" 200 6290 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59"
172.21.0.1 - - [23/May/2022:07:06:40 +0000] "POST /index.php?route=/ HTTP/1.1" 302 1020 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59"
172.21.0.1 - - [23/May/2022:07:06:40 +0000] "GET /index.php?route=/&route=%2F HTTP/1.1" 200 18402 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59"
172.21.0.1 - - [23/May/2022:07:06:40 +0000] "POST /index.php?route=/config/get HTTP/1.1" 200 2471 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59"
172.21.0.1 - - [23/May/2022:07:06:40 +0000] "POST /index.php?route=/navigation&ajax_request=1 HTTP/1.1" 200 3205 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59"
172.21.0.1 - - [23/May/2022:07:06:40 +0000] "POST /index.php?route=/version-check HTTP/1.1" 200 1047 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59"
172.21.0.1 - - [23/May/2022:07:06:40 +0000] "POST /index.php?route=/config/get HTTP/1.1" 200 2573 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59"
172.21.0.1 - - [23/May/2022:07:06:40 +0000] "POST /index.php?route=/config/set HTTP/1.1" 200 2462 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59"
172.21.0.1 - - [23/May/2022:07:06:42 +0000] "POST /index.php?route=/navigation&ajax_request=1 HTTP/1.1" 200 3897 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59"
172.21.0.1 - - [23/May/2022:07:30:35 +0000] "POST /index.php?route=/ HTTP/1.1" 200 2458 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59"
172.21.0.1 - - [23/May/2022:07:49:14 +0000] "POST /index.php?route=/ HTTP/1.1" 200 2466 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59"
172.21.0.1 - - [23/May/2022:08:14:59 +0000] "POST /index.php?route=/ HTTP/1.1" 200 3027 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59"
172.21.0.1 - - [23/May/2022:08:14:59 +0000] "GET /themes/pmahomme/img/s_error.png HTTP/1.1" 200 898 "http://localhost:8080/themes/pmahomme/css/theme.css?v=5.2.0" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36 OPR/86.0.4363.59"

您需要使用 docker exec 命令来 shell 访问您的 web (dockeryiidisc) 容器,其中 apache 运行。进入 shell 后,您可以查找 Apache 日志文件。默认情况下,您可以在以下路径找到 Apache 访问日志文件:/var/log/apache/access.log

Shell 访问命令为:

docker exec -it -u 0 dockeryiidisc bash

这基本上将您的命令提示符绑定到名为 dockeriidisc 的容器(根据您的 compose yaml 文件,您的 apache 容器)

-u 0 授予您容器的根访问权限。