php - Docker : There are no commands defined in the "setup" namespace 上的 magento2 错误

标签 php linux docker containers magento2

我正在使用操作系统的 Docker 容器中安装 magento2,如下所示。

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”命名空间。

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 && \

非常欢迎任何解决此问题的想法。

最佳答案

我遇到了类似的问题,这是由于 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

关于php - Docker : There are no commands defined in the "setup" namespace 上的 magento2 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57464898/

相关文章:

php - 试图在事件过去两天后隐藏该事件

amazon-web-services - 用于本地开发的 AWS Docker 容器

php - 带有参数的 URL 的 htaccess 301 重定向

PHP如何检查一天是否是假期(在指定国家)?

PHP登录/注销设计问题

php - Symfony 缓存 :clear Failed to remove directory

c - valgrind - 地址 ---- 在分配大小为 8 的 block 之后为 0 字节

linux - 在 Linux 上构建 Skia 时出现的问题

node.js - Node (Express & Mongo) 应用程序的生产与开发 Docker 设置

mysql - 无法远程连接容器中的mysql服务器