如何在Shopware 6 Docker容器中通过CLI命令设置店面域名URL
Shopware 6 Docker容器配置店面URL的CLI方法
你可以通过Shopware内置的system:config:set命令,结合Docker exec来修改店面的域名URL,具体操作如下:
1. 设置全局基础URL
执行命令配置整个Shopware实例的基础访问URL:
docker exec -it $SHOPWARE_CONTAINER_ID /bin/bash -c "cd /var/www/html && bin/console system:config:set core.shopware.baseUrl 'http://localhost:8080'"
2. 指定Storefront主机(含端口)
配置Storefront模块使用的主机和端口:
docker exec -it $SHOPWARE_CONTAINER_ID /bin/bash -c "cd /var/www/html && bin/console system:config:set core.storefront.host 'localhost:8080'"
3. (可选)设置规范主机URL
为保证页面链接的一致性,避免重复内容问题,可配置规范主机:
docker exec -it $SHOPWARE_CONTAINER_ID /bin/bash -c "cd /var/www/html && bin/console system:config:set core.shopware.canonicalHost 'localhost:8080'"
4. 清除缓存使配置生效
Shopware会缓存系统配置,修改后需清除缓存以加载新配置:
docker exec -it $SHOPWARE_CONTAINER_ID /bin/bash -c "cd /var/www/html && bin/console cache:clear"
验证配置结果
你可以通过以下命令查看当前配置是否生效:
# 查看基础URL配置 docker exec -it $SHOPWARE_CONTAINER_ID /bin/bash -c "cd /var/www/html && bin/console system:config:show core.shopware.baseUrl" # 查看Storefront主机配置 docker exec -it $SHOPWARE_CONTAINER_ID /bin/bash -c "cd /var/www/html && bin/console system:config:show core.storefront.host"
完成上述操作后,访问http://localhost:8080即可确认店面URL已更新。
内容的提问来源于stack exchange,提问作者mlodhi
相关产品推荐
相关产品推荐

