Vagrant Provisioning Bash Scripts
The goal of this project is to create easy to use bash scripts in order to provision a Vagrant server.
- This targets Ubuntu LTS releases, currently 12.04.*
- This project will give users various popular options such as LAMP, LEMP
- This project will attempt some modularity. For example, users might choose to install a Vim setup, or not.
Some further assumptions and self-imposed restrictions. If you find yourself needing or wanting the following, then other provisioning tool would better suited (Chef, Puppet, Ansible).
- If other OSes need to be used (CentOS, Redhat, Arch, etc).
- If dependency management becomes complex. For example, installing Laravel depends on Composer. Setting a document root for a project will change depending on Nginx or Apache. Currently, these dependencies are accounted for, but more advanced dependencies will likely not be.
First, Copy the Vagrantfile from this repo. You may wish to use curl or wget to do this instead of cloning the repository.
# curl
curl -L http://bit.ly/vaprobash > Vagrantfile
# wget
wget -O Vagrantfile http://bit.ly/vaprobash
The
bit.ly
link will always point to the master branch version of the Vagrantfile.
Second, edit the Vagrantfile
and uncomment which scripts you'd like to run. You can uncomment them by removing the #
character before the config.vm.provision
line.
You can indeed have multiple provisioning scripts when provisioning Vagrant.
# Provision Apache Base
# config.vm.provision "shell", path: "https://raw.github.com/fideloper/Vaprobash/master/scripts/lamp.sh"
# Provision Nginx Base
# config.vm.provision "shell", path: "https://raw.github.com/fideloper/Vaprobash/master/scripts/lemp.sh"
# Provision MySQL
# config.vm.provision "shell", path: "https://raw.github.com/fideloper/Vaprobash/master/scripts/mysql.sh"
# Provision Vim
# config.vm.provision "shell", path: "https://raw.github.com/fideloper/Vaprobash/master/scripts/vim.sh"
# Provision Composer
# config.vm.provision "shell", path: "https://raw.github.com/fideloper/Vaprobash/master/scripts/composer.sh"
# Provision Laravel
# config.vm.provision "shell", path: "https://raw.github.com/fideloper/Vaprobash/master/scripts/laravel.sh"
# Install Memcached
# config.vm.provision "shell", path: "https://raw.github.com/fideloper/Vaprobash/master/scripts/memcached.sh"
Third and finally, run:
$ vagrant up
The following setups are installable via the separate bash scripts of this repository.
This will install:
- Apache 2.4.*
- PHP 5.5 mod_php5
- This vhost bash script is installed to get you started with setting up a virtual host. This will make use of xip.io, creating a virtual host for 192.168.33.10.xip.io.
By default, the web root will the /vagrant
, which I suggest you change as needed (within /etc/apache2/sites-available/192.168.33.10.xip.io.conf
). The Laravel installation script will change the document root.
This will install:
- Nginx 1.1.*
- PHP 5.5 via php5-fpm
This makes use of xip.io, creating a virtual host for 192.168.33.10.xip.io.
By default, the web root will the /vagrant
, which I suggest you change as needed (within /etc/nginx/sites-available/vagrant
). The Laravel installation script will change the document root.
This will install the MySQL 5 database.
- Host:
localhost
or192.168.33.10
- Username:
root
- Password:
root
This will install a Vim setup, including:
- Vundle
- Bundle 'altercation/vim-colors-solarized'
- Bundle 'plasticboy/vim-markdown'
- Bundle 'othree/html5.vim'
- Bundle 'scrooloose/nerdtree'
- Bundle 'kien/ctrlp.vim'
See the .vimrc file for more details and configuration.
This will install composer and make it globally accessible.
This will install a base Laravel (latest stable) project within /vagrant/laravel
. It depends on Composer being installed.
This will also attempt to change the Apache or Nginx virtual host to point the document root at /vagrant/laravel/public
.
The vagrant file does two things you should take note of:
- Gives the virtual machine a static IP address of 192.168.33.10. This IP address is again hard-coded (for now) into the LAMP, LEMP and Laravel installers. This static IP allows us to use xip.io for the virtual host setups while avoiding having to edit our computers'
hosts
file. - Uses NFS instead of the default file syncing. NFS is reportedly faster than the default syncing for large files. If, however, you experience issues with the files actually syncing between your host and virtual machine, you can change this to the default syncing by deleting the lines setting up NFS:
config.vm.synced_folder ".", "/vagrant",
id: "core",
:nfs => true,
:mount_options => ['nolock,vers=3,udp,noatime']
- Test variations further
- Make gitconfig (but not git) a separate install?
- Community additions? Memcached, redis, postgresql, node, ruby, python, sass, less, fish/zsh