The ArminVieweg/ubuntu-bionic64-lamp box is an optimized Vagrant box for VirtualBox 6+ based on latest Ubuntu 18.04 LTS "Bionic Beaver" 64-bit, containing an extended LAMP stack.
This box is released under GPL-2.0+.
- Apache 2 (with SSL available)
- PHP 5.6, 7.0 - 7.4 (7.4 enabled by default)
- with handy switch (e.g.
$ sudo ~/enable-php/7.4.sh
)
- with handy switch (e.g.
- XDebug for all versions (except for 7.4)
- MariaDB
- ImageMagick
- Composer
- NodeJS & npm
- Ruby
- Mailcatcher
Just perform a vagrant init ArminVieweg/ubuntu-bionic64-lamp
in your project to use this box.
This will create a very basic Vagrantfile for you.
You may also use the Vagrantfile in this repository. It ships a pretty solid configuration which should
work out of the box. Put the file to your project's root and perform a vagrant up
.
The Vagrantfile from this repo requires the following plugins to be installed:
- vagrant-bindfs
- vagrant-hostmanager
- vagrant-winnfsd (for Windows only)
To install a Vagrant plugin simply enter
$ vagrant plugin install <name>
There are some points in Vagrantfile you may adjust for your projects. To be able to run multiple instances on one host, you need to specify a unique static ip address.
Default values:
staticIpAddress = "192.168.12.2"
config.vm.hostname = "bionic.local"
Vagrantfile comes with a provisioning scripts, which updates the SSL certificate for apache, based on configured hostname.
- The default document root is
/var/www/html
- In MySQL/MariaDB use
root
/root
to login. An emptydefault
is existing. - For SSH use port 22 and credentials
vagrant
/vagrant
. You can also use theprivate_key
in .vagrant folder. - To open Mailcatcher use port 1080: http://bionic.local:1080
- Supports
vagrant share
(with ngrok installed)
In home directory of Vagrant user are some php.ini files located, which are sym-linked in conf.d folders of php versions. The following files are existing:
- php-x.y.ini Just used with PHP x.y (e.g php-7.4.ini)
- php-all.ini Used with all versions (not CLI)
- php-cli.ini Used for CLI
- php-xdebug.ini Settings for XDebug (remote debugging enabled by trigger, profiling prepared but disabled by default)
The paths /etc/apache2
, /etc/php
and /etc/mysql
have got write permissions for Vagrant user,
which allows you to edit system configuration with e.g. WinSCP, without need to perform sudo
on CLI.
To switch the current PHP version just execute:
$ sudo ~/enable-php/7.2.sh
Available versions are:
- 5.6.sh
- 7.0.sh
- 7.1.sh
- 7.2.sh
- 7.3.sh
- 7.4.sh (enabled by default)
Apache server will get automatically restarted and also the CLI PHP version will get changed.
The virtual hard disk shipped with ArminVieweg/ubuntu-bionic64-lamp stores up to 100 GB by default.
New instances of this box require ~5GB of disk space.
As a PHP developer I'm working very much with the dependency manager Composer. A disadvantage of working with virtual machines, are the separated disks each VM has. So composer will always download dependencies when executed first time in VM.
To avoid that, you can create a Vagrantfile in .vagrant.d folder in your home directory, with this content:
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# Mounting Composer cache to all VMs
config.vm.synced_folder "/path/to/composer/home/cache", "/var/nfs-composer-cache", type: "nfs"
config.bindfs.bind_folder "/var/nfs-composer-cache", "/home/vagrant/.cache/composer", perms: "u=rwX:g=rwX:o=rD"
end
This will mount your local composer cache, on host, to VM and every cached package will be installed instantly.