ubuntu 20 安装 magento2.4

目录

说明

1、magento2.4需要elasticsearch7服务,首先安装elasticsearch7

2、修改elasticsearch配置

3、启动 elasticsearch7

4、验证服务

5、安装 magento2.4 

1)下载magento2.4 

A、下载安装包

 B、composer方式

Access Key获得方式:

2)命令行开始安装magento

6、可能的问题:

1)由于是管理员账户安装的可能有的配置会有权限问题,用下面的命令修复一下。

2)修改目录文件所有权 daemon:daemon 根据实际情况修改 注意后面的 "." 不要忘了

3)刷新静态页面

4)后台登录需要双重验证

5)安装2.4.2版本报错:Declaration of Psr\Log\LoggerInterface\Proxy::emergency 问题解决

6)Failed to initialize global composer: Composer could not find the config file: var/composer_home/composer.json

7)Missing following extensions: 'xsl'  


说明

这里只记录了主体部分的安装流程,和碰到的问题解决方式。虚拟站点创建部分没有做说明。目前不建议安装2.4.2版本有坑。

1、magento2.4需要elasticsearch7服务,首先安装elasticsearch7

curl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -

echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list

sudo apt update

sudo apt install elasticsearch



2、修改elasticsearch配置

sudo nano /etc/elasticsearch/elasticsearch.yml
/etc/elasticsearch/elasticsearch.yml
. . .
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: localhost
. . .

3、启动 elasticsearch7

sudo systemctl start elasticsearch
sudo systemctl enable elasticsearch

4、验证服务

curl -X GET 'http://localhost:9200'

 ubuntu 20 安装 magento2.4_第1张图片

说明服务已经正常

安装elasticsearch插件,不安装会有报错

cd /usr/share/elasticsearch
bin/elasticsearch-plugin install analysis-phonetic
bin/elasticsearch-plugin install analysis-icu
sudo service elasticsearch restart

5、安装 magento2.4 

我这里使用的是PHP 7.3.23版本,php安装可以参考 ubuntu 20 php-7.4.15 编译安装

PHP 7.3.23 (cli) (built: Oct 16 2020 13:58:39) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.23, Copyright (c) 1998-2018 Zend Technologies
    with the ionCube PHP Loader + ionCube24 v10.4.1, Copyright (c) 2002-2020, by ionCube Ltd.
    with Zend OPcache v7.3.23, Copyright (c) 1999-2018, by Zend Technologies

1)下载magento2.4 

A、下载安装包

下载地址 https://magento.com/tech-resources/download#archive-releases

 解压到网站目录,或者FTP上传

tar xvzf magento-ce-2.4.0-2020-07-24-11-15-38.tar.gz

 B、composer方式

安装composer1.9.0版本

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
sudo php composer-setup.php --install-dir=/bin/composer --version=1.9.0
All settings correct for using Composer
Downloading...

Composer (version 1.9.0) successfully installed to: /usr/bin/composer.phar
Use it: php /bin/composer.phar

 为方便使用进行重命名:

mv /bin/composer.phar /bin/composer

 如果已经安装了其他版本的可以进行版本切换:

composer self-update 1.9.0

开始下载:

composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition=2.4.0 ./magento240

如果是第一次升级安装会提示输入验证信息,

Access Key获得方式:

1.打开https://marketplace.magento.com

2.注册账号这里就不说明了

3.打开My Profile

ubuntu 20 安装 magento2.4_第2张图片

4.打开Access Keys

ubuntu 20 安装 magento2.4_第3张图片

5.点击Create A New Access Key 创建key

ubuntu 20 安装 magento2.4_第4张图片

6.输入名称

ubuntu 20 安装 magento2.4_第5张图片

这里的Public Key 是Username, Private Key 是 Password

ubuntu 20 安装 magento2.4_第6张图片

直接回车开始下载。

出现类似  pcntl_signal() has been disabled for security reasons  这样的错误是因为PHP禁用了pcntl_signal 命令,打开php.ini找到 disable_functions 这一行,删除对应的名称就可以了。

2)命令行开始安装magento

进入安装目录:

cd magento240

安装用到的的参数查询方式 

语言代码列表	sudo php bin/magento info:language:list
货币代码列表 sudo php bin/magento info:currency:list
时区代码列表 sudo php bin/magento info:timezone:list

开始安装: 

sudo php bin/magento setup:install --base-url=http://magento.local --db-host=localhost --db-name=magento.local --db-user=magento.local  --db-password=magento.local --admin-firstname=Magento --admin-lastname=User [email protected]  --admin-user=admin --admin-password=admin123 --language=it_IT --currency=EUR --timezone=Europe/Rome --use-rewrites=1 --search-engine=elasticsearch7 --elasticsearch-host=127.0.0.1 --elasticsearch-port=9200

   ubuntu 20 安装 magento2.4_第7张图片

 安装完成 /admin_miv4ax 是随机产生的后台管理地址,可以在app/etc/env.php中修改

ubuntu 20 安装 magento2.4_第8张图片

记得要创建虚拟站点我用的是Apache 2.4.46版本

6、可能的问题:

错误提示 Class Magento\Framework\App\ResourceConnection\Proxy does not exist

1)由于是管理员账户安装的可能有的配置会有权限问题,用下面的命令修复一下。

find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +
find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +
chmod u+x bin/magento

2)修改目录文件所有权

daemon:daemon是运行web服务的用户和组

sudo chown -R daemon:daemon . 

 daemon:daemon 根据实际情况修改 注意:后面的 "." 不要忘了

3)刷新静态页面

php bin/magento setup:static-content:deploy -f
php bin/magento indexer:reindex
php bin/magento cache:clean
php bin/magento cache:flush

4)后台登录需要双重验证

ubuntu 20 安装 magento2.4_第9张图片

 暴力方式先关了

php bin/magento module:disable Magento_TwoFactorAuth

5)安装2.4.2版本报错:Declaration of Psr\Log\LoggerInterface\Proxy::emergency 问题解决

因为PHP兼容问题,会报错 \\Psr\\Log\\LoggerInterface\\Proxy 的错误

    2.7834   21909600  31. Magento\Framework\App\ObjectManager->get($type = '\\Psr\\Log\\LoggerInterface\\Proxy') /www/wwwroot/magento242/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php:170
    2.7834   21909656  32. Magento\Framework\ObjectManager\Factory\Dynamic\Developer->create($requestedType = 'Psr\\Log\\LoggerInterface\\Proxy', $arguments = ???) /www/wwwroot/magento242/vendor/magento/framework/ObjectManager/ObjectManager.php:70
    2.7834   21909656  33. Magento\Framework\Interception\ObjectManager\Config\Developer->getInstanceType($instanceName = 'Psr\\Log\\LoggerInterface\\Proxy') /www/wwwroot/magento242/vendor/magento/framework/ObjectManager/Factory/Dynamic/Developer.php:47
    2.7834   21909656  34. Magento\Framework\Interception\Config\Config->hasPlugins($type = 'Psr\\Log\\LoggerInterface\\Proxy') /www/wwwroot/magento242/vendor/magento/framework/Interception/ObjectManager/Config/Developer.php:61
    2.7834   21909656  35. Magento\Framework\Interception\Config\Config->_inheritInterception($type = 'Psr\\Log\\LoggerInterface\\Proxy') /www/wwwroot/magento242/vendor/magento/framework/Interception/Config/Config.php:180
    2.7834   21910200  36. Magento\Framework\ObjectManager\Relations\Runtime->has($type = 'Psr\\Log\\LoggerInterface\\Proxy') /www/wwwroot/magento242/vendor/magento/framework/Interception/Config/Config.php:157
    2.7834   21910200  37. class_exists($classname = 'Psr\\Log\\LoggerInterface\\Proxy') /www/wwwroot/magento242/vendor/magento/framework/ObjectManager/Relations/Runtime.php:38
    2.7834   21910296  38. spl_autoload_call($class_name = 'Psr\\Log\\LoggerInterface\\Proxy') /www/wwwroot/magento242/vendor/magento/framework/ObjectManager/Relations/Runtime.php:38
    2.7835   21910392  39. Magento\Framework\Code\Generator\Autoloader->load($className = 'Psr\\Log\\LoggerInterface\\Proxy') /www/wwwroot/magento242/vendor/magento/framework/ObjectManager/Relations/Runtime.php:38
    2.7835   21910392  40. Magento\Framework\Code\Generator->generateClass($className = 'Psr\\Log\\LoggerInterface\\Proxy') /www/wwwroot/magento242/vendor/magento/framework/Code/Generator/Autoloader.php:53
    2.7848   21936400  41. Magento\Framework\Code\Generator\Io->includeFile($fileName = '/www/wwwroot/magento242/generated/code/Psr/Log/LoggerInterface/Proxy.php') /www/wwwroot/magento242/vendor/magento/framework/Code/Generator.php:142
    2.7850   21950144  42. include('/www/wwwroot/magento242/generated/code/Psr/Log/LoggerInterface/Proxy.php') /www/wwwroot/magento242/vendor/magento/framework/Code/Generator/Io.php:160

修复方法参考 更新magento 2.4.2 错误 PHP Fatal error:  Declaration of Psr\Log\LoggerInterface\Proxy::emergency 问题解决

6)Failed to initialize global composer: Composer could not find the config file: var/composer_home/composer.json

[Progress: 951 / 1206]
Module 'Magento_ComposerRootUpdatePlugin':
Running data recurring...Reading /www/wwwroot/magento240/composer.json
Loading config file /www/wwwroot/magento240/composer.json
Failed to initialize global composer: Composer could not find the config file: /www/wwwroot/magento240/var/composer_home/composer.json
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
Reading /www/wwwroot/magento240/vendor/composer/installed.json
Reading /www/wwwroot/magento240/composer.lock
Checking for "magento/composer-root-update-plugin: 1.1.0" for the Web Setup Wizard...
Reading /www/wwwroot/magento240/var/vendor/magento/composer-root-update-plugin/composer.json
Loading config file /www/wwwroot/magento240/var/vendor/magento/composer-root-update-plugin/composer.json
No Web Setup Wizard update needed for magento/composer-root-update-plugin; version 1.1.0 is already in /www/wwwroot/magento240/var.

[Progress: 952 / 1206]

ubuntu 20 安装 magento2.4_第10张图片

解决方法:

禁用magento/composer-root-update-plugin模块

php bin/magento module:disable Magento_ComposerRootUpdatePlugin

直接删除 magento/composer-root-update-plugin 模块

composer remove magento/composer-root-update-plugin 

ubuntu 20 安装 magento2.4_第11张图片

7)Missing following extensions: 'xsl'  

Starting Magento installation:
File permissions check...
[Progress: 1 / 1206]
Required extensions check...

In Installer.php line 525:
                                       
  Missing following extensions: 'xsl'  
                                       

ubuntu 20 安装 magento2.4_第12张图片

magento 需要下面这些PHP插件,打开php.ini文件开启对应的插件

ext-bcmath
ext-ctype
ext-curl
ext-dom
ext-gd
ext-hash
ext-iconv
ext-intl
ext-mbstring
ext-openssl
ext-pdo_mysql
ext-simplexml
ext-soap
ext-xsl
ext-zip

你可能感兴趣的:(Magento,Linux,magento,2.4,安装,magento命令行安装)