Docker上的magento2错误:“设置”名称空间中未定义任何命令

时间:2019-08-12 16:27:43

标签: php linux docker containers magento2

我正在将magento2安装在具有以下操作系统的Docker容器中。

Linux 8791be8c3c43 5.0.0-23-generic #24~18.04.1-Ubuntu SMP Mon Jul 29 16:12:28 UTC 2019 x86_64 GNU/Linux

当我尝试使用下面的命令和参数设置magento时,出现错误: There are no commands defined in the "setup" namespace.

bin/magento setup:install \
--base-url=http://localhost/magento2 \
--db-host=localhost \
--db-name=magento \
--db-user=magento \
--db-password=magento \
--backend-frontname=admin \
--admin-firstname=admin \
--admin-lastname=admin \
--admin-email=admin@admin.com \
--admin-user=admin \
--admin-password=admin123 \
--language=en_US \
--currency=USD \
--timezone=America/Chicago \
--use-rewrites=1

根据我发现的一些帖子,我在下面运行了此命令,看来它显示了magento设置中的问题。最后一个错误,一个涉及SODIUM的错误,我通过安装钠扩展程序解决了。其他似乎也解决了。

enter image description here

magento@8791be8c3c43:/var/www/html/magento2$ php bin/magento list
Magento CLI 2.3.2

In ServiceManager.php line 1130:

  An abstract factory could not create an instance of magentosetupconsolecommandbackupcommand(alias: Magento\Setup\Console\Command\BackupCommand).  


In ServiceManager.php line 941:

  An exception was raised while creating "Magento\Setup\Console\Command\BackupCommand"; no instance returned  


In Di.php line 865:

  Missing instance/object for parameter maintenanceMode for Magento\Setup\Console\Command\BackupCommand::__construct  


In ServiceManager.php line 1130:

  An abstract factory could not create an instance of magentoframeworkappmaintenancemode(alias: Magento\Framework\App\MaintenanceMode).  


In ServiceManager.php line 941:

  An exception was raised while creating "Magento\Framework\App\MaintenanceMode"; no instance returned  


In ErrorHandler.php line 61:

  Warning: Use of undefined constant SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13 - assumed 'SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13' (this will throw an Error in a future version of PHP) in /var/www/html/magento2/  
  lib/internal/Magento/Framework/Encryption/Encryptor.php on line 153 

我尝试按照某些帖子中找到的步骤来解决该问题,例如删除以下目录的内容,然后尝试执行php bin/magento cache:flushphp bin/magento setup:upgrade,但是我尝试执行任何操作以php bin/magento.....开头的运行使我收到错误:There are no commands defined in the "xxxxxx" namespace.

rm -Rf var/cache/*
rm -Rf var/generation/*

我发现一些解决方案基于解决权限文件夹问题,但是我认为我没有权限问题,因为我的“ magento”用户是安装文件夹所有者组的成员(请参阅下面的代码),并且composer已安装“ magento”用户,未引发任何错误。

   # Create a new user and group, which will be Magento file system owner
    useradd -m -U -r -d /opt/magento magento -s /bin/bash && \

    # Add the magento user to the www-data group and change the /opt/magento directory permissions so that the Nginx can access the Magento installation:
    usermod -a -G www-data magento && \
    chmod 750 /opt/magento && \

    wget https://github.com/magento/magento2/archive/2.3.2.tar.gz && \
    tar -xzvf 2.3.2.tar.gz && \
    chown -R www-data:www-data /var/www/html/magento2-2.3.2/ && \
    chmod -R 775 /var/www/html/magento2-2.3.2/ && \
    mv magento2-2.3.2/ magento2 && \
    rm 2.3.2.tar.gz && \
    cd magento2 && \
    su magento && \

非常感谢您提出任何解决此问题的想法,

1 个答案:

答案 0 :(得分:2)

我遇到了类似的问题,这是由于libsodium版本(1.0.11)。

您可以安装更新的版本,请参见https://github.com/magento/magento2/issues/23405

将其添加到我的docker文件中很有吸引力:

RUN echo "deb http://deb.debian.org/debian stretch-backports main" >> /etc/apt/sources.list 

RUN apt-get update && apt-get -t stretch-backports install -y libsodium-dev

RUN pecl install -f libsodium-1.0.17