Magento2 安装与使用笔记

目录

单机安装:

- 安装demon数据

- 安装cronjob

- 几个控制命令

- 要点: 

- 安装插件

- 优化参考


单机安装:

- 用composer 耐心安装

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

- 完毕后,选择性运行下列命令

A 不带elastic search方式

-- 停用elastic search 模块

bin/magento module:disable {Magento_Elasticsearch,Magento_InventoryElasticsearch,Magento_Elasticsearch6,Magento_Elasticsearch7}

-- 停用两层验证,不然登录不上admin 

bin/magento module:disable Magento_TwoFactorAuth 

-- 安装

bin/magento setup:install \
--base-url=http://magento2-t1.local.com \
--db-host=192.168.16.169 \
--db-name=db_magento2_t1 \
--db-user=admin \
--db-password=xxx \
--admin-firstname=admin \
--admin-lastname=admin \
--admin-email=admin@admin.com \
--admin-user=admin \
--admin-password=xxx \
--language=en_US \
--currency=USD \
--timezone=America/Chicago \
--use-rewrites=1 \
--cleanup-database

B 应用elastic search方式

docker exec mk-php php /var/www/html/Eshops/MK003/src/bin/magento setup:install \
--elasticsearch-host=elasticsearch \
--backend-frontname=adminmg \
--base-url=http://www.xxx.com \
--base-url-secure=https://www.xxx.com \
--db-host=mariadb \
--db-name=mk_003_live \
--db-user=admin \
--db-password=xxx \
--admin-firstname=admin \
--admin-lastname=admin \
--admin-email=admin@admin.com \
--admin-user=admin \
--admin-password=xxx \
--admin-email=admin@xxx.com \
--language=en_US \
--currency=USD \
--timezone=America/Chicago \
--use-rewrites=1 \
--cleanup-database

- 修改配置参数

docker exec mk-php php /var/www/html/Eshops/MK003/src/bin/magento setup:upgrade
docker exec mk-php php /var/www/html/Eshops/MK003/src/bin/magento setup:di:compile
docker exec mk-php php /var/www/html/Eshops/MK003/src/bin/magento setup:static-content:deploy -f
docker exec mk-php php /var/www/html/Eshops/MK003/src/bin/magento config:set dev/static/sign 0
docker exec mk-php php /var/www/html/Eshops/MK003/src/bin/magento config:set web/secure/use_in_frontend 1
docker exec mk-php php /var/www/html/Eshops/MK003/src/bin/magento config:set web/secure/use_in_adminhtml 1
docker exec mk-php php /var/www/html/Eshops/MK003/src/bin/magento cache:clean
docker exec mk-php php /var/www/html/Eshops/MK003/src/bin/magento cache:flush

- 安装demon数据

bin/magento sampledata:deploy

bin/magento setup:upgrade  //To make sure that the enabled modules are properly registered

bin/magento setup:di:compile  //run the 'setup:di:compile' command to generate classes

- 安装cronjob

bin/magento cron:install

- 几个控制命令

命令说明
bin/magento cache:clean清理缓存
bin/magento cache:flush刷新缓存
bin/magento cron:run --group indexindexing cron job
bin/magento cron:run --group defaultrun the default cron job
bin/magento setup:config:set --enable-debug-logging=true
开启日志
bin/magento setup:static-content:deploy -f部署静态内容
当遇到错误“"Unable to retrieve deployment version of static files from the file system"时应用
bin/magento admin:user:create --admin-user {USER} --admin-password {PASSWORD} --admin-email {EMAIL} --admin-firstname {FIRSTNAME} --admin-lastname {LASTNAME}建管理账号
bin/magento deploy:mode:set developer设置为开发者模式

- 要点: 

- 添加完产品,要前台显示,需索引,清缓存

bin/magento cron:run --group index
bin/magento cache:flush

- debug

在 STORES-ADVANCED-Developer-Debug 面板打开后,需在访问页面后加 ?templatehints=magento 才显示hints信息

- 安装插件

查看registration.php文件, 如果插件包名为Mageplaza,插件名为SocialLogin, 则安装目录为app/code/Mageplaza/SocialLogin/

启用插件并安装插件数据

php bin/magento module:enable --clear-static-content Mageplaza_SocialLogin
php bin/magento setup:upgrade
php bin/magento setup:di:compile

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

- 优化参考

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

bennybi

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值