Through the years, I’ve tested several different environments for the most efficient development process. I’m happy to announce that I’ve found the perfect one for me and let me share it with you. First of all, lets start with the setup process. It takes no more than 5 minutes to finish configuration on any *n?x based machinery.
What you need is downloading Oracle VM VirtualBox and Vagrant itself. After you’ve finished the setup for both, open up your terminal (Alt + T for Debian based OS, CMD + Space and write Terminal for Mac OS X). Create a new virtual box of Homestead using the command
vagrant box add laravel/homestead
It will ask you for which Virtual Machine should it install the Homestead. Choose VirtualBox as that’s what you’ll be using. While the box is being downloaded and added, open a new Tab in the Terminal (CMD + T for OS X, CTRL + SHIFT +T for Debian) and enter the command sequence:
git clone https://github.com/laravel/homestead ~/homestead && cd ~/homestead && bash init.sh
Afterwards, when Homestead is initialized, there will be a new file created in the ~/homestead directory called Homestead.yaml. This is the file you’ll be mainly functioning with. It’s pretty self-explanationary, and it should look something like this:
So what we understand from there, all of the hosts will be functioning through 192.168.10.10 IP address and the sources are located in ~/Code/PHP/ directory (~ stands for home). Structure is map domain.tld to ~/Code/PHP/domain.tld folder in your machinery, which will be linked to /home/vagrant/code/domain.tld in the virtual box. Of course, you can choose the folder structure as you wish. Also, as you can see, there are extra parameters such as php, which will allow you to specify PHP version to be used for the domain.
To bind the domains to your actual machine, you need to edit your hosts file located in “/etc/hosts“, so
sudo nano /etc/hosts
Should bring out something similar to this, after entering computers password:
Where you specify 192.168.10.10 (use TAB instead of space) domain.tld for each and every domain name you want to use and then save the file using CTRL + X, enter Y and press ENTER.
At this point, we’re almost done. If you haven’t done that before, you’ll need to open up Terminal once again and enter
ssh-keygen -t rsa -b 4096 -C "email@example.com"
Now, lets go back to ~/homestead directory and do the magical command that you should memorize:
vagrant up --provision
Note that you need –provision switch only when there’s some changes made in the Homestead.yaml file. Else, you can just use vagrant up.
After you see that the machine has booted, use your favorite browser to navigate to any of the domains specified in the Homestead.yaml and /etc/hosts files. If everything works great, congratulations. If you have “No input file specified” outputted, check your paths in the Homestead.yaml file.
If you have any further questions or problems, feel free to ask them in the comments.