Vagrant for PHP development environment
What is Vagrant?
I asked this question before, I think is about 1 year+ ago. Many times, I search for it, but couldn't understand how it work.
Until recently, I found that Laravel also recommended it. I tried and eventually I found it really useful!
Generate ssh key
Navigate to your development folder, e.g.
Clone the Laravel configuration for Vagrant (we're refering to Laravel's vagrant file)
Assuming that all projects are hosted on the same VM.
The configuration files stored in
Edit the file Homestead.yaml, refer to Laravel doc for complete information.
There are few things you need to change
Just an example here, look at the section folders, it actually created a shared folder in the VM.
~/dev/web is the local folder which keep all the web project (make sure it exists before you run
vagrant up), whereas the
/home/vagrant/dev will be inside the VM
For sites, is actually the virtual hosts for a particular project, in this example is to map
laravel.homestead.com to the project named
Now you can create the VM
Now edit your /etc/hosts file, by adding the following line
(the ip address was in your ~/.homestead/Homestead.yaml)
Create a new laravel project (if you don't know how to install laravel, refer http://laravel.com/docs/5.0)
Now open up your browser, and type in the address laravel.homestead.com, and you will see the page!
You can remain your development in the host OS, but host the project in VM.
You can actually verify this by open a new terminal
Now you logged in to the VM
Go back to the previous terminal, create a dummy file
Switch back to the second terminal
Means now you can create any other PHP projects beside Laravel in this environment as you like.
Enjoy yourself :)