markdown [Vagrant] Fedora #linux上的Vagrant和Virtualbox安装

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown [Vagrant] Fedora #linux上的Vagrant和Virtualbox安装相关的知识,希望对你有一定的参考价值。

# Vagrant and Virtualbox Installation on Fedora
This article explains how to install Vagrant and Virtualbox on Fedora 23/24 so you can build your development environments.
Vagrant and Virtualbox provide an easy way to create, configure and distribute development environments.

This play is also working on the brand new Fedora 26 with just a glitch about few missing headers files, see my note at the end.

VirtualBox Installation
Add VirtualBox repository and update your system:

```
$ sudo su -
# cd /etc/yum.repos.d/
# wget http://download.virtualbox.org/virtualbox/rpm/fedora/virtualbox.repo
# dnf update
```
Ensure that you are running latest installed kernel version, you can check it by comparing the output of following commands, version numbers should match:

```
# rpm -qa kernel |sort -V |tail -n 1
# uname -r
```
If you got a kernel update then reboot your system.

Install VirtualBox dependencies:

```
# dnf install binutils gcc make patch libgomp glibc-headers \
  glibc-devel kernel-headers kernel-devel dkms
```
`# dnf install VirtualBox`
Last command will build needed kernel modules, in case you need in the future to rebuild them, you can use the following command:
```# /usr/lib/virtualbox/vboxdrv.sh setup
```
In order to use VirtualBox, a user must be member of vboxusers group which was created automatically during Virtualbox installation. Add your username to vboxusers group

`# usermod -a -G vboxusers username`

## Vagrant Installation
Run the following commands to install Vagrant:

`$ sudo dnf install vagrant` 

Note that Fedora use libvirt as default provider, so to use Virtualbox instead you need to set an environment variable for it. Run the following commands:
```
$ echo "export VAGRANT_DEFAULT_PROVIDER=virtualbox" >> ~/.bashrc
If you prefer to use Vagrant with KVM, make sure to install libvirt packages for it.
```
`$ sudo dnf install -y vagrant vagrant-libvirt libvirt-devel`
Finally, install some useful vagrant plugins, but before we need to install .

```
$ vagrant plugin install vagrant-cachier
$ vagrant plugin install vagrant-hostmanager
```

While installing vagrant-cachier on a brand new Fedora 24 I had some errors about missing headers, to fix it you need to install the following packages:

`$ sudo dnf install ruby-devel redhat-rpm-config zlib-devel`
You can find more info about Gems installation in the Fedora Developer site.

Launch a Vagrant box
Now you can launch a vagrant box, for example try the official CentOS 7.

```
$ vagrant init centos/7
$ vagrant up --provider virtualbox
```
if you use libvirt provider:

`$ vagrant up --provider libvirt`


## What to do after a kernel update 

## launch the following command
> /usr/lib/virtualbox/vboxdrv.sh setup

## Add a second user
```
Vagrant.configure("2") do |config|
  if VAGRANT_COMMAND == "ssh"
      config.ssh.username = 'other_username'
  end
```

以上是关于markdown [Vagrant] Fedora #linux上的Vagrant和Virtualbox安装的主要内容,如果未能解决你的问题,请参考以下文章

markdown vagrant仮想マシン操作

markdown Magento - Vagrant - Vhost

markdown Magento - Vagrant - Vhost

markdown 使用PHPStorm,Vagrant配置Xdebug

markdown Magento 2 Vagrant设置

markdown 使用Vagrant限制VirtualBox资源