This project is deprecated. The official Debian images are no longer maintained because Vagrant is no longer "free" software. I now create my development environment with incus, which is a free equivalent of Virtual Box + Vagrant + Docker.
- https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1110834
- https://linuxcontainers.org/incus/introduction/
Vagrant recipe for mounting a virtual machine with the official Debian in its latest stable version, provided by VirtualBox and provisioned with the following stack, installed from the Debian/Nginx/NodeSource package repositories:
- Nginx
- NodeJS
- PHP FPM + Xdebug + Composer
- MariaDB
- Mailhog
It you do not want to request and receive data via a local domain (default: local.test) rather than the virtual machine IP (default: 192.168.56.101), you can skip this section.
Your hosts file should include a mapping from the IP to the hostname of the virtual machine. This file is located:
- on Windows:
C:\Windows\System32\drivers\etc\hosts - on Mac and other Unix systems:
/etc/hosts
You may want to append other domains such as my-app-domain.test or dev.my-app-domain.com. A subdomain is recommended to develop an app with https.
If you do not want to manually change your hosts for each new project, you can either:
- use different ports such as
local.test:8001,local.test:8002, etc… - use different folders such as
local.test/my-first-app/,local.test/my-second-app/, etc… - install vagrant-hostmanager and setup
Vagrantfileaccordingly
Some issues might occur when running npm install or composer install in a shared folder. The easiest workaround is to create a symlink to a non shared folder:
cd /var/www/<my-app>
# For Composer
mkdir -p ~/composer/<my-app>
ln -s -T ~/composer/<my-app> vendor
# For npm
mkdir -p ~/npm/<my-app>
ln -s ~/npm/<my-app>/node_modules
cd ~/npm/<my-app>
ln -s /var/www/<my-app>/package{-lock}.jsonNote: if you have protocol errors when using ln -s, open your terminal (and run vagrant up) with admin privileges.
You may need vagrant-notify-forwarder to watch files (eg. with fs.watch in NodeJS) because Virtual Box does not forward change events on host files to the guest.
Polling (and diffing previous/current last modification time) is an alternative that remains fast enough when the number of watched files remains moderate.
To inspect a NodeJS script in Chrome Dev Tools, add local.test:9222 as a network target in chrome://inspect/#devices. Port 9222 is automatically mapped between the host and virtual machines when connecting to the latter with vagrant ssh.