- Overview
- Requirements
- Installation
- Set-Up
- Use
- Email Testing Environment
- Unit Tests
- Troubleshooting
- Known Issues
- Resources
Vagrant setup for NDL VuFind2 with two separate guest virtual machines:
- dev (default)
- for development, uses NDL-VuFind2 files from the host's filesystem. An added development feature is the option to have also RecordManager-Finna on the host's native filesystem. This is the one you will most likely be using.
- server
- a testbed to build a personal test server; SELinux enabled so could maybe even be a rough outline to set-up a production server, who knows. Clones the latest NDL-VuFind2 from GitHub inside the guest.
-
AND a provider:
-
VirtualBox (default for ease of use, not for performance)
- v7.xx recommended
- v6.1.x Mac users should see this
OR
-
QEMU (macOS only)
Note: For Apple Silicon CPUs this is the only tested optionOR
-
libvirt (Linux only)
(Note:
- Hyper-V (Windows only) may work if using SMBv1 on the host for sharing but is untested - you have been warned!)
Also for dev VM:
- NDL-VuFind2 (fork it!) cloned to the host computer (mandatory)
- RecordManager-Finna also cloned to the host (optional)
- finna-ui-components also cloned to the host (optional)
Quick way: install Vagrant and VirtualBox first and proceed to Set-Up.
Recommended way: see Wiki for more platform specific installation options.
dev (ubuntu-24.04):
-
Clone the NDL-VuFind2-Vagrant files to the host computer, preferably (but this is not an absolute must) into a directory parallel to the NDL-VuFind2 working directory e.g. path-to/NDL-VuFind2 & same-path-to/NDL-VuFind2-Vagrant. The directory names can also be different than those presented here. All the same applies also to RecordManager files if using it on the host.
-
Run
vagrant uponce or manually copy VagrantConf.rb.sample to VagrantConf.rb.- If the path to the NDL-VuFind2 working directory is other than ../NDL-VuFind2 modify the VagrantConf.rb VufindPath variable accordingly. The path can either be an absolute or a relative path as long as the NDL-VuFind2 files can be found there. Similar attention to possible RecordManager directory should be used.
- Adjust also VMProvider accordingly if not using VirtualBox.
- If the path to the NDL-VuFind2 working directory is other than ../NDL-VuFind2 modify the VagrantConf.rb VufindPath variable accordingly. The path can either be an absolute or a relative path as long as the NDL-VuFind2 files can be found there. Similar attention to possible RecordManager directory should be used.
-
Run
vagrant upagain or manually copy dev.conf.sample to dev.conf and see the file for possible install configuration changes (e.g. using RecordManager on host or remote Solr server etc.) prior to running the VM in full.
server (rockylinux9):
-
Clone the NDL-VuFind2-Vagrant files to the host computer unless this is already done. If only using server, any directory with sufficent user permissions will do. If using both dev & server, the same directory with dev is fine.
-
Run
vagrant up serveronce or manually copy VagrantConf.rb.sample to VagrantConf.rb unless this is already done. There should be no need for any changes. -
Run
vagrant up serveragain or manually copy server.conf.sample to server.conf and see the file for possible install configuration changes prior to running the VM in full.
both/either:
The default is to install & run Finna Solr & RecordManager-Finna locally inside the VM. Some configuration options still exist (see also Without local database) e.g. for RecordManager development:
-
Install only Finna Solr inside the guest VM
INSTALL_SOLR=true
INSTALL_RECMAN=false -
Use cloned RecordManager files on the host system instead of the guest VM (dev.conf only):
RECMAN_DEV=true ;default: false
Regarding the records data:
- default (but bare minimum for testing purposes): a sample data file exists in the data/ directory to be imported to the local Solr database via RecordManager during install
- more proper use: add your own data to the data/ directory before provisioning/installing or import your data manually from file(s) OR set up harvesting sources after the provisioning/installing is done. See RecordManager & Importing Data.
Without local database: use a remote Solr server (like the NDL development index - unfortunately, limited users only)
- either set the EXTERNAL_SOLR_URL in the conf files (also set INSTALL_SOLR + INSTALL_RECMAN to false as they are not needed), or
- add the external URL to the NDL-VuFind2/local/config/vufind/config.ini file before or after install.
Note: With RSync this is the only useful option since syncing happens only from host to guest VM.
If not using VirtualBox, see the platform and provider specific configuration options for QEMU (macOS) and libvirt (Linux) in the Wiki.
dev:
vagrant up- This will take a few minutes, so enjoy your beverage of choice!
- Point your browser to http://localhost:8081/vufind2
blank page or errors:- adjust VuFind config(s), reload browser page
- check forwarded ports
vagrant portand adjust the URL if needed, reload browser page - see also Troubleshooting
- No integrated responsive/mobile development tool but try the native open source Responsively App (also on GitHub).
- If you don't install Solr & RecordManager at
vagrant upstartup you can add them to the already started virtual machine later by first setting their install options to true in dev.conf and then running consecutivelyvagrant ssh -c "bash /vagrant/scripts/dev_solr.sh"vagrant ssh -c "bash /vagrant/scripts/dev_recman.sh"- This is quicker than
vagrant destroy+vagrant upif building the VM from the ground up is not needed or preferred.
- This is quicker than
Note: If RSync is enabled and you are making developement changes run:
vagrant rsync-autoto let vagrant keep up with the made changes and sync them into the VM–you can use another tab or start a screen session for running the command in the backround. See rsync-auto for details. (Another way is to manually runvagrant rsyncbefore testing the made changes but the previous command automizes this.)
server:
vagrant up server- Again, this will take a few minutes...
vagrant ssh -c "/usr/bin/mysql_secure_installation" serverto add MySQL root password and remove anonymous user & test databases- http://localhost:8082/vufind2
blank page or errors:- adjust VuFind config(s) inside the VM, reload browser page
- check forwarded ports
vagrant port serverand adjust the URL if needed, reload browser page - see also Troubleshooting.
Both machines can be run simultaneously provided the host has enough oomph–except with QEMU provider. See Known Issues.
Solr: sudo service solr start|stop|restart|status inside the VM to control the running state.
- Solr Admin UI can be accessed at
- dev: http://localhost:18983/solr
- server: http://localhost:28983/solr
RecordManager & Importing Data: Set to default, the provisioning phase will install a sample dataset to the local index. It is recommended to use your own data. The easiest way is to add a data file and a proper datasources.ini file to the data/ directory + adjust the RECMAN_SOURCE, RECMAN_DATASOURCE & RECMAN_DATA variables in dev-/server.conf prior to the vagrant up command. It is also possible to change the RECMAN_IMPORT to false and set up data harvesting after installation. For more details, see datasources.ini.sample and RecordManager Usage.
- RecordManager Wiki for additional information.
-
vagrant reload- reload the configuration changes made to VagrantConf.rb file
-
vagrant suspend- freeze the virtual machine, continue with
vagrant resume
- freeze the virtual machine, continue with
-
vagrant halt- shut down the virtual machine, restart with
vagrant up --no-provision
- shut down the virtual machine, restart with
-
vagrant destroy- delete the virtual machine
-
vagrant ssh-
login to the running virtual machine (vagrant:vagrant) e.g. to restart Apache
sudo service apache2 restartor to check Apache logssudo tail -f /var/log/apache2/error.log,sudo tail -f /var/log/apache2/access.log -
use option
-cto run commands in guest via ssh e.g.vagrant ssh -c "check-scss"to check for problems in scss, orvagrant ssh -c "build-scss"to build scss, orvagrant ssh -c "sudo service apache2 restart"to restart Apache etc.vagrant ssh -c "phing ..."to run phing tasks, e.g.vagrant ssh -c "phing php-cs-fixer"etc.
-
-
vagrant ssh -c "neofetch"- VM system info
-
vagrant port- see all forwarded ports
-
vagrant box update- update the cached boxes if newer versions exist
-
vagrant box list-
show the cached box files
all unnecessary ones can be pruned at once or only specific box files be removed (add-hfor help):vagrant box pruneor e.g.
vagrant box remove ubuntu/jammy64 --box-version 20221027.0.0
-
-
vagrant plugin install vagrant-vbguest- for prolonged use, install vagrant-vbguest plugin to keep the host machines's VirtualBox Guest Additions automatically updated
-
vagrant plugin update- keep the installed plugins up to date
-
(
vagrant package --output dev_mybox.box(use any name you wish for output)- package the virtual machine as a new base box, roughly 700MB or more - the VagrantConf.rb file needs to be edited to use the created box file. )
When addressing the server machine, just add server at the end of each command.
Vagrant documentation for more info.
Testing exists only in the dev VM.
- dev.conf:
EMAIL_TEST_ENV=true
- add the settings below & adjust the [Mail] section accordingly - you need a working mail server - in NDL-VuFind2/local/config/vufind/config.ini
[Site] institution = testi [Account] force_first_scheduled_email = true [Mail] host = localhost port = 25 ;username = user ;password = "pass" ; better to use quotes ; If set to false, users can send anonymous emails; otherwise, they must log in first require_login = false- There might also be need to use the setting below but YMMV
[Catalog] driver = Demo
- There might also be need to use the setting below but YMMV
- After
vagrant upuse 127.0.0.1 instead of localhost i.e. http://127.0.0.1:8081/vufind2 to log in as a (new) test user.
- in user profile add the email address to receive the messages, set Due date reminders via email
- run
vagrant ssh -c "due_date_reminders"
- in user profile add the email address to receive the messages, if not already set
- save a search or two, in Saved searched set the Alert schedule
- run
vagrant ssh -c "scheduled_alerts"
The email address in user profile should receive the messages. Note that another test user needs to be set up to run the made-up scheduled alerts again - turning them off and back on might work but this is untested.
Unit tests can be run in the dev VM if needed - this might come handy especially if developing upstream to vufind.org repository.
A quick example of running a single test (adjust params as needed):
vagrant ssh -c "./phing.sh phpunitfaster -Dphpunit_extra_params=/vufind2/module/VuFindConsole/tests/unit-tests/src/VuFindTest/Command/ScheduledSearch/NotifyCommandTest.php"
For more possibilities see Using Phing in the VuFind Developer Manual.
-
Check the network connection is working. The virtual environment needs to load from several Internet resources and cannot build itself properly without them. Note that there might also be problems with the cloud resources themselves.
-
As NDL-VuFind2 is being actively developed some new settings and configuration options will be presented in its .ini/yaml/json.sample files from time to time. While building the virtual machine these files are only copied if previous ones don't already exist. Therefore should problems arise there might be need to make a backup of the .ini/yaml/json files in local/config/vufind/ & local/config/finna/ before deleting all of them (not the .sample ones!). The files will then be copied anew next time the virtual machine is succesfully build. If needed, the old settings can now be carried over manually from the backups.
A telltale sign of this is usually when the dev machine fails to function properly or the PHP server crashes while the server machine is working properly (if built).
If all else fails, set LOCAL_CACHE_CLEAR to true in dev.conf to clear local cache files during the virtual machine provisioning. Remember to set this back to false to avoid clearing the cache every consecutive time the dev VM is being built. -
The Ubuntu basebox may be updated quite regularly so after
vagrant box updateit is not very common but quite possible that something breaks in the install scripts. If this happens and items 1 & 2 are already ruled out, runvagrant up 2>&1 | tee ./vagrant-log.txtwith the default dev.conf settings + create an issue describing shortly what happened and include the logfile. -
"Cannot shutdown/remove VM - HELP!"
Often (but not always) it is possible to use the VirtualBox GUI to remove the troublesome VM.
If this is not the case try VBoxManage:
- Find the name (or ID) of the VM you want to remove:
VBoxManage list vms - Shutdown the VM:
VBoxManage startvm NAME(OR ID) --type emergencystop - Delete the VM:
VBoxManage unregistervm NAME(OR ID) --delete
- "Library not loaded: '/opt/vagrant/embedded/lib/libssh2.1.dylib' ... '/usr/lib/libssh2.1.dylib' (no such file)" or similar error on
vagrantcommands after upgrading macOS and/or XCode when Vagrant installed via Homebrew
- Try reinstalling Vagrant:
brew reinstall --cask vagrant
- Virtual machine not working despite
vagrant global-statusshows it is running.
- Remove VM:
vagrant destroy - Provision again:
vagrant up
NOTE! Virtual machines DO NOT SURVIVE host reboot/shutdown.
- VirtualBox:
vagrant suspendbefore reboot/shutdown
vagrant resumeafter host has booted - QEMU: suspend/resume is not supported, use instead:
vagrant haltbefore reboot/shutdown
vagrant up --no-provisionafter host has booted
(this is quicker thanvagrant destroyandvagrant upfor destroying & re-provisioning the VM again from the start)
- If running Solr, VirtualMemory needs to be at least around 2048, which should work. Add more if/when needed considering the host has what to spare.
- Antiquated software versions have issues e.g. Vagrant v1.8.7 (curl issues), VirtualBox v5.0.28 & v5.1.8 (Composer issues), maybe others. Use current versions!
- Performance might be slightly slower than native LAMP/MAMP/WAMP but shouldn't be an issue. YMMV though, so worst case, try adding more VirtualMemory and/or raising VirtualCPUs to 2 in VagrantConf.rb.
More speed can also be gained by enabling NFS:- Set EnableNFS to true.
- Mac users, with NFS enabled Vagrant needs to modify /etc/exports and admin password will be asked at every
vagrant up&vagrant destroyunless you once runsudo scripts/nfs-sudoers_mac.shor manually modify sudoers. See NFS for more information.
Using VB v6.1.x, NFS will most likely be difficult to get working correctly. See here and here for NFS troubleshooting. If NFS is absolutely needed and v7.x.x is not an option and nothing else works, use the latest VB v6.0.x. - Linux users, NFS must be used with libvirt provider. To avoid being asked for credentials at every
vagrant up&vagrant destroyeither manually modify sudoers or runsudo scripts/nfs-sudoers_ubuntu.shorsudo scripts/nfs-sudoers_fedora.shbased on your platform. Please see NFS for details. - Windows users may want to try Vagrant WinNFSd as by default NFS synced folders are ignored by Vagrant - yet again, this is untested!
- On macOS, VirtualBox v6.1.x is known also to have some permission issues on occasion. Make sure you have given full disk access to Terminal in System Prefences > Security & Privacy > Privacy (also check for relevant programs if using e.g. iTerm2 or integrated terminal in VSCode etc.).
- Apple Silicon CPU users should use QEMU provider, which is limited to SMB sharing or RSync. VirtualBox developer preview for Apple silicon may work but is untested.
- QEMU provider ignores high-level network configurations and causes a conflict with SSH port forwarding if dev & server VMs are tried to be run simultaneously. Other providers shouldn't have this limitation given the host has enough resources.
- QEMU and libvirt providers may prompt to destroy both VMs at
vagrant destroyeven when the other one is not running. If this is confusing, target the wanted VM usingvagrant destroy devorvagrant destroy server. - SMB sharing will first ask sudo password and later user credentials at
vagrant up. User credentials are also asked atvagrant destroy. - Running on Linux has been tested to work with Linux Mint so Ubuntu(/Debian) based distros should likely work, others are unknown.
- For those about to use Windows, we salute you! And the best of luck–you tread the unwalked path.