{"id":52273,"date":"2024-10-09T01:15:16","date_gmt":"2024-10-08T17:15:16","guid":{"rendered":"https:\/\/server.hk\/cnblog\/52273\/"},"modified":"2024-11-14T10:39:38","modified_gmt":"2024-11-14T02:39:38","slug":"ubuntu-%e4%b8%8b%e5%ae%89%e8%a3%9d%e9%83%a8%e7%bd%b2-vagrant-%e5%92%8c-virtualbox-%e8%a9%b3%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/52273\/","title":{"rendered":"Ubuntu \u4e0b\u5b89\u88dd\u90e8\u7f72 Vagrant \u548c VirtualBox \u8a73\u89e3"},"content":{"rendered":"<h1 id=\"ubuntu-%e4%b8%8b%e5%ae%89%e8%a3%9d%e9%83%a8%e7%bd%b2-vagrant-%e5%92%8c-virtualbox-%e8%a9%b3%e8%a7%a3-TSpbdbQhPw\">Ubuntu \u4e0b\u5b89\u88dd\u90e8\u7f72 Vagrant \u548c VirtualBox \u8a73\u89e3<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u958b\u767c\u74b0\u5883\u4e2d\uff0c\u865b\u64ec\u5316\u6280\u8853\u5df2\u6210\u70ba\u4e00\u500b\u4e0d\u53ef\u6216\u7f3a\u7684\u5de5\u5177\u3002Vagrant \u548c VirtualBox \u662f\u5169\u500b\u5ee3\u6cdb\u4f7f\u7528\u7684\u865b\u64ec\u5316\u5de5\u5177\uff0c\u80fd\u5920\u5e6b\u52a9\u958b\u767c\u8005\u5feb\u901f\u642d\u5efa\u548c\u7ba1\u7406\u865b\u64ec\u74b0\u5883\u3002\u672c\u6587\u5c07\u8a73\u7d30\u4ecb\u7d39\u5982\u4f55\u5728 Ubuntu \u7cfb\u7d71\u4e0a\u5b89\u88dd\u548c\u90e8\u7f72 Vagrant \u548c VirtualBox\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%af-vagrant-%e5%92%8c-virtualbox%ef%bc%9f-TSpbdbQhPw\">\u4ec0\u9ebc\u662f Vagrant \u548c VirtualBox\uff1f<\/h2>\n<p>Vagrant \u662f\u4e00\u500b\u958b\u6e90\u5de5\u5177\uff0c\u65e8\u5728\u7c21\u5316\u865b\u64ec\u74b0\u5883\u7684\u7ba1\u7406\u3002\u5b83\u63d0\u4f9b\u4e86\u4e00\u500b\u547d\u4ee4\u884c\u754c\u9762\uff0c\u8b93\u958b\u767c\u8005\u80fd\u5920\u8f15\u9b06\u5730\u5275\u5efa\u3001\u914d\u7f6e\u548c\u7ba1\u7406\u865b\u64ec\u6a5f\u3002VirtualBox \u5247\u662f\u4e00\u500b\u7531 Oracle \u958b\u767c\u7684\u865b\u64ec\u5316\u8edf\u4ef6\uff0c\u652f\u6301\u591a\u7a2e\u64cd\u4f5c\u7cfb\u7d71\u7684\u865b\u64ec\u5316\u3002\u9019\u5169\u8005\u7d50\u5408\u4f7f\u7528\uff0c\u53ef\u4ee5\u5927\u5927\u63d0\u9ad8\u958b\u767c\u6548\u7387\u3002<\/p>\n<h2 id=\"%e5%ae%89%e8%a3%9d-virtualbox-TSpbdbQhPw\">\u5b89\u88dd VirtualBox<\/h2>\n<p>\u5728 Ubuntu \u4e0a\u5b89\u88dd VirtualBox \u7684\u6b65\u9a5f\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li>\u9996\u5148\uff0c\u66f4\u65b0\u7cfb\u7d71\u7684\u5305\u7ba1\u7406\u5668\uff1a<\/li>\n<pre><code>sudo apt update<\/code><\/pre>\n<li>\u63a5\u8457\uff0c\u5b89\u88dd VirtualBox \u7684\u5fc5\u8981\u4f9d\u8cf4\uff1a<\/li>\n<pre><code>sudo apt install -y software-properties-common<\/code><\/pre>\n<li>\u7136\u5f8c\uff0c\u6dfb\u52a0 Oracle \u7684 VirtualBox \u5b58\u5132\u5eab\uff1a<\/li>\n<pre><code>sudo add-apt-repository \"deb http:\/\/download.virtualbox.org\/virtualbox\/debian $(lsb_release -cs) contrib\"<\/code><\/pre>\n<li>\u63a5\u4e0b\u4f86\uff0c\u6dfb\u52a0 Oracle \u7684\u516c\u9470\uff1a<\/li>\n<pre><code>wget -q https:\/\/www.virtualbox.org\/download\/oracle_vbox_2016.asc -O- | sudo apt-key add -<\/code><\/pre>\n<li>\u66f4\u65b0\u5305\u7ba1\u7406\u5668\u4e26\u5b89\u88dd VirtualBox\uff1a<\/li>\n<pre><code>sudo apt update<\/code><\/pre>\n<pre><code>sudo apt install -y virtualbox-6.1<\/code><\/pre>\n<\/ol>\n<h2 id=\"%e5%ae%89%e8%a3%9d-vagrant-TSpbdbQhPw\">\u5b89\u88dd Vagrant<\/h2>\n<p>\u5b89\u88dd Vagrant \u7684\u6b65\u9a5f\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li>\u9996\u5148\uff0c\u4e0b\u8f09 Vagrant \u7684\u6700\u65b0\u7248\u672c\uff1a<\/li>\n<pre><code>wget https:\/\/releases.hashicorp.com\/vagrant\/2.2.19\/vagrant_2.2.19_x86_64.deb<\/code><\/pre>\n<li>\u7136\u5f8c\uff0c\u4f7f\u7528 dpkg \u5b89\u88dd Vagrant\uff1a<\/li>\n<pre><code>sudo dpkg -i vagrant_2.2.19_x86_64.deb<\/code><\/pre>\n<li>\u5982\u679c\u51fa\u73fe\u4f9d\u8cf4\u554f\u984c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4fee\u5fa9\uff1a<\/li>\n<pre><code>sudo apt --fix-broken install<\/code><\/pre>\n<\/ol>\n<h2 id=\"%e9%85%8d%e7%bd%ae-vagrant-%e5%92%8c-virtualbox-TSpbdbQhPw\">\u914d\u7f6e Vagrant \u548c VirtualBox<\/h2>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u53ef\u4ee5\u4f7f\u7528 Vagrant \u5275\u5efa\u4e00\u500b\u65b0\u7684\u865b\u64ec\u74b0\u5883\u3002\u4ee5\u4e0b\u662f\u5275\u5efa\u548c\u555f\u52d5\u865b\u64ec\u6a5f\u7684\u57fa\u672c\u6b65\u9a5f\uff1a<\/p>\n<ol>\n<li>\u5275\u5efa\u4e00\u500b\u65b0\u7684\u76ee\u9304\u4e26\u9032\u5165\u8a72\u76ee\u9304\uff1a<\/li>\n<pre><code>mkdir my_vagrant_project &amp;&amp; cd my_vagrant_project<\/code><\/pre>\n<li>\u521d\u59cb\u5316 Vagrant \u74b0\u5883\uff1a<\/li>\n<pre><code>vagrant init ubuntu\/bionic64<\/code><\/pre>\n<li>\u555f\u52d5\u865b\u64ec\u6a5f\uff1a<\/li>\n<pre><code>vagrant up<\/code><\/pre>\n<li>\u9032\u5165\u865b\u64ec\u6a5f\uff1a<\/li>\n<pre><code>vagrant ssh<\/code><\/pre>\n<\/ol>\n<h2 id=\"%e5%b8%b8%e8%a6%8b%e5%95%8f%e9%a1%8c-TSpbdbQhPw\">\u5e38\u898b\u554f\u984c<\/h2>\n<h3 id=\"%e5%a6%82%e4%bd%95%e5%81%9c%e6%ad%a2%e5%92%8c%e5%88%aa%e9%99%a4%e8%99%9b%e6%93%ac%e6%a9%9f%ef%bc%9f-TSpbdbQhPw\">\u5982\u4f55\u505c\u6b62\u548c\u522a\u9664\u865b\u64ec\u6a5f\uff1f<\/h3>\n<p>\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u505c\u6b62\u548c\u522a\u9664\u865b\u64ec\u6a5f\uff1a<\/p>\n<pre><code>vagrant halt<\/code><\/pre>\n<pre><code>vagrant destroy<\/code><\/pre>\n<h3 id=\"%e5%a6%82%e4%bd%95%e6%9b%b4%e6%96%b0-vagrant-%e5%92%8c-virtualbox%ef%bc%9f-TSpbdbQhPw\">\u5982\u4f55\u66f4\u65b0 Vagrant \u548c VirtualBox\uff1f<\/h3>\n<p>\u53ef\u4ee5\u901a\u904e\u91cd\u65b0\u4e0b\u8f09\u6700\u65b0\u7248\u672c\u4e26\u91cd\u8907\u5b89\u88dd\u6b65\u9a5f\u4f86\u66f4\u65b0 Vagrant \u548c VirtualBox\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-TSpbdbQhPw\">\u7e3d\u7d50<\/h2>\n<p>\u5728 Ubuntu \u4e0a\u5b89\u88dd\u548c\u90e8\u7f72 Vagrant \u548c VirtualBox \u662f\u4e00\u500b\u76f8\u5c0d\u7c21\u55ae\u7684\u904e\u7a0b\uff0c\u80fd\u5920\u70ba\u958b\u767c\u8005\u63d0\u4f9b\u9748\u6d3b\u7684\u865b\u64ec\u74b0\u5883\u3002\u9019\u4e9b\u5de5\u5177\u4e0d\u50c5\u80fd\u63d0\u9ad8\u958b\u767c\u6548\u7387\uff0c\u9084\u80fd\u5e6b\u52a9\u5718\u968a\u4fdd\u6301\u4e00\u81f4\u7684\u958b\u767c\u74b0\u5883\u3002\u5982\u679c\u60a8\u9700\u8981\u66f4\u9ad8\u6548\u7684\u865b\u64ec\u5316\u89e3\u6c7a\u65b9\u6848\uff0c\u8003\u616e\u4f7f\u7528 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u670d\u52d9\uff0c\u9019\u5c07\u70ba\u60a8\u7684\u958b\u767c\u5de5\u4f5c\u63d0\u4f9b\u66f4\u5f37\u5927\u7684\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8a73\u7d30\u6307\u5357\uff0c\u6559\u4f60\u5982\u4f55\u5728 Ubuntu \u4e0a\u5b89\u88dd\u548c\u90e8\u7f72 Vagrant \u53ca VirtualBox\uff0c\u8f15\u9b06\u7ba1\u7406\u865b\u64ec\u74b0\u5883\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4924],"tags":[],"class_list":["post-52273","post","type-post","status-publish","format-standard","hentry","category-setup-tutorials"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/52273","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=52273"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/52273\/revisions"}],"predecessor-version":[{"id":52274,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/52273\/revisions\/52274"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=52273"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=52273"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=52273"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}