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

Setup Tailwind CSS with Angular 11

Install tailwind css with npm Run the following command to install tailwind css npm install…

1 year ago

How to setup laravel project using homestead

Step 1 : Create a new directory Homestead by using this command  cd ~/Homestead Step…

1 year ago

NPM vs NPX

npx and npm are both command line tools that are used to install and run…

1 year ago

Guide To Naming Conventions

Specifically, there are certain naming conventions available across all programming languages, also known as Snake…

1 year ago

How to use a CORS proxy to avoid “No Access-Control-Allow-Origin header” problems

If you want to solve the Access-Control-Allow-Orgin header problems, you can setup the cors proxy.…

1 year ago

React Native Hybrid with Ease

React Native Hybrid: Is React native hybrid? a popular question that mostly developers asked. Let…

2 years ago

This website uses cookies.