Prahlad Inala
Prahlad Inala

Follow

Prahlad Inala

Follow
Complete Guide to Vagrant

Complete Guide to Vagrant

Prahlad Inala's photo
Prahlad Inala
ยทMar 4, 2023ยท

21 min read

Play this article

What is Vagrant

Vagrant is a command-line tool used for managing and building virtual machine environments in a single workflow. It is designed to make it easy to create and configure virtual machines, which can be used to develop and test software across different operating systems and platforms.

With Vagrant, developers can set up a development environment that closely resembles a production environment, reducing the likelihood of issues and increasing the overall quality of code. It allows for reproducibility and consistency across development and production environments.

Vagrant uses a provider-based architecture, which means it can support various virtualization technologies such as VirtualBox, VMware, and Docker. Vagrantfiles, which are simple configuration files, can be used to define the virtual machine's operating system, memory, and other settings.

History of Vagrant

Vagrant was created by Mitchell Hashimoto and John Bender in 2010, while they were working on a project for their company. They were frustrated by the difficulties of setting up consistent development environments across different machines and decided to create a tool that would make it easier to manage virtual environments.

The initial version of Vagrant was released in 2010, and it quickly gained popularity among developers who were looking for a better way to manage their virtual environments. Over the years, Vagrant has evolved and added many new features, such as support for different virtualization providers, cloud integration, and advanced networking and storage features.

In 2015, HashiCorp, the company founded by Mitchell Hashimoto, acquired Vagrant and has since continued to develop and support the project. Vagrant is now part of a larger suite of tools provided by HashiCorp, including Terraform, Consul, and Vault.

Today, Vagrant is widely used by developers and development teams around the world and has become an essential tool for building, testing and deploying software applications. Its simplicity, flexibility, and ease of use make it a popular choice for managing virtual environments in a variety of different contexts, from individual development projects to large-scale enterprise applications.

Benefits of Vagrant

  1. Portability:

    Vagrant can be used on different operating systems and platforms, allowing developers to work on different machines without worrying about compatibility issues.

  2. Reproducibility:

    Vagrant makes it easy to create a standardized environment that can be easily shared among team members or used to recreate an environment for testing or debugging.

  3. Consistency:

    With Vagrant, developers can ensure that their development environment is consistent across different machines, reducing the likelihood of issues caused by differences in the environment.

  4. Efficiency:

    Vagrant automates the process of setting up and configuring virtual machines, saving developers time and increasing productivity.

Getting Started with Vagrant

Getting started with Vagrant is easy. The first step is to install Vagrant and a virtualization provider, such as VirtualBox. Once installed, developers can use the Vagrant command-line tool to manage and configure virtual machines. Developers can also create and share their Vagrant boxes, which are pre-configured virtual machine images, with others in the community.

To use Vagrant, you typically start by creating a Vagrantfile, which is a configuration file that defines the settings and specifications of the virtual machine environment. The Vagrantfile can be created using a text editor and saved in the root directory of the project.

The Vagrantfile contains various sections, including the virtual machine's operating system, memory, CPU, network settings, and any additional software that needs to be installed. Once the Vagrantfile is created, developers can use the Vagrant command-line tool to create, configure, and manage the virtual machine environment.

Basic Commands

  1. vagrant up: This command creates and configures the virtual machine according to the settings specified in the Vagrantfile.

  2. vagrant ssh: This command allows developers to access the virtual machine via SSH and perform various operations within the virtual machine.

  3. vagrant halt: This command stops the virtual machine, preserving its current state.

  4. vagrant destroy: This command removes the virtual machine and all its associated resources.

In addition to these basic commands, Vagrant provides many other features and plugins that can enhance the virtual machine environment's functionality, such as provisioners, which automate the process of installing software and configuring the virtual machine.

Vagrant also has a large community of developers who create and share Vagrant boxes, which are pre-configured virtual machine images that can be easily downloaded and used. These boxes can be used to set up a development environment quickly, saving developers time and effort.

In conclusion, Vagrant is an essential tool for developers who want to create and manage virtual machine environments easily. By providing a standardized workflow for building and configuring virtual machines, Vagrant allows developers to focus on writing quality code without worrying about compatibility or environment issues.

Features of Vagrant

  1. Multi-machine support: Vagrant allows developers to create and manage multiple virtual machines simultaneously, allowing them to test complex distributed systems and network configurations.

  2. Synced folders: With Vagrant, developers can easily share files and folders between the host machine and the virtual machine, allowing them to work on code and files on their host machine while testing it in the virtual machine.

  3. Networking: Vagrant allows developers to configure the virtual machine's network settings, such as port forwarding and private networks, to test and debug applications in a secure environment.

  4. Plugins: Vagrant has a large library of plugins that can enhance its functionality, such as plugins for configuring provisioners, automating development workflows, and integrating with cloud providers.

  5. Provisioning: Vagrant provides various provisioning tools such as Ansible, Puppet, and Chef, allowing developers to automate the process of installing and configuring software on the virtual machine.

  6. Box creation: Vagrant allows developers to create and distribute their Vagrant boxes, which are pre-configured virtual machine images that can be used to set up a development environment quickly.

Vagrant also integrates well with other tools commonly used in the software development process, such as version control systems like Git and continuous integration tools like Jenkins. With its flexible configuration options and support for multiple virtualization technologies, Vagrant can be easily integrated into any software development workflow.

Moreover, Vagrant is an open-source project, meaning that its code is freely available to anyone who wants to use, modify, or contribute to it. This open-source nature of Vagrant has resulted in a large and active community of developers who contribute to the project, creating new plugins, fixing bugs, and adding new features.

Vagrant's popularity has led to the creation of many tools and services that complement or extend its functionality, such as Vagrant Manager, which provides a graphical user interface for managing Vagrant environments, and Vagrant Cloud, which is a cloud-based service for hosting and sharing Vagrant boxes.

Finally, Vagrant can also be used in production environments, where it can be used to deploy and manage applications in a standardized and reproducible way, ensuring that the environment is consistent across different machines and platforms.

Best Practises

  1. Keep the Vagrantfile in version control: The Vagrantfile should be treated as any other code artifact and kept in version control, so it can be easily shared and tracked over time.

  2. Use provisioning tools: Provisioning tools such as Ansible, Puppet, or Chef should be used to automate the installation and configuration of software in the virtual machine environment.

  3. Use synced folders: Synced folders should be used to share files and folders between the host machine and the virtual machine, allowing developers to work on code and files on their host machine while testing it in the virtual machine.

  4. Use a single Vagrantfile for each project: Each project should have its own Vagrantfile, as different projects may have different requirements for virtual machine configurations.

  5. Use Vagrant boxes from trusted sources: Vagrant boxes should be downloaded from trusted sources to ensure that they are secure and free of malware.

  6. Clean up unused Vagrant boxes: Unused Vagrant boxes should be deleted to free up disk space and avoid clutter.

  7. Use Vagrant Cloud for sharing boxes: Vagrant Cloud should be used for sharing boxes with other developers, as it provides a secure and centralized repository for Vagrant boxes.

By following these best practices, developers can ensure that their Vagrant environments are well-managed, efficient, and secure.

Vagrant Cloud

Vagrant Cloud is a cloud-based service provided by HashiCorp that allows you to store, distribute, and discover Vagrant boxes. It provides a central repository for sharing Vagrant boxes, making it easy to collaborate on development projects and distribute development environments.

Using Vagrant Cloud, you can upload and share your own custom Vagrant boxes, or browse and download boxes created by others. You can also use Vagrant Cloud to manage access to your boxes, control versioning, and track usage statistics.

Key Features of Vagrant Cloud

  1. Box hosting: Vagrant Cloud provides a secure and reliable hosting service for Vagrant boxes, making it easy to share and distribute your boxes.

  2. Box discovery: Vagrant Cloud makes it easy to discover new Vagrant boxes, search for boxes by operating system, provider, or other criteria, and browse popular boxes.

  3. Access control: Vagrant Cloud allows you to control access to your boxes, set permissions for individual users or teams, and manage versioning and updates.

  4. Collaboration: Vagrant Cloud makes it easy to collaborate on development projects, share development environments with team members, and keep everyone on the same page.

  5. Integration: Vagrant Cloud integrates with other HashiCorp tools such as Terraform and Consul, allowing you to easily create, manage, and deploy infrastructure.

    To use Vagrant Cloud, you need to create a free account and sign in using your HashiCorp account credentials. Once you are signed in, you can create and manage your own Vagrant boxes, or browse and download boxes created by others. You can also use Vagrant Cloud to collaborate with other users, track usage statistics, and manage access to your boxes.

Vagrant Box

A Vagrant box is a pre-configured virtual machine that is used as a starting point for building and managing virtual environments. It contains an operating system image, configured software, and other necessary components.

When you use Vagrant, you start by downloading a base box from a box repository, such as HashiCorp's Atlas or Vagrant Cloud. The base box serves as a template for creating a new virtual machine. You can then customize the virtual machine using a Vagrantfile, which specifies the virtual machine's configuration settings, such as its network settings, synced folders, and provisioners.

Once you have configured your Vagrantfile, you can start the virtual machine by running the vagrant up command. Vagrant will use the base box to create a new virtual machine with the specified configuration settings. You can then connect to the virtual machine using SSH or other remote access methods.

Vagrant boxes can be shared with others, making it easy to distribute development environments and ensure consistency across different development teams. You can also create your own custom boxes by packaging up a virtual machine that you have configured yourself.

There are many pre-configured boxes available for Vagrant, including boxes for popular operating systems such as Ubuntu, CentOS, and Windows. You can also find boxes for specific development environments, such as Ruby on Rails, Python, and Node.js.

VagrantFile Configuration

A Vagrantfile is a configuration file that specifies how to create and configure a virtual machine using Vagrant. The Vagrantfile is written in Ruby and contains a series of instructions that Vagrant uses to set up the virtual machine.

  1. config.vm.box

    This setting specifies the base box that Vagrant should use to create the virtual machine. A base box is a pre-built virtual machine image that contains an operating system and other software.

  2. config.vm.network

    This setting specifies the networking configuration for the virtual machine. This includes things like the IP address, network interfaces, and port forwarding rules.

  3. config.vm.provider

    This setting specifies the virtualization provider that Vagrant should use to create the virtual machine. Vagrant supports multiple virtualization providers, including VirtualBox, VMware, and Hyper-V.

  4. config.vm.synced_folder

    This setting specifies folders that should be shared between the host machine and the virtual machine. This allows you to easily transfer files between the two environments.

  5. config.vm.provision

    This setting specifies how the virtual machine should be provisioned with software and configurations. Vagrant supports multiple provisioners, including shell scripts, Chef, Puppet, and Ansible.

  6. config.vm.hostname

    This setting specifies the hostname for the virtual machine. This is the name that the machine will use to identify itself on the network.

  7. config.vm.boot_timeout

    This setting specifies the amount of time that Vagrant should wait for the virtual machine to boot before giving up.

  8. config.vm.box_check_update

    This setting specifies whether Vagrant should check for updates to the base box before creating the virtual machine.

  9. config.ssh.forward_agent

    This setting specifies whether SSH agent forwarding should be enabled. This allows you to use your local SSH keys when logging into the virtual machine.

  10. config.vm.post_up_message

    This setting specifies a message that should be displayed after the virtual machine has been created.

  11. config.vm.box_url

    This setting specifies the URL where Vagrant should download the base box if it's not already present on the host machine.

  12. config.vm.guest

    This setting specifies the guest operating system that the virtual machine will run. This is useful if you want to use a different operating system than the default for the base box.

  13. config.vm.usable_port_range

    This setting specifies the range of ports that can be used for port forwarding.

  14. config.vm.provider "virtualbox" do |vb|

    This block specifies VirtualBox-specific settings for the virtual machine, such as the amount of memory and CPU cores to allocate to the machine.

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

    This command provisions the virtual machine with a shell script located at the specified path. The script can be used to install software, configure the environment, and perform other tasks.

  16. config.vm.box_version

    This setting specifies the version of the base box to use when creating the virtual machine. This is useful if you need to use a specific version of the operating system or software.

  17. config.vm.provider "vmware_fusion" do |v|

    This block specifies VMware-specific settings for the virtual machine, such as the amount of memory and CPU cores to allocate to the machine.

  18. config.vm.provision "ansible_local" do |ansible|

    This command provisions the virtual machine with Ansible, a popular configuration management tool. The ansible_local option specifies that Ansible should be installed on the guest machine.

  19. config.vm.provider "hyperv" do |h|

    This block specifies Hyper-V-specific settings for the virtual machine, such as the amount of memory and CPU cores to allocate to the machine.

  20. config.vm.define "web" do |web|

    This command defines a named virtual machine in the Vagrantfile. This is useful if you need to create multiple virtual machines with different configurations.

Vagrant File

most commonly used commands in a Vagrantfile

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

    This command initializes a new Vagrant configuration block and sets the version of the Vagrantfile to "2". This block is where you will define the various settings and configurations for your virtual machine.

  2. config.vm.box = "ubuntu/focal64"

    This command sets the base box that will be used to create the virtual machine. A base box is a preconfigured virtual machine image that includes a particular operating system and any additional software or configurations you may need. In this example, we are using the "ubuntu/focal64" box, which is a base box for Ubuntu 20.04 LTS.

  3. config.vm.network "forwarded_port", guest: 80, host: 8080

    This command forwards a port from the guest machine (the virtual machine) to the host machine (the computer running Vagrant). In this example, we are forwarding port 80 (the default HTTP port) from the guest machine to port 8080 on the host machine.

  4. config.vm.provision "shell", inline: <<-SHELL ... SHELL

    This command provisions the virtual machine with a shell script. Provisions are used to install software, configure settings, and perform other tasks on the virtual machine during its creation or later on. In this example, we are using a shell provision to install and configure Apache, PHP, MySQL, Git, and Composer.

  5. config.vm.provider "virtualbox" do |vb|

    This command specifies the provider to use for the virtual machine. A provider is the underlying software that actually creates and manages the virtual machine. In this example, we are using VirtualBox as the provider.

  6. config.vm.synced_folder "src/", "/srv/website"

    This command sets up a synced folder between the host and guest machines. Synced folders allow you to share files between the two machines, making it easy to develop and test code on the host machine and run it on the guest machine. In this example, we are syncing the "src/" directory on the host machine with the "/srv/website" directory on the guest machine.

  7. config.vm.hostname = "webserver"

    This command sets the hostname for the virtual machine. The hostname is the name that the machine will use to identify itself on the network. In this example, we are setting the hostname to "webserver".

  8. config.vm.boot_timeout = 300

    This command sets the boot timeout for the virtual machine, which is the amount of time that Vagrant will wait for the machine to boot up before timing out. The default timeout is 120 seconds, but you can increase it with this command if your machine takes longer to boot up.

  9. config.vm.provider "virtualbox" do |vb| vb.memory = "1024"

    This command sets the amount of memory to allocate to the virtual machine. In this example, we are using the VirtualBox provider and setting the memory to 1024 MB.

  10. config.vm.provision "ansible" do |ansible|

    This command provisions the virtual machine with Ansible, a popular configuration management tool. Ansible allows you to automate the setup and configuration of your virtual machine, making it easier to maintain and scale your infrastructure.

  11. config.vm.provider "aws" do |aws, override|

    This command specifies the provider and provider-specific configuration options for an Amazon Web Services (AWS) instance. Vagrant supports many different providers, including AWS, DigitalOcean, and Microsoft Azure, each with their own set of configuration options.

  12. config.vm.define "web" do |web|

    This command defines a named configuration block for a specific virtual machine. This can be useful if you have multiple virtual machines in your Vagrantfile with different configurations.

  13. config.vm.provision "docker" do |docker|

    This command provisions the virtual machine with Docker, a popular containerization platform. Docker allows you to run multiple isolated environments on the same machine, making it easier to deploy and manage your applications.

  14. config.vm.provider "virtualbox" do |vb| vb.gui = true

    This command sets the GUI mode for the virtual machine. By default, Vagrant creates headless virtual machines, which means that there is no graphical interface. However, you can enable the GUI mode with this command if you need to interact with the machine's graphical interface.

  15. config.vm.provision "file", source: "config/nginx.conf", destination: "/etc/nginx/nginx.conf"

    This command provisions the virtual machine with a file from the host machine. The source option specifies the path to the file on the host machine, and the destination option specifies the path to where the file should be copied on the guest machine. This can be useful for copying configuration files, scripts, and other assets to the virtual machine.

  16. config.vm.box_check_update = false

    This command disables the automatic checking for updates to the base box. By default, Vagrant checks for updates to the base box every time you run vagrant up, but you can disable this behavior with this command if you prefer to manage updates manually.

  17. config.vm.network "private_network", ip: "192.168.33.10"

    This command sets up a private network interface for the virtual machine, which allows the machine to communicate with other machines on the same network. The ip option specifies the IP address to assign to the machine on the private network.

  18. config.vm.provision "puppet", manifests: ["webserver.pp", "database.pp"]

    This command provisions the virtual machine with Puppet, another popular configuration management tool. The manifests option specifies the path to one or more Puppet manifest files, which define the desired configuration for the machine.

  19. config.vm.synced_folder ".", "/vagrant"

    This command sets up a synced folder between the host machine and the guest machine, allowing files to be shared between the two. The first argument specifies the path to the folder on the host machine, and the second argument specifies the path to where the folder should be mounted on the guest machine.

  20. config.vm.hostname = "webserver"

    This command sets the hostname for the virtual machine. The hostname is the name that the machine will use to identify itself on the network.

  21. config.vm.provision "shell", path: "setup.sh"

    This command provisions the virtual machine with a shell script. The path option specifies the path to the shell script on the host machine, which will be executed on the guest machine during provisioning.

  22. config.vm.provider "virtualbox" do |vb| vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]

    This command sets a custom configuration option for the VirtualBox provider. In this example, we are enabling NAT DNS resolution, which allows the guest machine to resolve DNS names using the host machine's DNS resolver.

  23. config.vm.provision "chef", run_list: ["recipe[webserver]", "recipe[database]"]

    This command provisions the virtual machine with Chef, another popular configuration management tool. The run_list option specifies the list of Chef recipes to apply to the machine.

  24. config.vm.provision "ansible", playbook: "playbook.yml"

    This command provisions the virtual machine with Ansible, yet another popular configuration management tool. The playbook option specifies the path to the Ansible playbook to apply to the machine.

  25. config.vm.provider "virtualbox" do |vb| vb.memory = "2048"

    This command sets the amount of memory to allocate to the virtual machine. The value is specified in megabytes (MB). In this example, we are allocating 2 GB of memory to the machine.

  26. config.vm.provision "shell", inline: "echo 'Hello, World!'"

    This command provisions the virtual machine with an inline shell command. The inline option specifies the command to execute on the guest machine during provisioning.

  27. config.vm.provision "docker", images: ["nginx", "postgres"]

    This command provisions the virtual machine with Docker, a popular containerization platform. The images option specifies the list of Docker images to download and run on the machine

Scenario 1: Vagrantfile that sets up a virtual machine running Ubuntu 20.04 LTS and installs the Apache web server:

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

  # Set the box to use (Ubuntu 20.04 LTS)
  config.vm.box = "ubuntu/focal64"

  # Forward port 80 from the guest to port 8080 on the host
  config.vm.network "forwarded_port", guest: 80, host: 8080

  # Provision the machine with a shell script
  config.vm.provision "shell", inline: <<-SHELL
    # Update the package list and install Apache
    sudo apt-get update
    sudo apt-get install -y apache2

    # Configure Apache to serve a custom index.html file
    echo "<h1>Hello, Vagrant!</h1>" | sudo tee /var/www/html/index.html
  SHELL
end

This Vagrantfile uses the Ubuntu 20.04 LTS box, forwards port 80 from the guest machine to port 8080 on the host machine, and provisions the machine with a shell script that installs Apache and serves a custom index.html file. To use this Vagrantfile, you would save it to a file called "Vagrantfile" in an empty directory and run the command vagrant up to create and provision the virtual machine.

Scenario 2: Vagrantfile that sets up a virtual machine running CentOS 7 and installs Docker:

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

  # Set the box to use (CentOS 7)
  config.vm.box = "centos/7"

  # Forward port 8080 from the guest to port 8080 on the host
  config.vm.network "forwarded_port", guest: 8080, host: 8080

  # Provision the machine with a shell script
  config.vm.provision "shell", inline: <<-SHELL
    # Update the package list and install Docker
    sudo yum install -y yum-utils
    sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
    sudo yum install -y docker-ce docker-ce-cli containerd.io
    sudo systemctl start docker

    # Add the vagrant user to the docker group
    sudo usermod -aG docker vagrant
  SHELL
end

This Vagrantfile uses the CentOS 7 box, forwards port 8080 from the guest machine to port 8080 on the host machine, and provisions the machine with a shell script that installs Docker and adds the vagrant user to the docker group. To use this Vagrantfile, you would save it to a file called "Vagrantfile" in an empty directory and run the command vagrant up to create and provision the virtual machine. Once the machine is up and running, you can use Docker to build and run containers on the guest machine.

Scenario 3: Vagrantfile that sets up a virtual machine running Windows 10 and installs IIS

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

  # Set the box to use (Windows 10)
  config.vm.box = "mwrock/Windows10"

  # Forward port 80 from the guest to port 8080 on the host
  config.vm.network "forwarded_port", guest: 80, host: 8080

  # Provision the machine with a PowerShell script
  config.vm.provision "shell", inline: <<-SHELL
    # Install IIS and enable remote management
    Install-WindowsFeature Web-Server
    Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WebManagement\Server" -Name EnableRemoteManagement -Value 1
    Set-NetFirewallRule -Name "Web Management Service (HTTP-In)" -RemoteAddress Any

    # Configure IIS to serve a custom index.html file
    New-Item -Path "C:\inetpub\wwwroot" -Type Directory -Force
    echo "<h1>Hello, Vagrant!</h1>" | Out-File "C:\inetpub\wwwroot\index.html"
  SHELL

  # Set the WinRM username and password
  config.winrm.username = "vagrant"
  config.winrm.password = "vagrant"
end

This Vagrantfile uses the "mwrock/Windows10" box, forwards port 80 from the guest machine to port 8080 on the host machine, and provisions the machine with a PowerShell script that installs IIS, enables remote management, and serves a custom index.html file. To use this Vagrantfile, you would save it to a file called "Vagrantfile" in an empty directory and run the command vagrant up to create and provision the virtual machine. Once the machine is up and running, you can access the IIS server by navigating to http://localhost:8080 in a web browser on the host machine. Note that this Vagrantfile also sets the WinRM username and password to "vagrant" for remote access to the Windows machine.

Scenario 4: Vagrantfile that sets up a virtual machine running Ubuntu 20.04 LTS with multiple provisions including Apache, PHP, MySQL, and Git

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

  # Set the box to use (Ubuntu 20.04 LTS)
  config.vm.box = "ubuntu/focal64"

  # Forward port 80 from the guest to port 8080 on the host
  config.vm.network "forwarded_port", guest: 80, host: 8080

  # Provision the machine with a shell script to install Apache and PHP
  config.vm.provision "shell", inline: <<-SHELL
    # Update the package list and install Apache and PHP
    sudo apt-get update
    sudo apt-get install -y apache2 php libapache2-mod-php
  SHELL

  # Provision the machine with a shell script to install MySQL
  config.vm.provision "shell", inline: <<-SHELL
    # Install MySQL and configure the root password
    sudo apt-get install -y mysql-server
    sudo mysql -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; FLUSH PRIVILEGES;"
  SHELL

  # Provision the machine with a shell script to install Git and clone a repository
  config.vm.provision "shell", inline: <<-SHELL
    # Install Git and clone a repository
    sudo apt-get install -y git
    git clone https://github.com/example/my-app.git /var/www/html/my-app
  SHELL

  # Provision the machine with a shell script to install Composer
  config.vm.provision "shell", inline: <<-SHELL
    # Install Composer
    sudo apt-get install -y composer
  SHELL

  # Provision the machine with a shell script to install the necessary dependencies for the app
  config.vm.provision "shell", inline: <<-SHELL
    # Install the necessary dependencies for the app
    cd /var/www/html/my-app
    composer install
  SHELL
end

This Vagrantfile uses the Ubuntu 20.04 LTS box, forwards port 80 from the guest machine to port 8080 on the host machine, and provisions the machine with several shell scripts to install and configure Apache, PHP, MySQL, Git, and Composer, and to clone a repository and install its dependencies. To use this Vagrantfile, you would save it to a file called "Vagrantfile" in an empty directory and run the command vagrant up to create and provision the virtual machine. Once the machine is up and running, you can access the app by navigating to http://localhost:8080/my-app in a web browser on the host machine. Note that this Vagrantfile uses a default password of "password" for the MySQL root user, which should be changed in a production environment.

Did you find this article valuable?

Support Prahlad Inala by becoming a sponsor. Any amount is appreciated!

See recent sponsors |ย Learn more about Hashnode Sponsors
ย 
Share this