简体   繁体   中英

Afterlogic Webmail - Nginx to Apache “Cannot declare class, name is already in use”

I downloaded the Afterlogic Webmail from the official site, it works fine on apache.

Moving it to the official docker which uses apache it works fine ( https://github.com/afterlogic/docker-webmail-pro )

Moving it to my docker setup I use for every other project that uses nginx seems to cause the php classes to load twice.

Fatal error: Cannot declare class Aurora\Modules\ActivityHistory\Module, because the name is already in use in /var/www/modules/ActivityHistory\/Module.php on line 245

This is the default project pulled straight from https://afterlogic.com/download/webmail-pro-php.zip .

nginx configuration

server {
    listen 80;
    index index.php index.html;
    root /var/www;
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;
    location / {
        try_files $uri /index.php?$query_string;
    }

    location ~ \.php$ {

        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass ${LARANAME}:9000;
        fastcgi_index /index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}

docker-compose.yml

version: '3.7'
services:
  app:
    container_name: wbmail_app_dev
    build:
      context: .
      dockerfile: docker/app.dev.dockerfile
    ports:
      - '4721:80'
    volumes:
      - './:/var/www/'
    networks:
      - wbmail-network-dev
    ports: []
  web:
    container_name: wbmail_web_dev
    build:
      context: .
      dockerfile: docker/web.dev.dockerfile
    ports:
      - '4721:80'
    volumes:
      - './:/var/www/'
    environment:
      - LARANAME=wbmail_app_dev
    networks:
      - wbmail-network-dev
  db:
    container_name: wbmail_db_dev
    image: 'mariadb:latest'
    environment:
      MYSQL_DATABASE: wbmail_test
      MYSQL_ROOT_PASSWORD: cr0ssf1r3
    networks:
      - wbmail-network-dev
networks:
  wbmail-network-dev:
    driver: bridge

phpinfo(): https://codepasta.app/paste/c1e7nmvout2tbkhn2dk0

It turned out that there was a bug in the code, which caused attempts to include the same file multiple times. The issue has been corrected and the fix will be included in the product starting from the next version.

For those who experience the issue and need to correct it on their installation, locate the following line in system/autoload.php file:

$sModuleName = substr($sModuleClassName, 0, -7);

and replace it with:

$sModuleName = substr($sModuleClassName, 0, strpos($sModuleClassName, '\\'));

Thank you Andrew Gosselin for researching this and offering a fix.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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