在Windows 用laragon 搭建magento2.3 -人生苦短
Magento2 搭建
软件准备
- window10 尽量16G内存以上 8G内存也可以但很慢 你的机器会呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜呜
- php 集成环境 LARAGON 相当于wamp但常用于laravel环境搭建。
- 获取源代码
安装
选择最优的第一种方式安装:magento官网下载压缩包
- 在Magento网站 marketplace.magento.com 上注册一个帐户。这个账户需要使用Magento和Magento Composer商店。
- 注册后,转到选项卡My Profile > My Access Keys > Magento 2,然后生成密钥。
- 配置密钥 注意:当需要使用验证的时候 配置Magento密钥 vpublic key作为用户名 Private Key 密码
- 安装第三方组件 在magento 根目录 执行
composer install -v
- 命令一键安装 (后面是携带的参数都要加上去)
php bin/magento setup:install --backend-frontname="adminlogin"
--key="65b07bf53f4d7ee8f4b884c102e5ee62"
--base-url="http://magento2.test" --base-url-secure="https://magento2.test"
--db-host=localhost
--db-name=magento2
--db-user=root
--db-password=
--admin-firstname=peter
--admin-lastname=zhao
--admin-email=2194958643@qq.com
--admin-user=admin
--admin-password=123_zhao
--language=en_US
--currency=USD
--timezone=America/Chicago
--use-rewrites=1
遇到的bug
解决:在项目路径/cli下新建一个php文件,updateConfiValue.php 填入代码再编译
<?php
if (php_sapi_name() != 'cli')die;
include('app/bootstrap.php');
use \Magento\Framework\App\Bootstrap;
use \Magento\Framework\App\ObjectManager;
use Magento\ImportExport\Model\Import\Adapter as ImportAdapter;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Catalog\Api\CategoryRepositoryInterface;
$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$resource = $objectManager->get('Magento\Framework\App\ResourceConnection');
$connection = $resource->getConnection();
$tableName = $resource->getTableName('core_config_data'); //gives table name with prefix
//Select Data from table
//$sql = "Select * FROM " . $tableName . " WHERE `path`='carriers/flatrate/postcoderanges'";
$sql = "Select * FROM {$tableName}";
$result = $connection->fetchAll($sql); // gives associated array, table fields as key in array.
foreach ($result as $row) {
if (checkIsSerialized($row['value'])) {
$value = json_encode(unserialize($row['value']));
$configId = $row['config_id'];
$sql = "Update " . $tableName . " Set value = "."'".$value."'"." where config_id = $configId";
$connection->query($sql);
}
}
function checkIsSerialized($str)
{
$data = @unserialize($str);
if ($str === 'b:0;' || $data !== false) {
return true;
}
return false;
}
F12 CSS JS 404空白 失效问题
编译静态文件:
php bin/magento setup:static-content :deploy -f
清楚缓存:
php bin/magento cache:clean && php bin/magento cache:flush
谷歌浏览器清除缓存:
ctrl +shift + delete
magento2.3 版本bug
- 文件所在:magento/vendoe/framework/View/Element/Template/File/Valitdator.php
- 修改如下:
$realPath = $this->fileDriver->getRealPath($path);
to replace
$realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path));
导入演示数据
演示数据引入系统 php -f magento2-sample-data/dev/tools/build-sample-data.php —-ce-source=”D:/laragon/www/magento2”
如果还是不行 可试着执行 php bin/magento sampledata:deploy php bin/magento setup:upgrade
搭建成功
最后建议
- 非常不开心!你竟然看到了最好,人生苦短,远离Magento2(码砖头)
- 不要用window 开发Magento2 会很多bug 特别是8G内存及以下的 响应十分缓慢慢慢慢慢慢慢慢慢慢慢
- 尽可能 linux 双核4g 以上 遵循Magento规则 不要砖牛脚尖
- 没有外贸需求 可以不用这系统 并不是系统有多难 主要开发繁琐 代码零散 配置要求高
系统优点
给点阳光和雨露:Magento2 代码复用模块化 扩展性强 属性处理牛 优惠券功能6 缓存机制牛。。。。
个人博客停止维护,部分博客转载到这
本作品采用《CC 协议》,转载必须注明作者和本文链接