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

How to Choose the Right CCTV System in Singapore

Choosing the right CCTV system is an important step in protecting your home, office, retail…

1 week ago

Bash Script Basics Tutorial: #1

Bash Script Basics Bash scripting is a powerful way to automate tasks in Linux. This…

2 years ago

Screen vs Tmux: Which One to Choose?

Screen vs Tmux Both screen and tmux are popular terminal multiplexers that allow you to…

2 years ago

How to Use nohup

How to Use nohup The nohup command allows you to run a script or command…

2 years ago

Running Bash script in background

Running Bash script in background Running Bash script in the background is useful for executing…

2 years ago

How do I make Git ignore file mode (chmod)?

How do I make Git ignore file mode (chmod)? Git is a powerful version control…

2 years ago

This website uses cookies.