This is a Vagrant box provisioned using plain old bash shell scripting. Avoid this box if you are hip, trendy, or both; they will all laugh at you.
This setup is for newcomers to Web development. It is also for veterans looking to add virtualization to their development toolbelt without being inundanted by a hefty learning curve that involves a tonne of trendy new technologies and nomenclatures. This is why Bash is the provisioner. It is familiar; it is easy to understand. Once familiarity takes hold, I encourage you to start looking at more advanced build processes.
There will come a time when saltstack
or ansible
will be used, but that
will also exist in a different repo.
vagrantshell
includes a vshell
Bash utility for managing certain tasks
related to the box. By default it is symlinked into $HOME/bin
, so it may
already be available. If not, it is located in /vagrant/bin
; it is
recommended to add it to the box's path: export PATH="/vagrant/bin:$PATH"
.
vshell 2.0.0
'vshell' is used for managing the vagrantshell VM.
Usage:
vshell [ Options ]
Options:
help Show this usage message.
map Map contents of /vagrant/etc/ into core /etc/.
restart Restart multiple daemons.
update Update vagrantshell from master.
xdebug Toggle PHP Xdebug on or off.
xhprof Toggle PHP XHProf on or off.
Examples:
Remap new /vagrant/etc/ files into core /etc/:
vshell map
Located at https://dev
is an index of various tools configured for this box.
It exposes the following:
phpinfo()
for easy viewing [https://dev/phpinfo.php
]sites
listing all virtual hosts installed [https://dev/sites
]logs
directory for provisioned daemons [https://dev/logs
]- linux-dash [
https://dev/linux-dash
] - xhgui XHProf profiler [
https://dev/xhgui
]
Read the changelog
below for more information. Version 2.0.0 (October 2, 2015)
introduced a major break from the previous version.
The default provider will be automatically selected according to Vagrant's
Basic Provider Usage
article. vagrantshell
defines Parallels first, because if it is available, it
will be used, then fallback to VirtualBox. Parallels is faster, but not free.
- VirtualBox (free)
- Parallels (licensed)
- CentOS 6.7
- Nginx 1.9+ (mainline branch)
- PHP 5.5+ (PHP-FPM & opcache)
- Percona 5.6+ (MySQL)
- Redis
- MongoDB
- Varnish 3.0+
- Node.js
- Xdebug (read below)
- Git 2.5+
- Rsync 3.1+
- The
SPDY
/HTTP2
protocol is activated for Nginx when usingHTTPS
.
This box is configured for high performance and makes low-level changes to the underlying OS. The configurations in place descend from a much larger, battle-hardened production environment, with tweaks made to memory allocation for this smaller VM (as well as development tweaks), so this box also serves as a good example of a performance-tuned stack.
In addition, it has specific VM-only configs that speed up NFS,
using cachefilesd
, which will seamlessly cache NFS-mounted files inside the
guest box's filesystem. Reads and writes are also improved using the tuned
utility.
These performance enhancements were implemented in response to the poor performance of Magento 1.8+ in a Vagrant environment based on VirtualBox. This box is useful for everyone, and will be especially fast for most frameworks and needs, because it was tuned for the slowest PHP framework in the industry--namely, Magento. The logic being that if Magento performs very well on this box, everything else will fly.
If the Parallels provider is used, there will be an additional performance boost.
The average install time on a MBP 15" Retina / [email protected] * 8 / 16 GB / 512GB SSD
with 25Mbps
down:
- VirtualBox (~30 minutes)
- Parallels (~14 minutes)
If you are on Windows and are still using the basic command prompt, stop using it. It has nothing to offer. Use cmder.
This provider is free. If you have OSX, just use brew
, otherwise have a look
here:
https://www.virtualbox.org/wiki/Downloads
This provider requires a license. If you have OSX, just use brew
, otherwise
have a look here:
If you have OSX, just use brew
, otherwise have a look here:
https://www.vagrantup.com/downloads.html
These plugins correspond with the provider installed in the previous step.
Guest Additions plugin: vagrant plugin install vagrant-vbguest
https://github.com/dotless-de/vagrant-vbguest
Parallels plugin: vagrant plugin install vagrant-parallels
http://parallels.github.io/vagrant-parallels/docs/installation/
This is necessary so that the environment can be accessed in a browser. Edit
/etc/hosts
to include the following line:
192.168.80.80 dev vagrant.dev develop.vagrant.dev
On Windows, the file is located at C:\Windows\System32\Drivers\etc\hosts
.
-
Navigate to the directory you want to work from.
-
git clone [email protected]:danemacmillan/vagrantshell.git
orgit clone https://github.com/danemacmillan/vagrantshell.git
(if you do not have SSH keys). -
cd
into it.
⚠️ Note:vagrantshell
provisions mostly everything for modern development. Read about post-provision scripts below if adding additional content automation is required.
-
Run
vagrant up
in thevagrantshell
directory where theVagrantFile
file exists. -
Wait for everything to install. This can take about twenty minutes, depending on the connection.
From the vagrantshell
directory that contains the VagrantFile
file, run
vagrant ssh
. You are in CentOS as user, vagrant
. For root access,
type, sudo su
.
A default root directory of develop.vagrant.dev
will be created in sites
.
There is a wildcard vhost entry which will serve any content within the sites
directory, using the exact directory name created.
By default, the server parses documents from /vagrant/sites/develop.vagrant.dev
.
Additional sites can be created under /vagrant/sites
to test different
codebases. On your host machine, point your IDE or editor to
/your/local/path/vagrantshell/sites/develop.vagrant.dev
to make changes.
Browse to the address at develop.vagrant.dev
using HTTP
or HTTPS
. This
will work so long as the hosts file has been updated. Note that the SPDY
/
HTTP2
protocol will be used.
Create a new directory in sites
. Nginx will automatically pick up on it. A
corresponding /etc/hosts
entry should exist, otherwise the new directory will
be inaccessible. For example, create a directory, tests.vagrant.dev
or
foobar.dev
in sites
, and edit
the host's host file to include 192.168.80.80 foobar.dev
, then browse to it.
The directory name will be exactly what should be typed in a browser's
address bar.
Read the README.md
in post-provision
to see how post-provision scripts and
DB imports work.
Oddly, the dotfiles are not sourced during post-provision, so upon SSH'ing into
the box for the first time, run source ~/.dotfiles/dotfiles
. This will
change the color of your PS1 and add a tonne of handy functionality.
Xdebug is not enabled by default. It is configured according this tutorial:
https://danemacmillan.com/how-to-configure-xdebug-in-phpstorm-through-vagrant/
The xdebug.idekey
is PHPSTORM
, and the xdebug.remote_port
is 9000
. If
the provider is VirtualBox, the IP to connect to the host is 10.0.2.2
. If
the provider is Parallels, the IP to connect to the host is 192.168.0.1
.
To toggle debugging on, use vshell xdebug
. The state of the debug setting
will be displayed.
This vagrant provision includes the following dotfiles:
https://github.com/danemacmillan/dotfiles
It is installed during post-provision.
There is no reason why any framework or CMS would not work with this Vagrant box. Unless very custom server configurations are required, the defaults are plenty. However, this Vagrant box has been configured to easily allow such customizations.
This box is Magento-friendly. The proper variables and rewrites are included for Magento development. This does not mean only Magento can be developed on this box. The Magento settings do not change any other type of development. Magento version 1.9+ has been tested. Downgrading the version of PHP to 5.4 or 5.3 will increase compatibility for older releases of Magento.
Port 2368
from the guest is forwarded to port 2368
on the host. Instructions
to install and run an instance of the Ghost
blogging platform are available online.
Wordpress development is not an issue.
It works fast.
- Running
vagrant halt
and thenvagrant up
will cause the SELinux enforce policy to reactivate. This blocks Nginx from being accessible. Since CentOS 6.6 the SELinux policy for Nginx has been changed. For the meantime, after Vagrant has been booted, SSH into the box and runsetenforce 0
as root. Restart Nginx/etc/init.d/nginx restart
and PHP-FPM/etc/init.d/php-fpm restart
. The server will devliver content once again.
The entire structure of the repository was changed. If a fork from before this date exists, it will no longer be compatible with this version.
The MIT License (MIT)
Copyright (C) 2015 vagrantshell - Released under the MIT License.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.