Installing Drupal VM (With Vagrant+Ansible )

Information

Environment that passed the test

Name Version Notes
Vagrant 2.0.3 Download
VirtualBox 5.2.8 Download
Ansible 2.4.3.0 Document
Drupal VM git hash ‘63433a0’ Github
MacOSX High Sierra 10.13.3 Installation
Windows7 Installation

Download

git clone https://github.com/geerlingguy/drupal-vm.git
git checkout fe88f3e

Preparation

Powershell upgrade ( Windows only )

  • https://github.com/PowerShell/PowerShell/releases
    ** Action: Download
    *** “PowerShell-6.0.2-win-x64.msi”

Install vagrant plugins ( Windows only )

vagrant plugin install vagrant-winnfsd

Upgrade ansible

  • Mac OS local Ansible version 2.0.2 -> 2.4.x upgrade
ansible --version
brew upgrade ansible

Settings

Vagrantfile

  • Suppress CPU load to 80%
    • Row 137.
 # VirtualBox.
  config.vm.provider :virtualbox do |v|
    v.linked_clone = true
    v.name = vconfig['vagrant_hostname']
    v.memory = vconfig['vagrant_memory']
    v.cpus = vconfig['vagrant_cpus']
    v.customize ['modifyvm', :id, '--natdnshostresolver1', 'on']
    v.customize ['modifyvm', :id, '--ioapic', 'on']
+    v.customize ["modifyvm", :id, "--cpuexecutioncap", 80]
    v.gui = vconfig['vagrant_gui']
  end

config.yml

  • Create config file
    • config.yml.zip
    • 上記Linkからzipを解凍してconfig.phpを配置。
    • Diffで差分を確認。余計な差分がある場合はdefault.config.ymlをベースにした方が良い。
diff default.config.yml config.yml
Example
 # Available `vagrant_box` values include:
 #   - beet/box (pre-provisioned, based on Ubuntu 16.04)
 #   - geerlingguy/centos7
 #   - geerlingguy/centos6
 #   - geerlingguy/debian9
 #   - geerlingguy/debian8
 #   - geerlingguy/ubuntu1604
 #   - geerlingguy/ubuntu1404
-vagrant_box: geerlingguy/ubuntu1604
+vagrant_box: geerlingguy/centos7

~~

 # If you need to run multiple instances of Drupal VM, set a unique hostname,
 # machine name, and IP address for each instance.
-vagrant_hostname: drupalvm.test
+vagrant_hostname: drupal.vm.local
 vagrant_machine_name: drupalvm
 vagrant_ip: 192.168.88.88

~~ 

 # Ensure vagrant plugins are installed.
 vagrant_plugins:
   - name: vagrant-vbguest
   - name: vagrant-hostsupdater
+  - name: vagrant-bindfs
+  - name: vagrant-cachier
+  - name: vagrant-disksize
+  - name: sahara
+  - name: vagrant-global-status
+  - name: vagrant-multiplug
+  - name: vagrant-vbox-snapshot
+#  - name: vagrant-winnfsd
+

~~

 # Comment out any extra utilities you don't want to install. If you don't want
 # to install *any* extras, set this value to an empty set, e.g. `[]`.
 installed_extras:
   - adminer
-  # - blackfire
+  - blackfire
   # - drupalconsole
   - drush
   # - elasticsearch
   # - java
   - mailhog
-  # - memcached
+  - memcached
   # - newrelic
   # - nodejs
   - pimpmylog
   # - redis
-  # - ruby
+  - ruby
   # - selenium
   # - solr
   # - tideways
   # - upload-progress
-  - varnish
-  # - xdebug
+  # - varnish
+  - xdebug
   # - xhprof # use `tideways` if you're installing PHP 7+


~~

 # PHP Configuration. Currently-supported versions: 5.6, 7.0, 7.1, 7.2.
 # See version-specific notes: http://docs.drupalvm.com/en/latest/configurations/php/
 php_version: "7.1"
 php_install_recommends: no
-php_memory_limit: "192M"
+php_memory_limit: "512M"
 php_display_errors: "On"
 php_display_startup_errors: "On"
 php_realpath_cache_size: "1024K"
 php_sendmail_path: "/opt/mailhog/mhsendmail"
 php_opcache_enabled_in_ini: true
 php_opcache_memory_consumption: "192"
 php_opcache_max_accelerated_files: 4096
 php_max_input_vars: "4000"

Option change example

  • When you want to make another box
    • vagrant_machine_name: drupalvm
    • vagrant_machine_name: drupalvm-php56
  • Change version of PHP
    • php_version: “7.1”
    • php_version: “5.6”

Build CentOS7

vagrant up --debug

In case of success

  • If failed = 0 there is no problem.

Confirm

Trouble

  • Dual Network(LANとWIFI併用)を使っていたりするとネットワークの自動設定で問題が生じます。
    ** その結果、外部接続できず、yum installで失敗したりします。
  • 上手くいかない場合、上記Networkの問題を含め、OSのRebootを行うと解決する事もあります。

Bug report ( DrupalVM v4.8.1 )

※これらのBugは解決している可能性あり。
1.MacOSのCentOS7ではAnsibleのPHP install途中で外部接続できず、フリーズします
2.CentOS6で”drupalconsole”, “selenium”はErrorでinstallできません。


4 thoughts on “Installing Drupal VM (With Vagrant+Ansible )

  1. CentOS6の場合

    config.ymlを以下のように変更

    apache_vhost_php_fpm_parameters: |
        <LocationMatch ^(.*\.php)$>
          ProxyPass fcgi://127.0.0.1:9000/var/www/drupalvm/drupal/web/$1
        </LocationMatch>
    

コメントを残す