Arch Linux BasedManjaro

How To Install Vagrant on Manjaro

Install Vagrant on Manjaro

In this tutorial, we will show you how to install Vagrant on Manjaro. In the world of software development, having a reliable and efficient development environment is crucial. Vagrant, a powerful tool for building and managing virtual machine environments, has become increasingly popular among developers due to its ability to streamline the development process and ensure consistency across different systems.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the Vagrant on a Manjaro Linux.

Prerequisites

  • A server or desktop running one of the following operating systems: Manjaro, and other Arch-based distributions.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A stable internet connection is crucial for downloading and installing packages. Verify your connection before proceeding.
  • Access to a Manjaro Linux system with a non-root sudo user or root user.

Install Vagrant on Manjaro

Step 1. To begin, open a terminal and update Manjaro’s package database to ensure that you have access to the latest software versions. Run the following command:

sudo pacman -Syu

This command will synchronize the package database and upgrade any outdated packages to their latest versions.

Step 2. Installing Virtualization Software.

Vagrant relies on virtualization software to manage virtual environments. The two most common options are VirtualBox and KVM/QEMU. For this guide, we‘ll focus on installing VirtualBox. Run the following command to install VirtualBox:

sudo pacman -S virtualbox

Manjaro’s package manager, pacman, will handle the installation process, downloading and installing all necessary dependencies.

Step 3. Installing Vagrant on Manjaro.

With the dependencies in place, we can now proceed to install Vagrant itself. Manjaro’s package repositories include the latest version of Vagrant, making the installation process straightforward.

To install Vagrant, run the following command:

sudo pacman -S vagrant

Pacman will download and install the latest version of Vagrant, along with any additional dependencies required.

Once the installation is complete, it’s crucial to verify that Vagrant has been installed correctly and that you have the latest version. Run the following command to check Vagrant’s version:

vagrant --version

The output should display the installed version of Vagrant, confirming a successful installation.

Step 4. Configuring Vagrant.

  • Initializing a New Vagrant Project

To create a new Vagrant project, navigate to the desired directory in your terminal and run the following command:

vagrant init almalinux/9

This command initializes a new Vagrant project and generates a Vagrantfile based on the specified box (in this case, AlmaLinux 9). You can replace “almalinux/9” with any other box that suits your requirements.

  • Customizing the Vagrantfile

Open the generated Vagrantfile in your preferred text editor to customize the virtual machine’s settings. Some common modifications include:

  1. Adjusting the amount of memory and CPU cores allocated to the virtual machine.
  2. Configuring network settings, such as forwarding ports or setting up private networks.
  3. Specifying shared folders between the host and the virtual machine.
  4. Adding provisioning scripts to automate the setup of the virtual environment.

Here’s an example of a customized Vagrantfile:

Vagrant.configure("2") do |config|
  config.vm.box = "almalinux/9"
  config.vm.provider "virtualbox" do |vb|
    vb.memory = "2048"
    vb.cpus = "2"
  end
  config.vm.network "forwarded_port", guest: 80, host: 8080
  config.vm.synced_folder ".", "/vagrant", type: "nfs"
  config.vm.provision "shell", inline: <<-SHELL
    sudo dnf install -y httpd
    sudo systemctl start httpd
    sudo systemctl enable httpd
  SHELL
end

This Vagrantfile sets the memory to 2GB, allocates 2 CPU cores, forwards port 80 from the guest to port 8080 on the host, sets up an NFS shared folder, and provisions the virtual machine with an Apache web server.

Step 5. Managing Virtual Environments with Vagrant.

Vagrant provides a set of commands to manage the lifecycle of virtual environments, making it easy to create, start, stop, and destroy virtual machines.

To start the virtual machine defined in your Vagrantfile, run the following command:

vagrant up

Once the virtual machine is up and running, you can SSH into it using the following command:

vagrant ssh

To gracefully shut down the virtual machine, use the following command:

vagrant halt

If you want to completely remove the virtual machine and free up disk space, run:

vagrant destroy

Be cautious when using vagrant destroy, as it permanently deletes the virtual machine and any data stored within it.

Congratulations! You have successfully installed Vagrant. Thanks for using this tutorial to install the latest version of the Vagrant on the Manjaro system. For additional help or useful information, we recommend you check the official Vagrant website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button