1 Star 1 Fork 2

alen / magento

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
magento2.4安装.txt 5.48 KB
一键复制 编辑 原始数据 按行查看 历史
alen 提交于 2021-01-08 15:44 . update magento2.4安装.txt.
magento 2.4 安装
1.需要用到命令行安装。 安装前准备安装的软件
composer
elasticsearc 高版本及对应的jdk
PHP7.3及以上
mysql8.0及以上
apache2.4及以上
2. 下载代码
从Github上: https://github.com/magento/magento2-sample-data
可选择版本下载
下载完成后,放到web下目录:magento24
3. 下载vendor
安装命令:管理员身份运行cmd,cd到 magento24下, 直接运行:composer install 下载 vendor
4.命令安装
需要到elasticsearch-7.9.1\bin下点击 elasticsearch.bat 运行,在网页端运行:http://localhost:9200/ 显示数据则运行成功
cmd 直接cd 到 magento24/bin 下,运行安装命令,windows下,php安装命令如下:
php magento setup:install --base-url="http://local.magento24.com" --db-host=localhost --db-name=magento24 --db-user=root --db-password=root --admin-firstname=Magento --admin-lastname=User --admin-email=admin@example.com --admin-user=admin --admin-password=admin123 --language=en_US --currency=HKD --timezone=Asia/Hong_Kong --use-rewrites=1 --search-engine=elasticsearch7 --elasticsearch-host=localhost --elasticsearch-port=9200
5.安装出错更改:
Unable to apply data patch Magento\Theme\Setup\Patch\Data\RegisterThemes for module Magento_Theme. Original excepti
on message: Wrong file
In Gd2.php line 64:
Wrong file
需要到: lib/internal/Magento/Framework/Image/Adapter/Gd2.php 中更改:
private function validateURLScheme(string $filename) : bool
{
$allowed_schemes = ['ftp', 'ftps', 'http', 'https'];
$url = parse_url($filename);
if ($url && isset($url['scheme']) && !in_array($url['scheme'], $allowed_schemes) ) {
return false;
}
return true;
}
方法更改为下面方法
private function validateURLScheme(string $filename) : bool
{
$allowed_schemes = ['ftp', 'ftps', 'http', 'https'];
$url = parse_url($filename);
//条件加 && !file_exists($filename)
if ($url && isset($url['scheme']) && !in_array($url['scheme'], $allowed_schemes) && !file_exists($filename)) {
return false;
}
return true;
}
6.页面显示不出
需要到: lib/internal/Magento/Framework/View/Element/Template/File/Validator.php 中更改方法:
protected function isPathInDirectories($path, $directories)
{
if (!is_array($directories)) {
$directories = (array)$directories;
}
$realPath = $this->fileDriver->getRealPath($path);
foreach ($directories as $directory) {
if (0 === strpos($realPath, $directory)) {
return true;
}
}
return false;
}
更改为: 是的,这是Windows的问题。Windows使用“ \”作为分隔符,数组“目录”包含以“ /”作为分隔符的条目,因此检查将始终失败。
protected function isPathInDirectories($path, $directories)
{
if (!is_array($directories)) {
$directories = (array)$directories;
}
// $realPath = $this->fileDriver->getRealPath($path);
$realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path));
foreach ($directories as $directory) {
if (0 === strpos($realPath, $directory)) {
return true;
}
}
return false;
}
7.php bin / magento setup:di:compile 出错
Warning: file_put_contents(F:/wamp64/www/magento24-2021-1/generated/metadata/primary|global|plugin-list.php): faile
d to open stream: No such file or directory in F:\wamp64\www\magento24-2021-1\lib\internal\Magento\Framework\Interc
eption\PluginListGenerator.php on line 414
为什么会这样呢?编译器试图使用“ | ”创建新文件。名称中的“”字符。在Linux文件系统上这是完全很酷的,但在Windows文件系统中是不允许的。
要修复它,我们需要打开此文件:411行周围的lib / internal / Magento / Framework / Interception / PluginListGenerator.php:
$this->initialize();
$configuration = sprintf('<?php return %s;', var_export($config, true));
file_put_contents(
$this->directoryList->getPath(DirectoryList::GENERATED_METADATA) . '/' . $key . '.php',
$configuration
);
}
我们将替换“ | ”,在$ key变量中包含“ _ ”,其中包含文件名:
$this->initialize();
$configuration = sprintf('<?php return %s;', var_export($config, true));
file_put_contents(
$this->directoryList->getPath(DirectoryList::GENERATED_METADATA) . '/' . str_replace('|', '_', $key) . '.php',
$configuration
);
}
8. 出错信息:
[2021-01-08 06:37:37] main.DEBUG: Request validation failed for action "Community\Logger\Controller\Adminhtml\Index\Index\Interceptor"
{"exception":"[object] (Magento\\Framework\\App\\Request\\InvalidRequestException(code: 0):
Invalid request received at F:\\wamp64\\www\\magento24-2021-1\\app\\code\\Magento\\Backend\\App\\Request\\BackendValidator.php:176)"} []
引起原因:显示页面,直接在浏览器中输入显示地址:
http://local.magento24-2021-1.com/admin/community_logger/index/index/
解决:
<1>需要经过菜单按钮点击链接跳转,在这过程中会生成key的值,key为验证值。
或是返回json数据
<2> module.xml 中需要添加版本号
<module name="Local_Shipping" setup_version="1.0.0">
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/alen2017/magento.git
git@gitee.com:alen2017/magento.git
alen2017
magento
magento
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891