Create a directory where you want to store project such as
mkdir ~/vagrant_projects
Now go to the vagrant directory
cd vagrant_projects
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
Creating a vagrant SSH session by running command
vagrant ssh
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
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
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
After changing in the vagrant file, you need to reload your virtual machine. Run this command
vagrant reload -provision
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
After Changing the vagrant file, again run this command for changes
vagrant reload --provision
After this , run the command for starting SSH session
vagrant ssh
Now go to vagrant (laravel project directory) by using this command
cd vagrant/html/test
Now run a laravel project by this command
php artisan serve --host 192.168.33.10 --port 8000
Bash Script Basics Bash scripting is a powerful way to automate tasks in Linux. This…
Screen vs Tmux Both screen and tmux are popular terminal multiplexers that allow you to…
How to Use nohup The nohup command allows you to run a script or command…
Running Bash script in background Running Bash script in the background is useful for executing…
How do I make Git ignore file mode (chmod)? Git is a powerful version control…
Install tailwind css with npm Run the following command to install tailwind css npm install…
This website uses cookies.