Code Monkey home page Code Monkey logo

wp-vagrant's Introduction

Seravo.com

Seravo Vagrant Box

Brought to you by Seravo.com.

This project is used to build our precompiled WordPress Vagrant Box. See github.com/Seravo/wordpress to get started using this.

This box imitates the functionality of seravo.com WordPress instances. We aim to help our users develop WordPress locally with the best tools available.

What's inside?

Quite recent Docker CE. It spins up seravo/wordpress:development Docker image, which in turn provides production-like environment for your development needs.

You could also run plain Docker, but with Vagrant you get all the workflow benefits, start/shutdown triggers, domain names working reliably etc.

Installation

You just need to clone our project template & start vagrant.

git clone https://github.com/seravo/wordpress myproject
cd myproject
vagrant up

Pre-requirement is of course that you have recent VirtualBox and Vagrant installed on your machine.

Similar projects

See also:

Unlike some of the alternatives listed above, the Seravo WordPress Vagrant comes with all batteries included and there is no separate paid version. Our Vagrant box is also fully integrated into the workflow, so that users can effortlessly import and export data from and to production.

Packaging

Create a Vagrant image on your machine

First make sure you have the latest Ubuntu base images on your system by running vagrant box update.

Then build the Seravo Vagrant box using with make rebuild.

Test the new box locally first

Make Vagrant box available for local testing with make import and fire up a WordPress project where the Vagrantfile has been modified to contain:

  config.vm.box_version = "= 0"
  config.vm.box = 'seravo/wordpress-beta'

Publish on Vagrant Cloud

Make available for public testing by publishing first as Seravo/WordPress-Beta and only later as the official Seravo/WordPress Vagrant box.

When publishing on Vagrant boxes, see previous releases on how to define the version number, release notes and checksums. When making new official releases (not beta), also remember to write release notes at https://seravo.com/docs/get-started/release-notes/.

Alternative Vagrant box formats

To create a libvirt box, make sure you have installed the same dependencies as listed in .travis.yml, and run the same commands as Travis-CI does to provision a libvirt image. The resulting image is 1.5x larger than the VirtualBox image and the audience of libvirt is rather limited, so for now we have not put much effort in publishing boxes in the libvirt format.

wp-vagrant's People

Contributors

austinpray avatar chriscarr avatar emaildano avatar etcook avatar fullyint avatar nathanielks avatar onnimonni avatar ottok avatar spktklr avatar swalkinshaw avatar ypcs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

wp-vagrant's Issues

Replace hard-wired Finnish timezones with something?

What shall we do about this?

wp-vagrant/roles/hhvm/templates/php.ini.j2:date.timezone = Europe/Helsinki

Related, should the locale be C instead of en_US?

wp-vagrant/http/preseed.cfg:d-i debian-installer/locale string en_US.utf8
wp-vagrant/packer.json:              " locale=en_US<wait>",

wp cli update should be run when provisioning a box

Fresh wp-palvelu.fi site, cloned from "production" with

git clone ssh://[email protected]:6666/data/wordpress ./sitename --origin production

and then nothing else but cd sitename; vagrant up. The script will eventually prompt about cloning the production database, and if you answer "y" to it, it will fail.

Removed wp-content from core and symlinked it to ../wp-content
    censored-box: Pull database from production? (no): y
==> censored-box: Executing remote command "wp-pull-production-db"...
==> censored-box: Saving backup of current development database in /data/db/pre-production-pull-backup.sql...
==> censored-box: Success: Exported to pre-production-pull-backup-1475666834.sql
==> censored-box: Define new and old siteurl for later search-replacing...
==> censored-box: PHP Fatal error:  Uncaught Error: Call to undefined function apply_filters() in /data/wordpress/htdocs/wordpress/wp-includes/load.php:317
==> censored-box: Stack trace:
==> censored-box: #0 phar:///usr/local/bin/wp-cli/php/utils-wp.php(22): wp_debug_mode()
==> censored-box: #1 phar:///usr/local/bin/wp-cli/php/wp-settings-cli.php(59): WP_CLI\Utils\wp_debug_mode()
==> censored-box: #2 phar:///usr/local/bin/wp-cli/php/WP_CLI/Runner.php(807): require('phar:///usr/loc...')
==> censored-box: #3 phar:///usr/local/bin/wp-cli/php/WP_CLI/Runner.php(755): WP_CLI\Runner->load_wordpress()
==> censored-box: #4 phar:///usr/local/bin/wp-cli/php/wp-cli.php(21): WP_CLI\Runner->start()
==> censored-box: #5 phar:///usr/local/bin/wp-cli/php/boot-phar.php(5): include('phar:///usr/loc...')
==> censored-box: #6 /usr/local/bin/wp-cli(4): include('phar:///usr/loc...')
==> censored-box: #7 {main}
==> censored-box:   thrown in /data/wordpress/htdocs/wordpress/wp-includes/load.php on line 317
==> censored-box: Pulling database from production with 'wp db export'...
==> censored-box: Success: Imported from -
==> censored-box: Search-replacing  with  --skip-columns=guid
==> censored-box: PHP Fatal error:  Uncaught Error: Call to undefined function apply_filters() in /data/wordpress/htdocs/wordpress/wp-includes/load.php:317
==> censored-box: Stack trace:
==> censored-box: #0 phar:///usr/local/bin/wp-cli/php/utils-wp.php(22): wp_debug_mode()
==> censored-box: #1 phar:///usr/local/bin/wp-cli/php/wp-settings-cli.php(59): WP_CLI\Utils\wp_debug_mode()
==> censored-box: #2 phar:///usr/local/bin/wp-cli/php/WP_CLI/Runner.php(807): require('phar:///usr/loc...')
==> censored-box: #3 phar:///usr/local/bin/wp-cli/php/WP_CLI/Runner.php(755): WP_CLI\Runner->load_wordpress()
==> censored-box: #4 phar:///usr/local/bin/wp-cli/php/wp-cli.php(21): WP_CLI\Runner->start()
==> censored-box: #5 phar:///usr/local/bin/wp-cli/php/boot-phar.php(5): include('phar:///usr/loc...')
==> censored-box: #6 /usr/local/bin/wp-cli(4): include('phar:///usr/loc...')
==> censored-box: #7 {main}
==> censored-box:   thrown in /data/wordpress/htdocs/wordpress/wp-includes/load.php on line 317
==> censored-box: Remote command execution finished.
    censored-box: Activate git hooks in scripts/hooks? (yes): y
==> censored-box: Executing remote command "wp-activate-git-hooks"...
==> censored-box: Remote command execution finished.
    censored-box: Trust the generated ssl-certificate in OS-X keychain? (yes):
==> censored-box: Executing remote command "wp-use-asset-proxy &> /dev/null"...
==> censored-box: Remote command execution finished.
==> censored-box: Executing remote command "wp-restart-nginx &> /dev/null"...
==> censored-box: Remote command execution finished.

==> trigger: Documentation available at https://docs.wp-palvelu.fi
==> trigger: Visit your site: https://censored.local
________________________________________________________________________________
| ~/Documents/Sites/censored @ Christian-MBP (christian)
| =>

The whole vagrant box seems to somehow break when this occurs. Easiest way to fix is just to clone the site again.

Stop using vagrant-triggers for Vagrant >= 2.1.0

When attempting to run vagrant up on Vagrant version 2.1.0 with vagrant-triggers installed, the command produces a warning and fails as a result of an exception:

$ vagrant up
WARNING: Vagrant has detected the `vagrant-triggers` plugin. This plugin conflicts
with the internal triggers implementation. Please uninstall the `vagrant-triggers`
plugin and run the command again if you wish to use the core trigger feature. To
uninstall the plugin, run the command shown below:

  vagrant plugin uninstall vagrant-triggers

Note that the community plugin `vagrant-triggers` and the core trigger feature
in Vagrant do not have compatible syntax.

To disable this warning, set the environment variable `VAGRANT_USE_VAGRANT_TRIGGERS`.
Bringing machine 'wordpress-box' up with 'virtualbox' provider...
/opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/lib/vagrant/plugin/v2/config.rb:73:in `method_missing': undefined method `before_triggers' for #<VagrantPlugins::Triggers::Config::Trigger:0x0000000100baca38> (NoMethodError)
	from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/lib/vagrant/plugin/v2/trigger.rb:40:in `fire_triggers'
	from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/lib/vagrant/machine.rb:164:in `action'
	from /opt/vagrant/embedded/gems/2.1.0/gems/vagrant-2.1.0/lib/vagrant/batch_action.rb:82:in `block (2 levels) in run'

According to https://www.vagrantup.com/docs/triggers/, it seems that Vagrant has its own trigger mechanism which conflicts with the vagrant-triggers plugin. We should probably move away from external plugins and investigate if we could start using Vagrant's own mechanism for newer Vagrant versions, and eventually deprecate the vagrant-triggers plugin.

wp-pull-production-db fails

I'm trying to get the box to download the production DB, however this fails with the following error:

==> redacted-box: Define new and old siteurl for later search-replacing...
==> redacted-box: /usr/lib/ruby/vendor_ruby/highline.rb:862:in `get_line'
==> redacted-box: : 
==> redacted-box: The input stream is exhausted.
==> redacted-box:  (
==> redacted-box: EOFError
==> redacted-box: )
==> redacted-box: 	from /usr/lib/ruby/vendor_ruby/highline.rb:885:in `get_response'
==> redacted-box: 	from /usr/lib/ruby/vendor_ruby/highline.rb:260:in `ask'
==> redacted-box: 	from /usr/lib/ruby/vendor_ruby/highline.rb:223:in `agree'
==> redacted-box: 	from /usr/local/bin/wp-pull-production-db:48:in `<main>'
==> redacted-box: ==> Production site URL: 
==> redacted-box: ==> Development site URL: http://redacted.local
==> redacted-box: ==> This is a normal WordPress single install.
==> redacted-box: Is the information above correct (yes/no)?
==> redacted-box: Please enter "yes" or "no".
==> redacted-box: Is the information above correct (yes/no)?
==> redacted-box: Remote command execution finished.
The command "wp-pull-production-db" returned a failed exit code. The
error output is shown below:

/usr/lib/ruby/vendor_ruby/highline.rb:862:in `get_line': The input stream is exhausted. (EOFError)
	from /usr/lib/ruby/vendor_ruby/highline.rb:885:in `get_response'
	from /usr/lib/ruby/vendor_ruby/highline.rb:260:in `ask'
	from /usr/lib/ruby/vendor_ruby/highline.rb:223:in `agree'
	from /usr/local/bin/wp-pull-production-db:48:in `<main>'

One thing I can see is that the production URL does not get pulled for soem reason. The command for pulling the production URL does however work when issued with the config.yml credentials (ssh -q [email protected] -p 10531 "wp option get siteurl")

I'm running Ubuntu 16.04.

Browsersync constantly emits errors

The error log is constantly filled with BrowserSync service errors. Viewing the BrowserSync page does not work either.

==> /data/log/nginx-error.log <==
2017/03/11 20:38:42 [error] 2899#0: *177 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.25.1, server: , request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:1337/", host: "wordpress.local"

==> /data/log/nginx-error.log <==
2017/03/11 20:40:51 [error] 2899#0: *208 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.25.1, server: browsersync.*, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:1338/favicon.ico", host: "browsersync.wordpress.local", referrer: "https://browsersync.wordpress.local/"

wp-pull-production-db fails for WP Network sites

After running wp-pull-production-db all wp-cli commands stop working, because the database has now the production Network domain while the Vagrant config files refer to the local version.

The temporary workaround is to use DOMAIN_CURRENT_SITE='https://example.local' before running wp search-replace.

The second problem is that the search-replace does not change all occurences of the production domain. It should be run with the --network flag to also update all wp_blogs and wp_sites etc tables.

(Bug report written by Otto on customer's laptop)

Clean away Packer

The project still has a packer.json file. It should be deleted as it is no longer used and only creates confusion.

Also the preseed file and scripts/* should be removed as they are not called from the Vagrantfile in any way. Any still useful parts from the preseed and scripts should be deployed via Ansible so they are included in the image building phase.

VirtualBox complains about non-matching guest utils

While booting up the latest v20201205.0.0 box, I saw this:

==> wordpress-box: Checking for guest additions in VM...
    wordpress-box: The guest additions on this VM do not match the installed version of
    wordpress-box: VirtualBox! In most cases this is fine, but in rare cases it can
    wordpress-box: prevent things such as shared folders from working properly. If you see
    wordpress-box: shared folder errors, please make sure the guest additions within the
    wordpress-box: virtual machine match the version of VirtualBox you have installed on
    wordpress-box: your host and reload your VM.
    wordpress-box: 
    wordpress-box: Guest Additions Version: 5.2.8_KernelUbuntu r120774
    wordpress-box: VirtualBox Version: 6.1

Maybe the Guest Additions should be updated to VirtualBox 6.1? I wonder if they are backwards compatible, will they work with VirtualBox 6.0 or 5.2?

PR #58 would be one way to do it. Another option would be install VB Guest additions from a Bionic repo.

Update to Ubuntu 18.04

The Vagrant box should be updated to Ubuntu 16.04, which brings PHP7 and new versions of all other software too (Nginx, Node.js, Redis, PhantomJS, XDebug). We could drop some of the PPA's in favour of vanilla Ubuntu 16.04 repository contents. At the same time we should review what updated VVV and Roots/Trellis have, we might want to import something from there.

Once the Vagrant image is at 16.04 level, we could proceed to consider updating production container environements to 16.04.

Upgrade PHPUnit?

Current box have:


phpunit --version
PHPUnit 3.7.28 by Sebastian Bergmann.

But for example wp-cli plugin unit test require 4.8.x

Any plans to upgrade PHPUnit?

After introducing PHP 7.1, php-error.log permissions are broken

Out-of-the-box the /data/log file permissions are now:

vagrant@wordpress:~$ ll /data/log/
total 48
drwxrwsrwx 2 vagrant vagrant  4096 Feb  1 16:47 ./
drwxr-sr-x 7 vagrant vagrant  4096 Feb  1 15:23 ../
-rw-r--r-- 1 root    vagrant     0 Feb  1 16:47 error.log
-rw-r--r-- 1 root    vagrant 18622 Feb 13 22:02 nginx-access.log
-rw-r--r-- 1 root    vagrant  5370 Feb 13 22:02 nginx-error.log
-rw------- 1 root    vagrant     0 Feb  1 16:46 php-error.log
-rw-rw---- 1 redis   vagrant  8341 Feb 13 22:26 redis.log

They should be more like in production (all owned by the user and no extra error.log there):

test11@test11_8ce59a:/data/home/test11$ ll /data/log/
total 20
drwxr-xr-x  2 test11 test11 4096 Feb 12 05:02 ./
drwxr-xr-x 11 test11 test11 4096 Feb 10 13:48 ../
-rw-r--r--  1 test11 test11    0 Feb 10 13:48 nginx-access.log
-rw-r--r--  1 test11 test11    0 Feb 10 13:48 nginx-error.log
-rw-------  1 test11 test11 3767 Feb 12 05:03 php-error.log
-rw-r--r--  1 test11 test11 3362 Feb 12 05:03 redis.log
-rw-r--r--  1 test11 test11 1933 Feb 12 05:04 update.log

Automate testing new Vagrant box

Testing new Vagrant boxes could be automated somewhat. We could run in a script on the same computer that built the image for example:

  1. Checkout latest Seravo/WordPress project template
  2. Modify Vagrant box to seravo/wordpress-beta and version = 0
  3. Run vagrant up, wait until it completes
  4. Run tests:
vagrant ssh --command wp-test
vagrant ssh --command s-test-commands

I tested to confirm that exit codes also come through as they should:

$ vagrant ssh --command wp-test
Connecting to development environment... (ssh -- /usr/local/bin/wp-test)
SSH connection confirmed
I: Starting wp-test...
I: Using URL 'https://wordpress.local' for pre-flight checks.
I: Pre-flight test for https://wordpress.local found a </html> tag
I: Pre-flight test for https://wordpress.local returned HTTP code 200
I: Executing ChromeDriver...
I: Ensure test user exists...
I: Updated permission and password for existing test user...
ERROR ERROR ERROR
I: Lower test user privileges as test ended...
Connection to 127.0.0.1 closed.

$ echo $?
1

Publish provider 'libvirt'

Steps for current demo:

# Assuming original box name is seravo/wordpress-beta version 0
qemu-img convert -f vmdk -O qcow2 ~/.vagrant.d/boxes/seravo-VAGRANTSLASH-wordpress-beta/0/virtualbox/*.vmdk seravo-wordpress-beta.img
/usr/share/doc/vagrant-libvirt/examples/create_box.sh seravo-wordpress-beta.img
vagrant box add seravo-wordpress-beta.box --name seravo/wordpress-beta

cd ~/wordpress-project
wordpress-project$ vagrant up --provider libvirt

Currently fails with missing vagrant-wordpress0 network. Needs more research to complete..

In a multisite configuration, upload doesn't work by default

This will fix it:

Outside the server block:

map $uri $blogname{
~^(?P<blogpath>/[^/]+/)files/(.*)       $blogpath ;
}

map $blogname $blogid{
default -999;
}

Custom.conf:

location ~ ^(/[^/]+/)?files/(.+) {
  try_files /wp-content/blogs.dir/$blogid/files/$2 /wp-includes/ms-files.php?file=$2 ;
  access_log off;     log_not_found off; expires max;
}

Initial wp-pull-production-db fails

It works once Vagrant is fully up and running, but the command initiated by the vagrant up wizard does not seem to find the command in the right path:

    redacted-box: Pull database from production? (no): yes
==> redacted-box: Executing remote command "wp core install --url=https://redacted.local --title=redacted         [email protected] --admin_user=vagrant --admin_password=vagrant"...
==> redacted-box: entering site container... /usr/local/bin/wp core install --url=https://redacted.local --title=redacted [email protected] --admin_user=vagrant --admin_password=vagrant
==> redacted-box: |----------------------------------------------------------------------------|
==> redacted-box: | Welcome to Seravo.com!                                                     |
==> redacted-box: | Unauthorized use is forbidden. All connections are monitored and recorded. |
==> redacted-box: |----------------------------------------------------------------------------|
==> redacted-box: Success: WordPress installed successfully.
==> redacted-box: Remote command execution finished.
==> redacted-box: Executing remote command "wp-pull-production-db"...
==> redacted-box: bash: line 5: wp-pull-production-db: command not found
==> redacted-box: Remote command execution finished.
The remote command "wp-pull-production-db" returned a failed exit
code or an exception. The error output is shown below:

bash: line 5: wp-pull-production-db: command not found

Docker daemon socket permission denied

I got the following error running vagrant ssh:

~ vagrant ssh              
Connecting to development environment... (ssh -- )
Waiting for SSH connection...
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.40/containers/seravo_wordpress/json: dial unix /var/run/docker.sock: connect: permission denied
Connection to 127.0.0.1 closed.

After I while, I got in. But the site doesn't seem to be running at all (ERR_TIMED_OUT). I tried running wp-restart-nginx but got the same error as with vagrant up. The VirtualBox is running fine.

Env:

  • Ubuntu 20.04 LTS
  • Vagrant 2.2.9 + VirtualBox 6.1
  • seravo\wordpress-beta v.20200606 box

Updating the Vagrant box breaks SSH key authentication

If one runs vagrant up for an existing project after vagrant box update was run, one will not be able to access the box anymore due to mismatch in SSH keys:

$ vagrant up
Bringing machine 'wordpress-box' up with 'virtualbox' provider...
==> wordpress-box: Checking if box 'seravo/wordpress' is up to date...
==> wordpress-box: Clearing any previously set forwarded ports...
==> wordpress-box: Clearing any previously set network interfaces...
==> wordpress-box: Preparing network interfaces based on configuration...
    wordpress-box: Adapter 1: nat
    wordpress-box: Adapter 2: hostonly
==> wordpress-box: Forwarding ports...
    wordpress-box: 22 (guest) => 2222 (host) (adapter 1)
==> wordpress-box: Running 'pre-boot' VM customizations...
==> wordpress-box: Booting VM...
==> wordpress-box: Waiting for machine to boot. This may take a few minutes...
    wordpress-box: SSH address: 127.0.0.1:2222
    wordpress-box: SSH username: vagrant
    wordpress-box: SSH auth method: private key
    wordpress-box: Warning: Authentication failure. Retrying...
    wordpress-box: Warning: Authentication failure. Retrying...
    wordpress-box: Warning: Authentication failure. Retrying...
    wordpress-box: Warning: Authentication failure. Retrying...
    wordpress-box: Warning: Authentication failure. Retrying...
    wordpress-box: Warning: Authentication failure. Retrying...
    wordpress-box: Warning: Authentication failure. Retrying...

The workaround is to run vagrant destroy; vagrant up but it seems stupid. Investigate how and where the SSH key is generated, and how we could save it and reuse if permanently to avoid this situation in the future.

Writing to /etc/hosts fails on OSX

When running vagrant up, the command fails with this chunk of text:

Bringing machine 'sample-box' up with 'virtualbox' provider...
==> sample-box: Checking if box 'seravo/wordpress' is up to date...
==> sample-box: VirtualBox VM is already running.
==> sample-box: [vagrant-hostsupdater] Checking for host entries
==> sample-box: [vagrant-hostsupdater] Writing the following entries to (/etc/hosts)
==> sample-box: [vagrant-hostsupdater]   192.168.93.139  sample  # VAGRANT: 799c4eac34e80adc79c99df966b0587a (sample-box) / b22a5436-f033-4008-8264-1b041bc11c78
==> sample-box: [vagrant-hostsupdater]   192.168.93.139  sample.local  # VAGRANT: 799c4eac34e80adc79c99df966b0587a (sample-box) / b22a5436-f033-4008-8264-1b041bc11c78
==> sample-box: [vagrant-hostsupdater]   192.168.93.139  www.sample.local  # VAGRANT: 799c4eac34e80adc79c99df966b0587a (sample-box) / b22a5436-f033-4008-8264-1b041bc11c78
==> sample-box: [vagrant-hostsupdater]   192.168.93.139  webgrind.sample.local  # VAGRANT: 799c4eac34e80adc79c99df966b0587a (sample-box) / b22a5436-f033-4008-8264-1b041bc11c78
==> sample-box: [vagrant-hostsupdater]   192.168.93.139  adminer.sample.local  # VAGRANT: 799c4eac34e80adc79c99df966b0587a (sample-box) / b22a5436-f033-4008-8264-1b041bc11c78
==> sample-box: [vagrant-hostsupdater]   192.168.93.139  mailcatcher.sample.local  # VAGRANT: 799c4eac34e80adc79c99df966b0587a (sample-box) / b22a5436-f033-4008-8264-1b041bc11c78
==> sample-box: [vagrant-hostsupdater]   192.168.93.139  browsersync.sample.local  # VAGRANT: 799c4eac34e80adc79c99df966b0587a (sample-box) / b22a5436-f033-4008-8264-1b041bc11c78
==> sample-box: [vagrant-hostsupdater]   192.168.93.139  info.sample.local  # VAGRANT: 799c4eac34e80adc79c99df966b0587a (sample-box) / b22a5436-f033-4008-8264-1b041bc11c78
==> sample-box: [vagrant-hostsupdater] This operation requires administrative access. You may skip it by manually adding equivalent entries to the hosts file.
/Users/christian/.vagrant.d/gems/gems/vagrant-hostsupdater-1.0.2/lib/vagrant-hostsupdater/HostsUpdater.rb:98:in `initialize': Permission denied @ rb_sysopen - /etc/hosts (Errno::EACCES)
    from /Users/christian/.vagrant.d/gems/gems/vagrant-hostsupdater-1.0.2/lib/vagrant-hostsupdater/HostsUpdater.rb:98:in `open'
    from /Users/christian/.vagrant.d/gems/gems/vagrant-hostsupdater-1.0.2/lib/vagrant-hostsupdater/HostsUpdater.rb:98:in `addToHosts'
    from /Users/christian/.vagrant.d/gems/gems/vagrant-hostsupdater-1.0.2/lib/vagrant-hostsupdater/HostsUpdater.rb:47:in `addHostEntries'
    from /Users/christian/.vagrant.d/gems/gems/vagrant-hostsupdater-1.0.2/lib/vagrant-hostsupdater/Action/UpdateHosts.rb:17:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/plugins/providers/virtualbox/action/message_already_running.rb:11:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builder.rb:116:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/runner.rb:66:in `block in run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/util/busy.rb:19:in `busy'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/runner.rb:66:in `run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builtin/call.rb:53:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builtin/box_check_outdated.rb:78:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/plugins/providers/virtualbox/action/check_virtualbox.rb:17:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builder.rb:116:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/runner.rb:66:in `block in run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/util/busy.rb:19:in `busy'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/runner.rb:66:in `run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builtin/call.rb:53:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builder.rb:116:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/runner.rb:66:in `block in run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/util/busy.rb:19:in `busy'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/runner.rb:66:in `run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builtin/call.rb:53:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/plugins/providers/virtualbox/action/check_virtualbox.rb:17:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /Users/christian/.vagrant.d/gems/gems/vagrant-triggers-0.5.3/lib/vagrant-triggers/action/trigger.rb:17:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /Users/christian/.vagrant.d/gems/gems/vagrant-triggers-0.5.3/lib/vagrant-triggers/action/trigger.rb:17:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /Users/christian/.vagrant.d/gems/gems/vagrant-triggers-0.5.3/lib/vagrant-triggers/action/trigger.rb:17:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/warden.rb:34:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/builder.rb:116:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/runner.rb:66:in `block in run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/util/busy.rb:19:in `busy'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/action/runner.rb:66:in `run'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/machine.rb:224:in `action_raw'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/machine.rb:199:in `block in action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/environment.rb:561:in `lock'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/machine.rb:185:in `call'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/machine.rb:185:in `action'
    from /opt/vagrant/embedded/gems/gems/vagrant-1.8.1/lib/vagrant/batch_action.rb:82:in `block (2 levels) in run'

Basically for some reason it's unable to write to the hosts file, and I have to add the entries manually. Removing seems to happen just fine on vagrant halt. It never asks for a password to gain administrator privileges, but I can write to /etc/hosts just fine without root.

Kinda annoying having to do this every time.

Cannot halt the VM if triggers fail

You have to SSH in to the box to be able to shut down the VM.

$ vagrant halt --force
==> default: Running triggers before halt...
==> trigger: dumping the database into: .vagrant/vagrant-dump.sql
==> default: Executing command "wp core is-installed && wp db export /data/wordpress/.vagrant/vagrant-dump.sql"...
==> default: Error: This does not seem to be a WordPress install.
==> default: Pass --path='path/to/wordpress' or run 'wp core download'.
==> default: Command execution finished.
The command "wp core is-installed && wp db export /data/wordpress/.vagrant/vagrant-dump.sql" returned a failed exit code. The
error output is shown below:

Error: This does not seem to be a WordPress install.
Pass --path='path/to/wordpress' or run 'wp core download'.

$ vagrant status
Current machine states:

default                   running (virtualbox)

The VM is running. To stop this VM, you can run 'vagrant halt' to
shut it down forcefully, or you can run 'vagrant suspend' to simply
suspend the virtual machine. In either case, to restart it again,
simply run 'vagrant up'.

Make the SSH login banner nicer

Current Vagrant:

$ vagrant ssh
Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 3.13.0-112-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Mon Mar 13 11:22:10 UTC 2017

  System load:  3.57              Processes:           112
  Usage of /:   4.8% of 39.34GB   Users logged in:     0
  Memory usage: 5%                IP address for eth0: 10.0.2.15
  Swap usage:   0%

  Graph this data and manage this system at:
    https://landscape.canonical.com/

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

New release '16.04.2 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


WordPress Developer Documentation available at https://seravo.com/docs/

Last login: Sun Mar 12 21:50:55 2017 from 10.0.2.2

Compare to production:

$ ssh wp-palvelu
Last login: Mon Mar 13 09:40:52 2017 from 172.17.42.1
Documentation for WordPress developers at: https://seravo.com/docs/
wp-palvelu@wp-palvelu:~$

Update the Nginx version in Vagrant to match production

I made some checks and noticed that in our Vagrant image the Nginx version is behind the production container version:

vagrant@wordpress:~$ nginx -v
nginx version: nginx/1.8.0

wp-palvelu@wp-palvelu:~$ nginx -v
nginx version: nginx/1.12.1

For the other components I checked versions match quite well (Node.js 7.10, MariaDB 10.1.26, PHP 7.0.22, Redis 2.8.4).

In general we should do a new round of comparing/reviewing Vagrant vs production.

Nginx not being run as root, and not starting due to permission issues

vagrant@wordpress-wp-dev:~$ nginx -t
nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
2015/03/15 11:02:36 [warn] 2521#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:5
2015/03/15 11:02:36 [emerg] 2521#0: unknown "connection_upgrade" variable
nginx: configuration file /etc/nginx/nginx.conf test failed

Asset proxy failing to load static files from production

The asset proxy fails to get static files from the production instance even with proper config.yml configuration, resulting as 404 errors when accessing the local site. Steps to reproduce:

  1. Clone Seravocom (private) repo and switch to legacy branch
  2. Run vagrant up in repo and don't pull production db (yet)
  3. Run vagrant ssh and run wp-pull-production-db in the virtual machine, check that all presented site urls are valid
  4. Check local site in browser, static files give 404 error codes
  5. Attempt to run wp-use-asset-proxy in vagrant, does not fix the issue

There has also been at least one customer report on this issue. This could originate from some overlapping Nginx configurations, but we should look more thoroughly into this.

Halting the beta version of the Vagrant box renders the box unusable

It's not possible to restart Vagrant after a vagrant halt with the beta version of the box (a box run with config.vm.box = 'seravo/wordpress-beta' in Vagrantfile).

==> seravocom-box: Running triggers after up...
checking for composer... no
==> seravocom-box: Executing remote command "composer install --working-dir=/data/wordpress"...
==> seravocom-box: Waiting for container SSH...
==> seravocom-box: Waiting for container SSH...
==> seravocom-box: Waiting for container SSH...
==> seravocom-box: Waiting for container SSH...
==> seravocom-box: Waiting for container SSH...
==> seravocom-box: Waiting for container SSH...
==> seravocom-box: Waiting for container SSH...
==> seravocom-box: Waiting for container SSH...
==> seravocom-box: Waiting for container SSH...
==> seravocom-box: Waiting for container SSH...
==> seravocom-box: Waiting for container SSH...

There is a workaround: running vagrant destroy; vagrant up will clean up whatever went wrong with the vagrant halt, but it might still be worth it to investigate this.

Fix hard-coded UART path in a Virtualbox 6 compatible way

NOTE: All of these are true for the ubuntu/bionic64 box too!

Problem

6b36249 was a mistake, but reverting it isn't the solution either,

After updating the box, vagrant up fails with a hardcoded path which is generated during building:

[:~/seravo/wordpress] master+* 3m42s ± vagrant up 
Bringing machine 'wordpress-box' up with 'virtualbox' provider...
==> wordpress-box: Importing base box 'seravo/wordpress'...
==> wordpress-box: Matching MAC address for NAT networking...
==> wordpress-box: Checking if box 'seravo/wordpress' version '20201127.0.0' is up to date...
==> wordpress-box: Setting the name of the VM: wordpress_wordpress-box_1606743429262_295
==> wordpress-box: Clearing any previously set network interfaces...
==> wordpress-box: Preparing network interfaces based on configuration...
    wordpress-box: Adapter 1: nat
    wordpress-box: Adapter 2: hostonly
==> wordpress-box: Forwarding ports...
    wordpress-box: 22 (guest) => 2222 (host) (adapter 1)
==> wordpress-box: Running 'pre-boot' VM customizations...
==> wordpress-box: Booting VM...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.                   

Command: ["startvm", "7af72bad-205c-49bc-95c0-a3543973d433", "--type", "headless"]   

Stderr: VBoxManage: error: RawFile#0 failed to create the raw output file /home/otto/github-seravo/wp-vagrant/ubuntu-bionic-18.04-cloudimg-console.log (VERR_FILE_NOT_FOUND)                                                                                   
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component ConsoleWrap, interface IConsole                                                                 

The path can be changed from Virtualbox's machine settings to something that exists and everything works out fine.

If the UART is disabled, the boot with Virtualbox 6 is slooooow (doesn't seem to boot at all). In hashicorp/vagrant#10578 it is discussed, that ubuntu/xenial64 prints error to serial device -log during boot time.

Solutions

  1. Change the base box to bento/bionic64. It doesn't output stuff to a serial device during boot time. There is a high risk of regressions. Changing the base box is not usually recommended.
  2. Generate the log path in https://github.com/seravo/wordpress. This makes stuff incompatible with each other and the roll-out can be quite messy.

Include makepot in our Vagrant image for convenience

Create a command wp-makepot that executes the WordPress .pot file generator (which needs to be copied into our Vagrant image). This will make it easier for theme/plugin developers to generate translation files.

See https://github.com/Varying-Vagrant-Vagrants/VVV/blob/develop/config/homebin/makepot and https://codex.wordpress.org/I18n_for_WordPress_Developers and in particular https://developer.wordpress.org/plugins/internationalization/localization/#wordpress-i18n-tools

Also consider writing some small script that compiles po files to mo files, maybe calling it wp-pomo-compile or something. See https://developer.wordpress.org/plugins/internationalization/localization/#command-line as an example.

Compare to VVV

Compare our Seravo Vagrant box to the develop branch of the official WordPress Vagrant box: https://github.com/Varying-Vagrant-Vagrants/VVV

If there are any developer tools, speed optimizations etc cool things, consider copying them over to our image. Note however to keep the PHP/Nginx part in parity with our production environment, there should be no surprises when developers push their sites to production.

VIM IS NOT INSTALLED !! ! !! !! *OUTRAGE*

vagrant@pointscene-wp-dev:/etc/nginx$ vim nginx.conf 
The program 'vim' can be found in the following packages:
 * vim
 * vim-gnome
 * vim-tiny
 * vim-athena
 * vim-gtk
 * vim-nox
Try: sudo apt-get install <selected package>

Investigate using Kint for stack traces

XDebug is a bit slow and some users would like to have it disabled by default. However the pretty stack traces it makes is nice. One alternative would be to disable Xdebug and use Kint instead for stack traces.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.