best-it/shopware-vagrant

主要适用于 shopware (5) 的 Vagrant 设置

1.1.0 2021-06-10 10:31 UTC

This package is auto-updated.

Last update: 2024-09-11 15:13:55 UTC


README

安装

Virtualbox 和 Vagrant(最小版本 2.0)必须安装在您的本地计算机上

Debian / Ubuntu 的 Vagrant 安装

$ wget https://releases.hashicorp.com/vagrant/2.0.1/vagrant_2.0.1_x86_64.deb
$ sudo dpkg -i vagrant_2.0.1_x86_64.deb

使用方法

Composer

将仓库克隆到您的本地计算机。

$ composer require --dev best-it/shopware-vagrant

生成一个如下所示的 Vagrantfile 并根据您的需求进行修改

shopware_vagrant = File.expand_path('./vendor/best-it/shopware-vagrant/Vagrantfile')
load shopware_vagrant

confDir = $confDir ||= File.expand_path(File.dirname(__FILE__))
afterScriptPath = confDir + "/after.sh"
customizationScriptPath = confDir + "/user-customizations.sh"

Vagrant.configure("2") do |config|

    config.vm.synced_folder "./shopware", "/home/vagrant/www",
        type: "rsync",
        rsync__exclude: [
            "/.env",
            "/engine/Library",
            "/var/*",
            "/web/*",
            "/media/.htaccess",
            "/.htaccess",
            "/themes/Backend",
            "/themes/Frontend/Bare",
            "/themes/Frontend/Responsive",
            "/themes/Frontend/Session/node_modules",
            "/Plugins/Local/Backend/SwagImportExport/psh",
            "/custom/plugins/SwagPaymentPayPalUnified/psh"
        ]

    config.ssh.forward_agent = true

    if File.exist? afterScriptPath then
        config.vm.provision "shell", path: afterScriptPath, privileged: false, keep_color: true
    end

    if File.exist? customizationScriptPath then
        config.vm.provision "shell", path: customizationScriptPath, privileged: false, keep_color: true
    end
end

userVagrantfilePath = confDir + "/user-vagrantfile"
load userVagrantfilePath if File.exists?(userVagrantfilePath)

生成一个 ansible 文件夹

$ mkdir ansible

添加一个如下所示的 playbook

---
- name: apply common configuration to all nodes
  hosts: all
  roles:
    - role: '../vendor/best-it/shopware-vagrant/ansible/roles/common'
    - role: '../vendor/best-it/shopware-vagrant/ansible/roles/apache'
    - role: '../vendor/best-it/shopware-vagrant/ansible/roles/mysql'
    - role: '../vendor/best-it/shopware-vagrant/ansible/roles/adminer'
    - role: '../vendor/best-it/shopware-vagrant/ansible/roles/ioncube'
    - role: '../vendor/best-it/shopware-vagrant/ansible/roles/composer'
    - role: '../vendor/best-it/shopware-vagrant/ansible/roles/nodejs'
    - role: '../vendor/best-it/shopware-vagrant/ansible/roles/sw-cli-tools'
    - role: '../vendor/best-it/shopware-vagrant/ansible/roles/grunt'

不使用 composer

将仓库克隆到您的本地计算机。

$ git clone https://github.com/shopwareLabs/shopware-vagrant
$ cd shopware-vagrant

启动您的 vagrant 虚拟机

$ vagrant up

第一次启动可能需要一些时间,所以您可以随时喝杯咖啡。

您的机器将在 http://192.168.33.10/ 上可用。所有必需的工具,如 LAMP 栈,都已经安装。

要 SSH 到创建的 VM

$ vagrant ssh

如果您使用 Putty,ssh 配置可以通过

$ vagrant ssh-config

重新配置您的机器

$ vagrant provision

访问宿主机上的文件

要开始本地开发,建议将源 shopware 文件夹同步到本地文件夹。为此,请取消注释 Vagrantfile 文件中的一行 config.vm.synced_folder。

#config.vm.synced_folder "../src", "/home/vagrant/www/shopware", create: true, type: "smb"
#config.vm.synced_folder "../src", "/home/vagrant/www/shopware", create: true, type: "nfs"
#config.vm.synced_folder "../src", "/home/vagrant/www/shopware", create: true;

例如,对于 MacOS

config.vm.synced_folder "src", "/home/vagrant/www/shopware", create: true, type: "nfs"

编辑 vagrant 文件后,请确保重新加载您的实例。

$ vagrant reload

故障排除

  • 错误消息 "无法找到 'ansible_local' 配置器"。

请确保 vagrant 至少在 2.0 版本

$ vagrant -v
  • 无法挂载目录(MacOS),给出错误信息

      Got different reports about installed GuestAdditions version:
      Virtualbox on your host claims:   5.0.18
      VBoxService inside the vm claims: 6.0.8
      Going on, assuming VBoxService is correct..."
    

请确保 GuestAdditions 版本相同

$ vagrant vbguest --do install    
$ vagrant reload

更改 PHP 版本

默认安装以下 PHP 版本

  • PHP 7.0
  • PHP 7.1
  • PHP 7.2

调用以下命令之一以更改 PHP 版本

$ changephp_7.0
$ changephp_7.1
$ changephp_7.2

这将更改 Apache Web 服务器以及 php 命令使用的 PHP 版本。

您也可以通过它们的完整路径直接调用 PHP 版本

$ /usr/bin/php7.0 -v
$ /usr/bin/php7.1 -v
$ /usr/bin/php7.2 -v

安装 Shopware

首先通过 SSH 进入您的 VM

$ vagrant ssh

调用 install_shopware 脚本

$ install_shopware

这将下载最新的 git 版本的 shopware 并将其安装到 /home/vagrant/www/shopware

下载测试图像

$ cd /home/vagrant/www/shopware
$ wget -O test_images.zip http://releases.s3.shopware.com/test_images_since_5.1.zip
$ unzip test_images.zip

使用凭证 demo/demo 在浏览器中配置您的在线商店

然后您可以在以下位置访问您的店面

Arch Linux 用户注意事项

$ sudo pacman -S virtualbox ansible net-tools nfs-utils
$ sudo modprobe -a vboxdrv vboxnetadp vboxnetflt
$ sudo systemctl start nfs-server

许可证

MIT 许可证 (MIT)。有关更多信息,请参阅 许可证文件