安装vagrant时缺少centos 7的yum软件包

安装vagrant时缺少centos 7的yum软件包,centos,vagrant,virtualbox,centos7,Centos,Vagrant,Virtualbox,Centos7,我刚刚安装了centos 7,然后我尝试安装vagrant。安装virtualbox后,当我运行vagrant时,我得到: VirtualBox is complaining that the kernel module is not loaded. Please run `VBoxManage --version` or open the VirtualBox GUI to see the error message which should contain instructions on h

我刚刚安装了centos 7,然后我尝试安装vagrant。安装virtualbox后,当我运行vagrant时,我得到:

VirtualBox is complaining that the kernel module is not loaded. Please
run `VBoxManage --version` or open the VirtualBox GUI to see the error
message which should contain instructions on how to fix this error.
我运行“VBoxManage--version”时出现错误

The vboxdrv kernel module is not loaded. Please recompile the kernel module and install it by sudo /etc/init.d/vboxdrv setup
我运行sudo/etc/init.d/vboxdrv安装程序

Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> 
错误:无法找到当前Linux内核的源代码。指定KERN_DIR=
缺少哪些软件包?

您必须通过以下方式安装“gcc”和“kernel-devel”:

然后运行以重新编译虚拟盒:

sudo /etc/init.d/vboxdrv setup
您现在可以运行:

vagrant up

步骤2对我不起作用:

sudo: /etc/init.d/vboxdrv: command not found
在另一个线程上找到此线程,该线程工作正常:

sudo /usr/lib/virtualbox/vboxdrv.sh setup
希望能有所帮助;)

sudo /usr/lib/virtualbox/vboxdrv.sh setup