Al-Amin's Blog

How to install Laravel Homestead virtual machine on your Linux Computer ?

  Al-Amin Sarker  |   16 Jun, 2020 |   Laravel |   view 243 times

Homestead is a virtual development environment for Laravel. It’s supper easy to install and use on your machine. Before using Laravel Homestead, you have VirtualBox and Vagrant installed on your machine.

First, you have to install VirtualBox package, which is available in the ubuntu’s repositories. You may use the terminal command to install it on your computer.

	sudo apt install virtualbox

After installed the VirtualBox, you may need to install the Vagrant to your computer. Use bellow the command for it:

	sudo apt install vagrant

If you will get any problem to installed current version of Vagrant above that command, you may download the Vagrant package using the curl command:

	curl -O

Once the .deb file is downloaded, install it by using this command:

	sudo apt install ./vagrant_2.2.9_x86_64.deb

After installed, you may check the version of Vagrant by using this command:

	vagrant --version

Once, VirtualBox and Vagrant installed, you should add the laravel/homestead box to your vagrant installation using the command. It will take a few minutes to download the box.

	vagrant box add laravel/homestead

Now, you may install Homestead by cloning the repository onto your host machine. Consider cloning the repository into a Homestead folder within your "home" directory, as the Homestead box will serve as the host to all of your Laravel projects:

	git clone ~/Homestead

Once you have cloned the Homestead repository, run the bash command from the Homestead directory to create the Homestead.yaml configuration file. The Homestead.yaml file will be placed in the Homestead directory:


Configuring Shared Folders
The folders property of the Homestead.yaml file lists all of the folders you wish to share with your Homestead environment. As files within these folders are changed, they will be kept in sync between your local machine and the Homestead environment. You may configure as many shared folders as necessary:

		-map: ~/code/project1
		  to: /home/vagrant/project1
		-map: ~/code/project2
		  to: /home/vagrant/project2

Configuring Nginx Sites
The sites property allows you to easily map a "domain" to a folder on your Homestead environment. A sample site configuration is included in the Homestead.yaml file. Again, you may add as many sites to your Homestead environment as necessary. Homestead can serve as a convenient, virtualized environment for every Laravel project you are working on:

	    - map: project1.test
	       to: /home/vagrant/project1/public

	     -map: project2.test
	       to: /home/vagrant/project2/public

If you change the sites property after provisioning the Homestead box, you should re-run vagrant reload --provision to update the Nginx configuration on the virtual machine.

If you host multiple sites on a single Homestead instance, you may add the "domains" for your web sites to the hosts file on your machine. The hosts file will redirect requests for your Homestead sites into your Homestead machine. On Mac and Linux, this file is located at /etc/hosts.

Open ubuntu hosts file by using this command:

	sudo nano /etc/hosts

And add your domain name on this hosts file. This domain name should be similar with sites property in your Homestead.yaml file.  project1.test  project2.test

Make sure the IP address listed is the one set in your Homestead.yaml file. Once you have added the domain to your hosts file and launched the Vagrant box you will be able to access the site via your web browser:


Once you have edited the Homestead.yaml to your liking, run the vagrant up command from your Homestead directory. Vagrant will boot the virtual machine and automatically configure your shared folders and Nginx sites.

Subscribe to newsletter

About Al-Amin Sarker

Profile Picture

Al-Amin Sarker is a Bangladesh times best Web Engineer. He helps to build web based software. He studied at Computer Science and Engineering in Rajshahi University, Rajshahi, Bangladesh. He has more than 6 years of experience on building robust and scalable web applications (not websites) with cutting edge technologies Continue reading...

Do you love my source code ?

Hire me to Develop

Do you want me to
Develop at
Your Software ?
Click here to Hire

facebook box