代码拉取完成,页面将自动刷新
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">
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。