{"id":600,"date":"2018-10-28T18:04:14","date_gmt":"2018-10-28T10:04:14","guid":{"rendered":"http:\/\/hahacool.com\/?p=600"},"modified":"2019-04-07T23:30:22","modified_gmt":"2019-04-07T15:30:22","slug":"windows%e4%b8%8b%e9%85%8d%e7%bd%aelaravel%e7%94%a8%e7%9a%84%e5%bc%80%e5%8f%91%e7%8e%af%e5%a2%83%ef%bc%9ahomestead","status":"publish","type":"post","link":"https:\/\/hahacool.com\/?p=600","title":{"rendered":"windows\u4e0b\u914d\u7f6eLaravel\u7528\u7684\u5f00\u53d1\u73af\u5883\uff1aHomestead"},"content":{"rendered":"<ol>\n<li style=\"list-style-type: none;\">\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\n<li>\u5b89\u88c5virtualbox<\/li>\n<li>\u5b89\u88c5vagrant<br \/>\nVagrant \u662f\u7528\u6765\u7ba1\u7406\u865a\u62df\u673a\u7684\u5de5\u5177\uff0c\u652f\u6301\u5f53\u524d\u4e3b\u6d41\u7684\u865a\u62df\u673a\u7cfb\u7edf\u5982 VirtualBox\u3001VMware\u3001AWS \u7b49\u3002Vagrant \u7684\u4e3b\u8981\u4f5c\u7528\u662f\u63d0\u4f9b\u4e00\u4e2a\u53ef\u914d\u7f6e\u3001\u53ef\u79fb\u690d\u548c\u590d\u7528\u7684\u8f6f\u4ef6\u73af\u5883\u3002Vagrant \u8ba9\u4f60\u901a\u8fc7\u7f16\u5199\u4e00\u4e2a Vagrantfile \u6587\u4ef6\u6765\u63a7\u5236\u865a\u62df\u673a\u7684\u542f\u52a8\u3001\u865a\u62df\u673a\u7f51\u7edc\u73af\u5883\u7684\u914d\u7f6e\u3001\u865a\u62df\u673a\u4e0e\u4e3b\u673a\u95f4\u7684\u6587\u4ef6\u5171\u4eab\uff0c\u4ee5\u53ca\u542f\u52a8\u540e\u81ea\u52a8\u6267\u884c\u4e00\u4e9b\u914d\u7f6e\u811a\u672c\uff0c\u5982\u81ea\u52a8\u6267\u884c\u4e00\u4e2a Shell Script \u6765\u5b89\u88c5\u4e00\u4e9b\u5fc5\u5907\u7684\u5f00\u53d1\u5de5\u5177\uff0c\u5982\u5b89\u88c5\u914d\u7f6eMySQL\u3001PHP\uff0c\u751a\u81f3\u662f\u81ea\u52a8\u914d\u7f6e Nginx \u7ad9\u70b9\u3002\u8fd9\u610f\u5473\u7740\uff0c\u5728\u4e00\u4e2a\u591a\u4eba\u5f00\u53d1\u7684\u9879\u76ee\u4e2d\uff0c\u4f60\u53ea\u9700\u8981\u540c\u6b65 Vagrantfile \u6587\u4ef6\uff0c\u5c31\u53ef\u4ee5\u4fdd\u8bc1\u53c2\u4e0e\u9879\u76ee\u7684\u6bcf\u4e2a\u4eba\u5404\u81ea\u7684\u673a\u5668\u4e0a\u62e5\u6709\u4e00\u81f4\u7684\u5f00\u53d1\u73af\u5883\u3002<\/li>\n<li>\u5b89\u88c5 Homestead Vagrant \u76d2\u5b50<br \/>\n\u5728CMD\u6216\u8005GIT BASH\u91cc\u9762\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a&nbsp;<\/p>\n<pre><code>vagrant box add laravel\/homestead<\/code><\/pre>\n<p>\u4f1a\u5f00\u59cb\u4e0b\u8f7d\uff0c\u8d3c\u6162\uff0c\u56e0\u6b64\u622a\u53d6\u91cc\u9762\u7684\u4e00\u4e2a\u5730\u5740\uff0c\u6bd4\u5982\u6211\u5f53\u65f6\u7684https:\/\/vagrantcloud.com\/laravel\/boxes\/homestead\/versions\/6.3.0\/providers\/virtualbox.box\uff0c\u628a\u8fd9\u4e2a\u5730\u5740\u5012\u5165\u8fc5\u96f7\uff0c\u5f88\u5feb\u5c31\u597d\u4e86\u3002\u4f8b\u5982\u662f\u5b58\u5728D\u76d8\u7684\u3002\u4e0b\u9762\u5c31\u662f\u628a\u8fd9\u4e2a\u4e0b\u8f7d\u4e0b\u6765\u7684virtualbox.box\u5012\u5165\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4<\/p>\n<pre><code>vagrant box add laravel\/homestead d:\\virtualbox.box<\/code><\/pre>\n<p>\u4f46\u662f\u8fd9\u79cd\u672c\u5730\u7684box\u88c5\u8f7d\u8fdb\u53bb\u540e\u7684\u8bdd\uff0c\u4ee5\u540evagrant up\u7684\u65f6\u5019\u8fd8\u662f\u4f1a\u78b0\u5230\u8bf4\u627e\u4e0d\u5230box\u7684\u95ee\u9898\uff0c\u539f\u56e0\u5c31\u662f\u7248\u672c\u95ee\u9898\uff0c\u5177\u4f53\u89e3\u6790\u89c1\u8fd9\u91cc\uff1a<a href=\"https:\/\/stackoverflow.com\/questions\/34946837\/box-laravel-homestead-could-not-be-found\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/stackoverflow.com\/questions\/34946837\/box-laravel-homestead-could-not-be-found<\/a>\u3002\u8bf4\u7684\u6781\u5176\u660e\u6670\uff0c\u56e0\u6b64\uff0c\u4e0b\u8f7d\u4e0b\u6765\u7684box\u8981\u88c5\u8fdb\u53bb\u7528\u4e0b\u9762\u7684\u53e6\u4e00\u79cd\u529e\u6cd5\uff1a<\/p>\n<p>\u53e6\u4e00\u79cd\u529e\u6cd5\uff0c\u5728virtualbox.box\u7684\u540c\u4e00\u4e2a\u6587\u4ef6\u5939\u4e0b\u65b0\u5efa\u4e00\u4e2ametadata.json\uff0c\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9<\/p>\n<pre><code>{\n    \"name\": \"laravel\/homestead\",\n    \"versions\": [{\n        \"version\": \"6.3.0\",\n        \"providers\": [{\n            \"name\": \"virtualbox\",\n            \"url\": \"file:\/\/\/d:virtualbox.box\"\n        }]\n    }]\n}\n<\/code><\/pre>\n<p>\u4e0a\u9762\u7684version\u67e5\u770b\u4e0b\u8f7d\u94fe\u63a5\u91cc\u9762\u7684version\uff0c\u636e\u6b64\u4fee\u6539\u3002 \u7136\u540e\u8f93\u5165\u547d\u4ee4<\/p>\n<pre><code>vagrant box add d:\\metadata.json<\/code><\/pre>\n<p>\u8fd9\u6837\u5c31OK\u4e86\u3002<br \/>\n\u5728mac\u91cc\u9762\u7684\u8bdd\uff0cfile:\/\/\/d:virtualbox.box\u6539\u4e3a.\/virtualbox.box\u5c31\u884c\u3002\u8fd9\u91cc\u5047\u8bbevirtualbox.box\u548cmetadata.json\u4e00\u8d77\u653e\u5728homestead\u6587\u4ef6\u5939\u4e0b\u7684\uff0c\u56e0\u4e3avagrant\u5c31\u662f\u8981\u5728\u8fd9\u91cc\u8fd0\u884c\u7684\u561b\u3002\u7136\u540e\u4e00\u6837\u8f93\u5165\u547d\u4ee4<\/p>\n<pre><code>vagrant box add metadata.json<\/code><\/pre>\n<p>\u5c31\u884c\u4e86\u3002<\/p>\n<p>\u597d\u4e86\u4ee5\u540e\uff0c\u8f93\u5165\u547d\u4ee4<\/p>\n<pre><code>vagrant box list<\/code><\/pre>\n<p>\u67e5\u770b\u5217\u8868\u5224\u65ad\u6709\u6ca1\u6709\u6dfb\u52a0\u6210\u529f\u3002\u5982\u679c\u7b2c\u4e00\u6b21\u4e0d\u662f\u7528metadata.json\u5b89\u88c5\u7684\u90a3\u4e2aversion=0\u7684\u4e5f\u5728\u91cc\u9762\uff0c\u90a3\u4e48\u6700\u597d\u5220\u9664\u4e00\u4e0b\uff0c\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n<pre><code>vagrant box remove laravel\/homestead --box-version 0\n\n<\/code><\/pre>\n<p>\u5982\u679c\u4ee5\u524d\u6709\u5b89\u88c5\u8fc7homestead\u7248\u672c\u73b0\u5728\u91cd\u65b0\u5b89\u88c5\u7684\u8bdd\uff0c\u5728\u5217\u8868\u91cc\u6309\u4ee5\u4e0a\u65b9\u6cd5\u5220\u9664\u4ee5\u540e\uff0c\u8bb0\u5f97\u53bbVirtualBox VMs\u8fd9\u4e2a\u6587\u4ef6\u5939\u4e0b\u628a\u539f\u6765\u7684homestead-7\u8fd9\u4e2a\u6587\u4ef6\u5939\u5220\u9664\u6389\uff0c\u56e0\u4e3a\u6bcf\u6b21\u7684\u865a\u62df\u7cfb\u7edf\u90fd\u662f\u91cd\u547d\u540d\u53eb\u8fd9\u4e2a<\/li>\n<li>\u5b89\u88c5 Homestead<br \/>\n\u5728git bash\u4e0b\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4&nbsp;<\/p>\n<pre><code>cd ~\ngit clone https:\/\/github.com\/laravel\/homestead.git\n<\/code><\/pre>\n<p>\u5728window\u73af\u5883\u4e0b\u7684\u8bdd\uff0c\u5c31\u5728\u7528\u6237\u6839\u76ee\u5f55C:\\Users\\Administrator\u4e0b\u8fd0\u884c\u8fd9\u4e2a\u547d\u4ee4\u5c31\u884c.<\/p>\n<p>\u597d\u4e86\u4ee5\u540e\u518d\u8f93\u5165<\/p>\n<pre><code>cd ~\/Homestead\ngit checkout\nbash init.sh\n<\/code><\/pre>\n<p>(\u4ee5\u4e0a\u5982\u679c\u5728CMD\u4e2d\uff0c\u6700\u540e\u4e00\u884c\u4e2d\u7684bash\u8c8c\u4f3c\u4e0d\u7528\u6253\uff0c\u76f4\u63a5\u8f93\u5165init.sh\u5c31\u884c\u3002\u5e76\u4e14\uff0c\u7b2c\u4e00\u4e2a\u7684cd ~\u8fd9\u662f\u7528\u5728mac\u91cc\u9762\u7684\uff0c\u4e00\u822c\u7684windows\u5c31\u6539\u4e3a\u7528\u6237\u76ee\u5f55\uff0c\u6bd4\u5982C:\\Users\\Administrator\\\u3002\u5728mac\u4e2d\u7684Homestead.yaml\u53ef\u4ee5\u4e0d\u7528\u6539\u3002<\/p>\n<p>\u5728windows\u4e2d\u7684Homestead.yaml\u6211\u6539\u4e86\u4e0b\u624d\u80fd\u7528\u3002\u5982\u4e0b\uff1a<\/p>\n<pre><code>\nauthorize: C:\\Users\\Administrator\\.ssh\\id_rsa.pub\n\nkeys:\n    - C:\\Users\\Administrator\\.ssh\\id_rsa\n\n    # \u4e0a\u9762\u90fd\u662fgit\u914d\u7f6e\u6587\u4ef6\u7684\u4f4d\u7f6e\n\nfolders:\n    - map: C:\\Users\\Administrator\\code\n    # \u672c\u5730\u7684\u6e90\u4ee3\u7801\u4f4d\u7f6e\n      to: \/home\/vagrant\/code\n      # \u6620\u5c04\u5230\u865a\u62df\u673a\u4e0a\u7684\u6e90\u4ee3\u7801\u4f4d\u7f6e\n\nsites:\n    - map: homestead.test\n    # \u8bbf\u95ee\u7684\u57df\u540d\u540d\u5b57\n      to: \/home\/vagrant\/code\/lmh\/public\/\n      # \u5728\u865a\u62df\u673a\u4e0a\u7684\u7f51\u7ad9\u6839\u76ee\u5f55\n<\/code><\/pre>\n<p>Homestead.yaml \u6587\u4ef6\u4e2d\u7684 folders \u5c5e\u6027\u5217\u51fa\u4e86\u6240\u6709\u4e3b\u673a\u548c Homestead \u865a\u62df\u673a\u5171\u4eab\u7684\u6587\u4ef6\u5939\u3002<\/p>\n<pre><code>sites:\n    - map: homestead.test\n     \/\/\u8fd9\u91cc\u5199\u51fa\u8bd5\u9a8c\u7528\u7684\u57df\u540d\n      to: \/home\/vagrant\/code\/public<\/code><\/pre>\n<p>\u4e0d\u8981\u5fd8\u8bb0\u628a Nginx \u7ad9\u70b9\u914d\u7f6e\u4e2d\u7684\u57df\u540d\u6dfb\u52a0\u5230\u672c\u5730\u673a\u5668\u4e0a\u7684 hosts \u6587\u4ef6\u4e2d\uff0c\u8be5\u6587\u4ef6\u4f1a\u5c06\u5bf9\u672c\u5730\u57df\u540d\u7684\u8bf7\u6c42\u91cd\u5b9a\u5411\u5230 Homestead \u865a\u62df\u673a\uff0c\u5728 Mac \u6216 Linux\u4e0a\uff0c\u8be5\u6587\u4ef6\u4f4d\u4e8e \/etc\/hosts\uff0c\u5728 Windows \u4e0a\uff0c\u4f4d\u4e8e C:\\Windows\\System32\\drivers\\etc\\hosts\uff0c\u6dfb\u52a0\u65b9\u5f0f\u5982\u4e0b\uff1a\u589e\u52a0\u4e00\u884c<\/p>\n<pre><code>192.168.10.10 homestead.test<\/code><\/pre>\n<p>\u8fd9\u91cc\u7684IP\u8981\u548cHomestead.yaml \u6587\u4ef6\u4e2d\u7684\u4e00\u6837<\/li>\n<li>\u8fd0\u884c Vagrant<br \/>\n\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4&nbsp;<\/p>\n<pre><code>cd ~\/Homestead &amp;&amp; vagrant up<\/code><\/pre>\n<p>\u5982\u679c\u6709\u95ee\u9898\uff0c\u8bf4\u4ec0\u4e48\u627e\u4e0d\u5230base\u7684\uff0c\u90a3\u4e48\u6253\u5f00~\u76ee\u5f55\u4e0b\u7684Vagrantfile\uff0c config.vm.box = &#8220;base&#8221;\u91cc\u9762\u7684base\u6539\u6210laravel\/homestead\u5c31\u884c\u4e86\u3002<br \/>\n\u518d\u4e0b\u4e00\u6b65<\/p>\n<pre><code>vagrant ssh<\/code><\/pre>\n<p>\u5c31\u80fd\u8fdb\u53bb\u4e86<br \/>\n\u5728VirtualBox\u91cc\u9762\u7528\u6237\u540d\u548c\u5bc6\u7801\u90fd\u662fvagrant\u4e5f\u80fd\u767b\u5f55<\/li>\n<li>\u6700\u540e\uff0c\u5728mac\u6216\u8005windows\u4e0a\u901a\u8fc7composer\u5728code\u6587\u4ef6\u5939\u91cc\u65b0\u5efa\u597dlaravel\u7684\u9879\u76ee\uff0c\u6bd4\u5982\u53eblmh\u7684\uff0c\u4e0a\u9762\u7684\u914d\u7f6e\u6587\u4ef6\u7684\u8def\u5f84\u518d\u6539\u4e0b\uff0c\u6bd4\u5982\n<pre><code>\nsites:\n    - map: homestead.test\n      to: \/home\/vagrant\/code\/lmh\/public\/\n<\/code><\/pre>\n<p>\u6700\u7ec8\u5c31\u80fd\u5728\u6d4f\u89c8\u5668\u8f93\u5165homestead.test\u8bbf\u95ee\u4e86<\/li>\n<li>\u4e00\u4e9bvagrant\u5e38\u7528\u547d\u4ee4\uff1a$ vagrant init # \u521d\u59cb\u5316$ vagrant up # \u542f\u52a8\u865a\u62df\u673a<br \/>\n$ vagrant halt # \u5173\u95ed\u865a\u62df\u673a<br \/>\n$ vagrant reload # \u91cd\u542f\u865a\u62df\u673a<br \/>\n$ vagrant ssh # SSH \u81f3\u865a\u62df\u673a<br \/>\n$ vagrant suspend # \u6302\u8d77\u865a\u62df\u673a<br \/>\n$ vagrant resume # \u5524\u9192\u865a\u62df\u673a<br \/>\n$ vagrant status # \u67e5\u770b\u865a\u62df\u673a\u8fd0\u884c\u72b6\u6001<br \/>\n$ vagrant destroy # \u9500\u6bc1\u5f53\u524d\u865a\u62df\u673a<\/p>\n<p>#box\u7ba1\u7406\u547d\u4ee4<br \/>\n$ vagrant box list # \u67e5\u770b\u672c\u5730box\u5217\u8868<br \/>\n$ vagrant box add # \u6dfb\u52a0box\u5230\u5217\u8868<\/p>\n<p>$ vagrant box remove # \u4ecebox\u5217\u8868\u79fb\u9664<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>\u53c2\u8003\u6587\u4ef6\uff1a<\/p>\n<p><a href=\"https:\/\/laravel.com\/docs\/5.7\/homestead\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/laravel.com\/docs\/5.7\/homestead<\/a><\/p>\n<p><a href=\"https:\/\/laravel-china.org\/docs\/laravel-development-environment\/5.5\/development-environment-windows\/938\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/laravel-china.org\/docs\/laravel-development-environment\/5.5\/development-environment-windows\/938<\/a><\/p>\n<p><a href=\"https:\/\/laravelacademy.org\/post\/8671.html\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/laravelacademy.org\/post\/8671.html<\/a><\/p>\n<p><a href=\"https:\/\/laravelacademy.org\/post\/354.html\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/laravelacademy.org\/post\/354.html<\/a><\/p>\n<p><a href=\"https:\/\/www.cnblogs.com\/think-a-lot\/p\/7754328.html\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/www.cnblogs.com\/think-a-lot\/p\/7754328.html<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b89\u88c5virtualbox \u5b89\u88c5vagrant Vagrant \u662f\u7528\u6765\u7ba1\u7406\u865a\u62df\u673a\u7684\u5de5\u5177\uff0c\u652f\u6301\u5f53\u524d\u4e3b\u6d41\u7684\u865a\u62df\u673a\u7cfb\u7edf [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[166],"tags":[327,326,168,328,329],"class_list":["post-600","post","type-post","status-publish","format-standard","hentry","category-it","tag-homestead","tag-laravel","tag-php","tag-vagrant","tag-virtualbox"],"views":1696,"_links":{"self":[{"href":"https:\/\/hahacool.com\/index.php?rest_route=\/wp\/v2\/posts\/600"}],"collection":[{"href":"https:\/\/hahacool.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hahacool.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hahacool.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hahacool.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=600"}],"version-history":[{"count":0,"href":"https:\/\/hahacool.com\/index.php?rest_route=\/wp\/v2\/posts\/600\/revisions"}],"wp:attachment":[{"href":"https:\/\/hahacool.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=600"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hahacool.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=600"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hahacool.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=600"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}