Magento2 安装与使用笔记
单机安装:- 用composer 耐心安装composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition src- 完毕后,选择性运行下列命令-- 停用elastic search 模块bin/magento module:disable {Magento_El
·
目录
单机安装:
- 用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 index | indexing cron job | |
bin/magento cron:run --group default | run the default cron job | |
|
开启日志 | |
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
- 优化参考
更多推荐
所有评论(0)