Categories: Uncategorized

Configure laravel project in vagrant box in ubuntu

Step 1:

Create a directory where you want to store project such as 

mkdir ~/vagrant_projects

Now go to the vagrant directory

cd vagrant_projects

Step 2:

Install a vagrant box by run this command

vagrant init sternpunkt/jimmybox

Step 3:

Install vagrant box and run vagrant on virtually by running this command

Step 4:

Creating a vagrant SSH session by running command 

vagrant ssh

Step 5:

After this, you are in the home directory of vagrant , go to vagrant directory by cd vagrant and create a new folder named html. This folder is created in host machine vagrant_projects folder. Copy your laravel project into this folder. Suppose laravel project name is test

Step 6:

Now we creating a soft link by using shell script. Create following shell script and save it as bootstrap.sh in the same directory as your Vagrant file.

#!/usr/bin/env bash

if ! [ -L /var/www ]; then rm -

rf /var/www

ln -fs /vagrant /var/www

fi

Step 7:

Now add line in vagrant file

config.vm.provision :shell, path: "bootstrap.sh"

By editing the Vagrant file. It which should now look like this.

Vagrant.configure("2") do |config|

config.vm.box = "hashicorp/bionic64

config.vm.provision shell, path: "bootstrap.sh"

end

Step 8:

After changing in the vagrant file, you need to reload your virtual machine. Run this command

vagrant reload -provision

Step 9:

Now you need to configure a private network ip in which your guest machine runs . Add a line in vagrant file

config.vm.network "private network", ip "192.168.33.10"

You also need to setup a port forwarding for your guest machine . Add this line to vagrant file

config.vm.network "forwarded_port", guest: 8000, host:8000

Step 10:

After Changing the vagrant file, again run this command for changes

vagrant reload --provision 

Step 11

After this , run the command for starting SSH session

vagrant ssh

Step 12:

Now go to vagrant (laravel project directory) by using this command

cd vagrant/html/test

Step 13

Now run a laravel project by this command

php artisan serve --host 192.168.33.10 --port 8000

 

http://192.168.33.10

Cool Dev

Share
Published by
Cool Dev

Recent Posts

Dental Implants Cost in Ohio: Local Quote Guide

Compare dental implant costs in Ohio with a clear quote checklist. Check final teeth, extra…

2 days ago

Dental Implants Cost in Illinois: Local Quote Guide

Compare dental implant costs in Illinois with a clear quote checklist. Check final teeth, extra…

2 days ago

Dental Implants Cost in Pennsylvania: Local Quote Guide

Compare dental implant costs in Pennsylvania with a clear quote checklist. Check final teeth, extra…

2 days ago

Dental Implants Cost in North Carolina: Local Quote Guide

Compare dental implant costs in North Carolina with a clear quote checklist. Check final teeth,…

2 days ago

Dental Implants Cost in Georgia: Local Quote Guide

Compare dental implant costs in Georgia with a clear quote checklist. Check final teeth, extra…

2 days ago

Dental Implants Cost in Arizona: Local Quote Guide

Compare dental implant costs in Arizona with a clear quote checklist. Check final teeth, extra…

2 days ago

This website uses cookies.