Run PHP application with vagrant in very fast way

Article describes how to configure virtual machine on your linux (I’m using Linux mint).

First of all you should install virtual box:

sudo apt-get install virtualbox

Also we will need vagrant, I suggest to install it from:
http://www.vagrantup.com/downloads.html
Now we need scripts, easiest and fastest way is to go to:  https://puphpet.com/ and there generate vagrant and puppet scripts:

  • Select operating system
  • Name your VM, mine will be: example.dev
  • Change IP address: I changed to 11.11.11.11
  • Change your select box sync source. for example: /var/www/example/
  • Select shared folder type: NFS
  • Change server name and server aliases. For example: example.dev and www.example.dev
  • Change document root
  • Select PHP version
  • Change database settings for your needs
  • Take your script

After downloading and extracting the script usually I just rename it’s directory to _vagrant. Than I move it to my project directory.

Before running script you should go to your hosts file (probably it will be in /etc/hosts) and add your vagrant machine IP address and server name.

[easy_ad_inject_1]

In my case I would add:

11.11.11.11 example.dev

Important: there is NFS bug in script, puppet scripts does not start, so before first run of “vagrant up” you should to set

:nfs => true

to

:nfs => false

When _vagrant directory was moved to your project, you should navigate with terminal to _vagrant directory and type: “vagrant up”.

After that you should see that script is downloading VM and later installing from puppet scripts PHP, MySQL, git, etc…

Now you can check if everything went well and type to your browser server name. In my case it would be: http://example.dev/

We can see that everything works so let’s make NFS to work. Go to ./_vagrant/vagrantfile and change from “:nfs => false” to “:nfs => true”. No type in terminal “vagrant reload” to reload virtual machine. After this your virtual machine will work with NFS enabled.