{"id":33,"date":"2017-09-12T14:29:46","date_gmt":"2017-09-12T06:29:46","guid":{"rendered":"http:\/\/www.leohe.net.cn\/?p=33"},"modified":"2019-10-18T23:37:29","modified_gmt":"2019-10-18T15:37:29","slug":"laravel-homestead","status":"publish","type":"post","link":"https:\/\/china-abc.leohe.net.cn\/?p=33","title":{"rendered":"Laravel Homestead"},"content":{"rendered":"<h3 id=\"toc_0\">\u7b80\u4ecb<\/h3>\n<p><a title=\"View all posts in Laravel\" href=\"http:\/\/laravelacademy.org\/tags\/laravel\" target=\"_blank\" rel=\"noopener noreferrer\">Laravel<\/a>\u00a0\u4e3a\u5f00\u53d1\u8005\u63d0\u4f9b\u4e86\u4e00\u5957\u5b8c\u5584\u7684\u91cd\u91cf\u7ea7\u672c\u5730<a title=\"View all posts in \u5f00\u53d1\u73af\u5883\" href=\"http:\/\/laravelacademy.org\/tags\/%e5%bc%80%e5%8f%91%e7%8e%af%e5%a2%83\" target=\"_blank\" rel=\"noopener noreferrer\">\u5f00\u53d1\u73af\u5883<\/a>\u00a0\u2014\u2014 Laravel\u00a0<a title=\"View all posts in Homestead\" href=\"http:\/\/laravelacademy.org\/tags\/homestead\" target=\"_blank\" rel=\"noopener noreferrer\">Homestead<\/a>\u3002<\/p>\n<p>Laravel Homestead \u5b9e\u9645\u662f\u4e00\u4e2a\u6253\u5305\u597d\u5404\u79cd Laravel \u5f00\u53d1\u6240\u9700\u8f6f\u4ef6\u548c\u5de5\u5177\u7684\u00a0<a href=\"https:\/\/www.vagrantup.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Vagrant<\/a>\u00a0\u76d2\u5b50\uff08\u5173\u4e8e\u00a0<a title=\"View all posts in Vagrant\" href=\"http:\/\/laravelacademy.org\/tags\/vagrant\" target=\"_blank\" rel=\"noopener noreferrer\">Vagrant<\/a>\u00a0\u76d2\u5b50\u7684\u91ca\u4e49\u8bf7\u53c2\u8003\u00a0<a href=\"https:\/\/www.vagrantup.com\/docs\/boxes.html\" target=\"_blank\" rel=\"noopener noreferrer\">Vagrant \u5b98\u65b9\u6587\u6863<\/a>\uff09\uff0c\u8be5\u76d2\u5b50\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u4e00\u4e2a\u4f18\u79c0\u7684\u5f00\u53d1\u73af\u5883\uff0c\u6709\u4e86\u5b83\uff0c\u6211\u4eec\u4e0d\u518d\u9700\u8981\u5728\u672c\u5730\u73af\u5883<a title=\"View all posts in \u5b89\u88c5\" href=\"http:\/\/laravelacademy.org\/tags\/%e5%ae%89%e8%a3%85\" target=\"_blank\" rel=\"noopener noreferrer\">\u5b89\u88c5<\/a>\u00a0<a title=\"View all posts in PHP\" href=\"http:\/\/laravelacademy.org\/tags\/php\" target=\"_blank\" rel=\"noopener noreferrer\">PHP<\/a>\u3001Composer\u3001<a title=\"View all posts in Nginx\" href=\"http:\/\/laravelacademy.org\/tags\/nginx\" target=\"_blank\" rel=\"noopener noreferrer\">Nginx<\/a>\u3001<a title=\"View all posts in MySQL\" href=\"http:\/\/laravelacademy.org\/tags\/mysql\" target=\"_blank\" rel=\"noopener noreferrer\">MySQL<\/a>\u3001Memcached\u3001Redis\u3001Node \u7b49\u5176\u5b83\u5de5\u5177\u8f6f\u4ef6\uff0c\u6211\u4eec\u4e5f\u5b8c\u5168\u4e0d\u7528\u518d\u62c5\u5fc3\u8bef\u64cd\u4f5c\u641e\u4e71\u64cd\u4f5c\u7cfb\u7edf \u2014\u2014 \u56e0\u4e3a Vagrant \u76d2\u5b50\u662f\u4e00\u6b21\u6027\u7684\uff0c\u5982\u679c\u51fa\u73b0\u9519\u8bef\uff0c\u53ef\u4ee5\u5728\u6570\u5206\u949f\u5185\u9500\u6bc1\u5e76\u91cd\u65b0\u521b\u5efa\u8be5 Vagrant \u76d2\u5b50\uff01<\/p>\n<p>\u4e3a\u4ec0\u4e48\u8bf4\u5b83\u662f\u91cd\u91cf\u7ea7\u7684\u5f00\u53d1\u73af\u5883\u5462\uff1f\u8c01\u7528\u8c01\u77e5\u9053\uff0c\u8981\u4f7f\u7528\u4e0a\u8fd9\u4e2a\u5f00\u53d1\u73af\u5883\uff0c\u4f60\u9700\u8981\u5b89\u88c5 Vagrant\u3001<a title=\"View all posts in VirtualBox\" href=\"http:\/\/laravelacademy.org\/tags\/virtualbox\" target=\"_blank\" rel=\"noopener noreferrer\">VirtualBox<\/a>\uff0c\u4e0b\u8f7d Homestead \u5bf9\u5e94\u7684 Vagrant \u76d2\u5b50\uff0c\u7ecf\u5386\u4e00\u7cfb\u5217\u4e0b\u8f7d\u3001\u5b89\u88c5\u548c<a title=\"View all posts in \u914d\u7f6e\" href=\"http:\/\/laravelacademy.org\/tags\/%e9%85%8d%e7%bd%ae\" target=\"_blank\" rel=\"noopener noreferrer\">\u914d\u7f6e<\/a>\u4e4b\u540e\u624d\u80fd\u4f7f\u7528\uff08\u53ef\u80fd\u9700\u8981\u82b1\u8d39\u6570\u5c0f\u65f6\uff09\uff0c\u5982\u679c\u662f Mac \u6216 Linux \u7cfb\u7edf\u53ef\u80fd\u8fd8\u6bd4\u8f83\u987a\u5229\uff0c\u5982\u679c\u662f Windows \u7cfb\u7edf\u7684\u8bdd\u5c31\u5f97\u5148\u70e7\u67f1\u9999\u62dc\u62dc\u83e9\u8428\u518d\u5f00\u59cb\uff0c\u4fdd\u4f51\u4e00\u5207\u987a\u5229\uff0c\u54c8\u54c8\uff0c\u5f00\u73a9\u7b11\u5566\uff0c\u4e0d\u8fc7 Windows \u786e\u5b9e\u76f8\u5bf9\u800c\u8a00\u51fa\u95ee\u9898\u7684\u6982\u7387\u6bd4\u8f83\u5927\u3002<\/p>\n<p>\u6709\u4eba\u8981\u8bf4\u4e86\uff0c\u542c\u4e0a\u53bb\u8fd9\u4e48\u590d\u6742\uff0c\u6211\u5c31\u4e0d\u7528\u4e86\uff0c\u4e0d\u8fc7\u76f8\u4fe1\u6211\u5427\uff0c\u8fd9\u70b9\u65f6\u95f4\u90fd\u4f1a\u5728\u65e5\u540e\u56e0\u4e3a Homestead \u5f3a\u5927\u5b8c\u5584\u7684\u529f\u80fd\u5728\u5f00\u53d1\u8fc7\u7a0b\u4e2d\u8865\u56de\u6765\uff0c\u6b63\u6240\u8c13\u78e8\u5200\u4e0d\u8bef\u780d\u67f4\u529f\uff0cHomestead \u4e0d\u4ec5\u4e3a\u4f60\u63d0\u4f9b\u4e86\u4e00\u6574\u5957\u65e5\u540e\u5f00\u53d1\u6240\u9700\u8981\u7684\u5de5\u5177\uff0c\u800c\u4e14\u4e0e Laravel \u914d\u7f6e\u6587\u4ef6\u9ed8\u8ba4\u914d\u7f6e\u65e0\u7f1d\u7ed3\u5408\uff0c\u7701\u53bb\u4e86\u5f88\u591a\u914d\u7f6e\u7684\u9ebb\u70e6\uff0c\u6b64\u5916\uff0c\u5982\u679c\u662f\u5728\u56e2\u961f\u4e2d\u5f00\u53d1\u7684\u8bdd\uff0cHomestead \u8fd8\u4e3a\u4f60\u4eec\u63d0\u4f9b\u4e86\u4e00\u81f4\u7684\u5f00\u53d1\u73af\u5883\uff0c\u907f\u514d\u56e0\u4e3a\u4e0d\u540c\u5f00\u53d1\u4eba\u5458\u4f7f\u7528\u7684\u5de5\u5177\u8f6f\u4ef6\u7248\u672c\u4e0d\u540c\u9020\u6210\u7ebf\u4e0a\u7684\u95ee\u9898\uff0c\u8fd9\u4e09\u4e2a\u7406\u7531\uff0c\u6211\u60f3\u8db3\u591f\u53ef\u4ee5\u8bf4\u670d\u4f60\u4e86\u3002<\/p>\n<p>\u5f53\u7136\uff0c\u5982\u679c\u4f60\u53ea\u662f\u60f3\u7b80\u5355\u5c1d\u9c9c\uff0c\u4e0d\u4f7f\u7528 Homestead \u4e5f\u65e0\u53ef\u539a\u975e\uff0c\u6bd5\u7adf Mac \u4e0b\u6709 Valet\uff0cWindows \u4e0b\u5219\u53ef\u4ee5\u4f7f\u7528 Xampp \u4e4b\u7c7b\u7684\u4fbf\u6377\u5de5\u5177\u5305\uff0c\u4f46\u662f\u5982\u679c\u662f\u5de5\u7a0b\u5316\u5f00\u53d1\uff0c\u8d70\u6b63\u89c4\u519b\u8def\u5b50\u8fd8\u662f\u63a8\u8350\u4f7f\u7528 Homestead\u3002<\/p>\n<p>Homestead \u53ef\u4ee5\u8fd0\u884c\u5728 Windows\u3001Mac \u4ee5\u53ca Linux \u7b49\u4e3b\u6d41\u64cd\u4f5c\u7cfb\u7edf\u4e0a\uff0c\u9884\u88c5\u7684\u8f6f\u4ef6\u548c\u5de5\u5177\u5217\u8868\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li>Ubuntu 16.04<\/li>\n<li>Git<\/li>\n<li>PHP 7.1<\/li>\n<li>Nginx<\/li>\n<li>MySQL<\/li>\n<li>MariaDB<\/li>\n<li>SQLite 3<\/li>\n<li>Postgres<\/li>\n<li>Composer<\/li>\n<li>Node\uff08With Yarn, Bower, Grunt, and Gulp\uff09<\/li>\n<li>Redis<\/li>\n<li>Memcached<\/li>\n<li>Beanstalkd<\/li>\n<li>Mailhog<\/li>\n<li>ngrok<\/li>\n<\/ul>\n<blockquote><p>\u6ce8\uff1a\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f Windows\uff0c\u9700\u8981\u5f00\u542f\u7cfb\u7edf\u7684\u786c\u4ef6\u865a\u62df\u5316\uff08VT-x\uff09\uff0c\u8fd9\u901a\u5e38\u53ef\u4ee5\u901a\u8fc7 BIOS \u6765\u5f00\u542f\u3002\u5982\u679c\u4f60\u662f\u5728 UEFI \u7cfb\u7edf\u4e0a\u4f7f\u7528 Hyper-V\uff0c\u5219\u9700\u8981\u5173\u95ed Hyper-V \u4ee5\u4fbf\u53ef\u4ee5\u8bbf\u95ee VT-x\u3002<\/p><\/blockquote>\n<h3 id=\"toc_1\">\u9996\u6b21\u5b89\u88c5<\/h3>\n<blockquote><p>\u6ce8\uff1a\u5982\u679c\u4e4b\u524d\u5df2\u7ecf\u5b89\u88c5\u4e86 Homestead\uff0c\u53ef\u4ee5\u76f4\u63a5\u8df3\u8f6c\u5230<a href=\"http:\/\/laravelacademy.org\/post\/7658.html#toc_17\">\u5347\u7ea7\u90e8\u5206<\/a>\uff0c\u7136\u540e\u56de\u8fc7\u5934\u770b\u4e0b\u65b0\u7248\u672c\u65b0\u589e\u7684\u7279\u6027\u3002<\/p><\/blockquote>\n<p>\u5728\u4f7f\u7528 Homestead \u4e4b\u524d\uff0c\u9700\u8981\u5148\u5b89\u88c5\u00a0<a href=\"https:\/\/www.virtualbox.org\/wiki\/Downloads\" target=\"_blank\" rel=\"noopener noreferrer\">Virtual Box 5.1<\/a>\u3001<a href=\"https:\/\/www.vmware.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">VMWare<\/a>\u00a0\u6216\u00a0<a href=\"http:\/\/www.parallels.com\/products\/desktop\/\" target=\"_blank\" rel=\"noopener noreferrer\">Parallels<\/a>\u00a0\uff08\u4e09\u9009\u4e00\uff0c\u6211\u4eec\u901a\u5e38\u9009\u62e9 VirtualBox\uff0c\u56e0\u4e3a\u53ea\u6709\u5b83\u662f\u514d\u8d39\u7684\uff09\u4ee5\u53ca\u00a0<a href=\"https:\/\/www.vagrantup.com\/downloads.html\" target=\"_blank\" rel=\"noopener noreferrer\">Vagrant<\/a>\uff0c\u6240\u6709\u8fd9\u4e9b\u8f6f\u4ef6\u5305\u90fd\u4e3a\u5e38\u7528\u64cd\u4f5c\u7cfb\u7edf\u63d0\u4f9b\u4e86\u4e00\u4e2a\u4fbf\u4e8e\u4f7f\u7528\u7684\u53ef\u89c6\u5316\u5b89\u88c5\u5668\uff0c\u901a\u8fc7\u5b89\u88c5\u754c\u9762\u5f15\u5bfc\u5c31\u53ef\u4ee5\u5b8c\u6210\u5b89\u88c5\u3002<\/p>\n<p>\u8981\u4f7f\u7528 VMware \u7684\u8bdd\uff0c\u9700\u8981\u8d2d\u4e70 VMware Fusion\uff08Mac\uff09 \/ Workstation\uff08Windows\uff09 \u4ee5\u53ca\u00a0<a href=\"https:\/\/www.vagrantup.com\/vmware\" target=\"_blank\" rel=\"noopener noreferrer\">VMware Vagrant \u63d2\u4ef6<\/a>\uff0c\u5c3d\u7ba1\u4e0d\u4fbf\u5b9c\uff0c\u4e00\u5957\u4e0b\u6765\u8981 1000 \u591a\u5757\u4eba\u6c11\u5e01\uff0c\u4f46\u662f VMware \u53ef\u4ee5\u63d0\u4f9b\u66f4\u597d\u7684\u6027\u80fd\u548c\u4f53\u9a8c\uff08\u5e9f\u8bdd\uff0c\u4e0d\u7136\u8c01\u7528\uff09\u3002<\/p>\n<p>\u8981\u4f7f\u7528 Parallels \u7684\u8bdd\uff0c\u9700\u8981\u5b89\u88c5 Parallels Vagrant \u63d2\u4ef6\uff0c\u8fd9\u662f\u514d\u8d39\u7684\uff08\u4ec5\u4ec5\u662f\u63d2\u4ef6\u514d\u8d39\u54c8\uff09\u3002<\/p>\n<p><strong>\u5b89\u88c5 Homestead Vagrant \u76d2\u5b50<\/strong><\/p>\n<p>VirtualBox\/VMWare \u548c Vagrant \u5b89\u88c5\u597d\u4e86\u4e4b\u540e\uff0c\u5728\u7ec8\u7aef\u4e2d\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u5c06<br \/>\nHomestead Vagrant \u76d2\u5b50\u00a0<code>laravel\/homesterad<\/code>\u00a0\u6dfb\u52a0\u5230 Vagrant \u4e2d\u3002\u4e0b\u8f7d\u8be5\u76d2\u5b50\u5c06\u4f1a\u82b1\u8d39\u4e00\u4e9b\u65f6\u95f4\uff0c\u5177\u4f53\u65f6\u95f4\u957f\u77ed\u4e3b\u8981\u53d6\u51b3\u4e8e\u4f60\u7684<a title=\"View all posts in \u7f51\u7edc\" href=\"http:\/\/laravelacademy.org\/tags\/%e7%bd%91%e7%bb%9c\" target=\"_blank\" rel=\"noopener noreferrer\">\u7f51\u7edc<\/a>\u8fde\u63a5\u901f\u5ea6\uff1a<\/p>\n<pre><code>vagrant box add laravel\/homestead\r\n<\/code><\/pre>\n<p><img decoding=\"async\" src=\"http:\/\/static.laravelacademy.org\/wp-content\/uploads\/2017\/09\/15048836572501.jpg\" alt=\"\" \/>\ufffc<\/p>\n<blockquote><p>\u6ce8\uff1a\u5982\u679c\u4e0a\u8ff0\u547d\u4ee4\u6267\u884c\u5931\u8d25\uff0c\u9700\u8981\u786e\u8ba4 Vagrant \u662f\u5426\u662f\u6700\u65b0\u7248\u672c\u3002<\/p><\/blockquote>\n<p>\u8fd0\u884c\u547d\u4ee4\u4f1a\u5217\u51fa\u4e00\u4e2a\u9009\u62e9\u5217\u8868\uff0c\u9009\u62e9\u00a0<code>virtualbox<\/code>\u00a0\u5bf9\u5e94\u9009\u9879\u5373\u53ef\uff0c\u7136\u540e\u8fdb\u5165\u6f2b\u957f\u7684\u4e0b\u8f7d\u7b49\u5f85\uff0c\u770b\u770b\u591a\u559c\u4eba\uff0c\u8fd8\u89816\u5c0f\u65f640\u5206\u949f\u624d\u80fd\u4e0b\u8f7d\u5b8c\u6210\uff0c\u57fa\u672c\u4e0a\u4e00\u89c9\u9192\u6765\u7684\u8282\u594f\uff0c\u8fd8\u662f\u5728\u4f7f\u7528\u4e86 VPN \u7ffb\u5899\u7684\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u4e00\u76f4\u63d0\u793a\u7f51\u7edc\u8d85\u65f6\u7684\u8bdd\u53ea\u80fd\u53bb Vagrant \u5b98\u7f51\u4e0b\u8f7d\u4e86\uff08<a href=\"https:\/\/atlas.hashicorp.com\/laravel\/boxes\/homestead\/versions\/0.5.0\/providers\/virtualbox.box\" target=\"_blank\" rel=\"noopener noreferrer\">\u4e0b\u8f7d\u5730\u5740<\/a>\uff09\uff0c\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\u4e0b\u8f7d\u7684\u8bdd\u9700\u8981\u624b\u52a8\u5c06\u5176\u6dfb\u52a0\u5230 Vagrant\uff1a<\/p>\n<pre><code>vagrant box add laravel\/homestead ~\/Downloads\/virtualbox.box\r\n<\/code><\/pre>\n<p>\u8fd0\u884c\u4e0a\u8ff0\u547d\u4ee4\u6709\u53ef\u80fd\u62a5\u9519\uff1a<\/p>\n<pre><code>Check your Homestead.yaml file, the path to your private key does not exist.\r\n<\/code><\/pre>\n<p>\u89e3\u51b3\u529e\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre><code>ssh-keygen -t rsa -b 4096 -C \"your_email@example.com\"\r\neval \"$(ssh-agent -s)\"\r\nssh-add -K ~\/.ssh\/id_rsa\r\n<\/code><\/pre>\n<p>\u518d\u6b21\u8fd0\u884c\u4e0a\u8ff0\u547d\u4ee4\u5373\u53ef\u6dfb\u52a0\u6210\u529f\uff1a<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/static.laravelacademy.org\/wp-content\/uploads\/2017\/09\/15049606987873.jpg\" alt=\"\" \/>\ufffc<\/p>\n<p><strong>\u5b89\u88c5 Homestead<\/strong><\/p>\n<p>\u4f60\u53ef\u4ee5\u901a\u8fc7\u514b\u9686\u4ed3\u5e93\u4ee3\u7801\u6765\u5b9e\u73b0 Homestead \u5b89\u88c5\u3002\u5c06\u4ed3\u5e93\u514b\u9686\u5230\u7528\u6237\u76ee\u5f55\u4e0b\u7684\u00a0<code>Homestead<\/code>\u00a0\u76ee\u5f55\uff0c\u8fd9\u6837 Homestead \u76d2\u5b50\u5c31\u53ef\u4ee5\u4f5c\u4e3a\u6240\u6709\u5176\u4ed6 Laravel \u9879\u76ee\u7684\u4e3b\u673a\uff1a<\/p>\n<pre><code>cd ~\r\ngit clone https:\/\/github.com\/laravel\/homestead.git Homestead\r\n<\/code><\/pre>\n<p>\u514b\u9686\u5b8c\u6210\u540e\uff0c\u4f60\u9700\u8981\u68c0\u67e5 Homestead \u7684\u7248\u672c\u6807\u7b7e\uff0c\u56e0\u4e3a\u00a0<code>master<\/code>\u00a0\u5206\u652f\u4e0d\u4f1a\u603b\u662f\u7a33\u5b9a\u7248\u672c\uff0c\u4f60\u53ef\u4ee5\u5728\u00a0<a href=\"https:\/\/github.com\/laravel\/homestead\/releases\" target=\"_blank\" rel=\"noopener noreferrer\">GitHub Release Page<\/a>\u00a0\u67e5\u627e\u5230\u6700\u65b0\u7a33\u5b9a\u7248\u672c\u7136\u540e\u5728\u672c\u5730\u5c06\u5176\u68c0\u51fa\uff1a<\/p>\n<pre><code>cd Homestead\r\n\r\n\/\/ Clone the desired release...\r\ngit checkout v6.1.0\r\n<\/code><\/pre>\n<p>\u63a5\u4e0b\u6765\uff0c\u5728\u00a0<code>Homestead<\/code>\u00a0\u76ee\u5f55\u4e0b\u8fd0\u884c\u00a0<code>bash init.sh<\/code>\u00a0\u547d\u4ee4\u6765\u521b\u5efa\u00a0<code>Homestead.yaml<\/code>\u00a0\u914d\u7f6e\u6587\u4ef6\uff0c\u751f\u6210\u7684\u00a0<code>Homestead.yaml<\/code>\u914d\u7f6e\u6587\u4ef6\u6587\u4ef6\u4f4d\u4e8e\u5f53\u524d\u00a0<code>Homestead<\/code>\u00a0\u76ee\u5f55\uff1a<\/p>\n<pre><code>\/\/ Mac\/Linux...\r\nbash init.sh\r\n\r\n\/\/ Windows...\r\ninit.bat\r\n<\/code><\/pre>\n<h3 id=\"toc_2\">\u914d\u7f6e Homestead<\/h3>\n<p><strong>\u8bbe\u7f6e Provider<\/strong><\/p>\n<p><code>Homestead.yaml<\/code>\u00a0\u6587\u4ef6\u4e2d\u7684\u00a0<code>provider<\/code>\u00a0\u952e\u8868\u793a\u4f7f\u7528\u54ea\u4e2a Vagrant \u63d0\u4f9b\u8005\uff1a<code>virtualbox<\/code>\u3001<code>vmware_fushion<\/code>\u3001\u00a0<code>vmware_workstation<\/code>\u00a0\u6216\u00a0<code>parallels<\/code>\uff0c\u4f60\u53ef\u4ee5\u5c06\u5176\u8bbe\u7f6e\u4e3a\u81ea\u5df1\u559c\u6b22\u7684\u63d0\u4f9b\u8005\uff0c\u5f53\u7136\u5bf9\u5927\u90e8\u5206\u4eba\u6765\u8bf4\u4e5f\u6ca1\u5f97\u9009\uff1a<\/p>\n<pre><code>provider: virtualbox\r\n<\/code><\/pre>\n<p><strong>\u914d\u7f6e\u5171\u4eab\u6587\u4ef6\u5939<\/strong><\/p>\n<p><code>Homestead.yaml<\/code>\u00a0\u6587\u4ef6\u4e2d\u7684\u00a0<code>folders<\/code>\u00a0\u5c5e\u6027\u5217\u51fa\u4e86\u6240\u6709\u4e3b\u673a\u548c Homestead\u00a0<a title=\"View all posts in \u865a\u62df\u673a\" href=\"http:\/\/laravelacademy.org\/tags\/%e8%99%9a%e6%8b%9f%e6%9c%ba\" target=\"_blank\" rel=\"noopener noreferrer\">\u865a\u62df\u673a<\/a>\u5171\u4eab\u7684\u6587\u4ef6\u5939\uff0c\u4e00\u65e6\u8fd9\u4e9b\u76ee\u5f55\u4e2d\u7684\u6587\u4ef6\u6709\u4e86\u4fee\u6539\uff0c\u5c06\u4f1a\u5728\u672c\u5730\u548c Homestead \u865a\u62df\u673a\u4e4b\u95f4\u4fdd\u6301\u540c\u6b65\uff0c\u5982\u679c\u6709\u9700\u8981\u7684\u8bdd\uff0c\u4f60\u53ef\u4ee5\u914d\u7f6e\u591a\u4e2a\u5171\u4eab\u6587\u4ef6\u5939\uff1a<\/p>\n<pre><code>folders:\r\n    - map: ~\/Development\r\n      to: \/home\/vagrant\/Code\r\n<\/code><\/pre>\n<p>\u5982\u679c\u8981\u5f00\u542f\u00a0<a href=\"https:\/\/www.vagrantup.com\/docs\/synced-folders\/nfs.html\" target=\"_blank\" rel=\"noopener noreferrer\">NFS<\/a>\uff0c\u53ea\u9700\u7b80\u5355\u6dfb\u52a0\u4e00\u4e2a\u6807\u8bc6\u5230\u540c\u6b65\u6587\u4ef6\u5939\u914d\u7f6e\uff1a<\/p>\n<pre><code>folders:\r\n    - map: ~\/Development\r\n      to: \/home\/vagrant\/Code\r\n      type: \"nfs\"\r\n<\/code><\/pre>\n<blockquote><p>\u6ce8\uff1a\u4f7f\u7528 NFS \u7684\u8bdd\uff0c\u9700\u8981\u8003\u8651\u5b89\u88c5\u00a0<a href=\"https:\/\/github.com\/gael-ian\/vagrant-bindfs\" target=\"_blank\" rel=\"noopener noreferrer\">vagrant-bindfs<\/a>\u00a0\u63d2\u4ef6\u3002\u8be5\u63d2\u4ef6\u53ef\u7528\u4e8e\u5728 Homestead \u76d2\u5b50\u4e2d\u4e3a\u6587\u4ef6\u548c\u76ee\u5f55\u7ef4\u62a4\u6b63\u786e\u7684\u7528\u6237\/\u7ec4\u6743\u9650\u3002<\/p><\/blockquote>\n<p>\u4f60\u8fd8\u53ef\u4ee5\u901a\u8fc7\u00a0<code>options<\/code>\u00a0\u4f20\u9012\u5176\u4ed6 Vagrant \u652f\u6301\u7684<a href=\"https:\/\/www.vagrantup.com\/docs\/synced-folders\/basic_usage.html\" target=\"_blank\" rel=\"noopener noreferrer\">\u540c\u6b65\u6587\u4ef6\u5939<\/a>\u9009\u9879\uff1a<\/p>\n<pre><code>folders:\r\n    - map: ~\/Development\r\n      to: \/home\/vagrant\/Code\r\n      type: \"rsync\"\r\n      options:\r\n          rsync__args: [\"--verbose\", \"--archive\", \"--delete\", \"-zz\"]\r\n          rsync__exclude: [\"node_modules\"]\r\n<\/code><\/pre>\n<p><strong>\u914d\u7f6e Nginx \u7ad9\u70b9<\/strong><\/p>\n<p>\u5bf9 Nginx \u4e0d\u719f\uff1f\u6ca1\u5173\u7cfb\uff01\u901a\u8fc7\u00a0<code>sites<\/code>\u00a0\u5c5e\u6027\u4f60\u53ef\u4ee5\u65b9\u4fbf\u5730\u5c06\u201c\u57df\u540d\u201d\u6620\u5c04\u5230 Homestead \u865a\u62df\u673a\u7684\u6307\u5b9a\u76ee\u5f55\uff0c<code>Homestead.yaml<\/code>\u00a0\u4e2d\u9ed8\u8ba4\u5df2\u7ecf\u914d\u7f6e\u4e86\u4e00\u4e2a\u793a\u4f8b\u7ad9\u70b9\u3002\u548c\u5171\u4eab\u6587\u4ef6\u5939\u4e00\u6837\uff0c\u4f60\u53ef\u4ee5\u914d\u7f6e\u591a\u4e2a\u7ad9\u70b9\uff1a<\/p>\n<pre><code>sites:\r\n    - map: homestead.app\r\n      to: \/home\/vagrant\/Code\/Laravel\/public\r\n<\/code><\/pre>\n<p>\u5982\u679c\u4f60\u662f\u5728 Homestead \u76d2\u5b50\u542f\u52a8\u4e4b\u540e\u8fdb\u884c\u4e86\u4e0a\u8ff0\u4fee\u6539\uff0c\u9700\u8981\u8fd0\u884c\u00a0<code>vagrant reload --provision<\/code>\u00a0\u66f4\u65b0\u865a\u62df\u673a\u4e0a\u7684 Nginx \u914d\u7f6e\u3002<\/p>\n<p><strong>Hosts\u6587\u4ef6<\/strong><\/p>\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\u00a0<code>hosts<\/code>\u00a0\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\u00a0<code>\/etc\/hosts<\/code>\uff0c\u5728 Windows \u4e0a\uff0c\u4f4d\u4e8e\u00a0<code>C:\\Windows\\System32\\drivers\\etc\\hosts<\/code>\uff0c\u6dfb\u52a0\u65b9\u5f0f\u5982\u4e0b\uff1a<\/p>\n<pre><code>192.168.10.10 homestead.app\r\n<\/code><\/pre>\n<p>\u786e\u4fdd IP \u5730\u5740\u548c\u4f60\u7684\u00a0<code>Homestead.yaml<\/code>\u00a0\u6587\u4ef6\u4e2d\u5217\u51fa\u7684\u4e00\u81f4\uff0c\u4e00\u65e6\u4f60\u5c06\u57df\u540d\u6dfb\u52a0\u5230\u00a0<code>hosts<\/code>\u00a0\u6587\u4ef6\uff0c\u5c31\u53ef\u4ee5\u5728\u6d4f\u89c8\u5668\u4e2d\u901a\u8fc7\u8be5\u57df\u540d\u8bbf\u95ee\u7ad9\u70b9\u4e86\uff1a<\/p>\n<pre><code>http:\/\/homestead.app\r\n<\/code><\/pre>\n<blockquote><p>\u6ce8\uff1a\u5728\u771f\u6b63\u53ef\u4ee5\u8bbf\u95ee\u4e4b\u524d\u4e4b\u524d\u8fd8\u9700\u8981\u901a\u8fc7 Vagrant \u542f\u52a8\u865a\u62df\u673a\u4e0a\u7684 Homestead \u76d2\u5b50\u3002<\/p><\/blockquote>\n<h3 id=\"toc_3\">\u542f\u52a8 Vagrant Box<\/h3>\n<p>\u914d\u7f6e\u597d\u00a0<code>Homestead.yaml<\/code>\u00a0\u6587\u4ef6\u540e\uff0c\u5728\u00a0<code>Homestead<\/code>\u00a0\u76ee\u5f55\u4e0b\u8fd0\u884c\u00a0<code>vagrant up<\/code>\u00a0\u547d\u4ee4\uff0cVagrant \u5c06\u4f1a\u542f\u52a8\u865a\u62df\u673a\u5e76\u81ea\u52a8\u914d\u7f6e\u5171\u4eab\u6587\u4ef6\u5939\u4ee5\u53ca Nginx \u7ad9\u70b9\uff0c\u521d\u6b21\u542f\u52a8\u9700\u8981\u82b1\u8d39\u4e00\u70b9\u65f6\u95f4\u8fdb\u884c\u521d\u59cb\u5316\uff1a<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/static.laravelacademy.org\/wp-content\/uploads\/2017\/09\/15049624010579.jpg\" alt=\"\" \/>\ufffc<\/p>\n<p>\u542f\u52a8\u4e4b\u540e\uff0c\u5c31\u53ef\u4ee5\u5728\u6d4f\u89c8\u5668\u4e2d\u901a\u8fc7\u00a0<code>http:\/\/homestead.app<\/code>\u00a0\u8bbf\u95ee Laravel \u5e94\u7528\u4e86\uff08\u524d\u63d0\u662f Web \u76ee\u5f55\u4e0b\u5df2\u7ecf\u90e8\u7f72 Laravel \u5e94\u7528\u4ee3\u7801\uff09\uff1a<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/static.laravelacademy.org\/wp-content\/uploads\/2017\/09\/15049615378429.jpg\" alt=\"\" \/>\ufffc<\/p>\n<p>\u8981\u767b\u5f55\u5230\u8be5\u865a\u62df\u673a\uff0c\u4f7f\u7528\u00a0<code>vagrant ssh<\/code>\u00a0\u547d\u4ee4\uff1b\u5173\u95ed\u8be5\u865a\u62df\u673a\uff0c\u53ef\u4ee5\u4f7f\u7528\u00a0<code>vagrant halt<\/code>\u00a0\u547d\u4ee4\uff1b\u9500\u6bc1\u8be5\u865a\u62df\u673a\uff0c\u53ef\u4ee5\u4f7f\u7528\u00a0<code>vagrant destroy --force<\/code>\u00a0\u547d\u4ee4\u3002<\/p>\n<h3 id=\"toc_4\">\u53ef\u9009\u64cd\u4f5c<\/h3>\n<h4 id=\"toc_5\">\u4e3a\u6307\u5b9a\u9879\u76ee\u5b89\u88c5 Homestead<\/h4>\n<p>\u5168\u5c40\u5b89\u88c5 Homestead \u5c06\u4f1a\u4f7f\u6bcf\u4e2a\u9879\u76ee\u5171\u4eab\u540c\u4e00\u4e2a Homestead \u76d2\u5b50\uff0c\u4f60\u8fd8\u53ef\u4ee5\u4e3a\u6bcf\u4e2a\u9879\u76ee\u5355\u72ec\u5b89\u88c5 Homestead\uff0c\u8fd9\u6837\u5c31\u4f1a\u5728\u8be5\u9879\u76ee\u4e0b\u521b\u5efa\u00a0<code>Vagrantfile<\/code>\uff0c\u5141\u8bb8\u5176\u4ed6\u4eba\u5728\u8be5\u9879\u76ee\u4e2d\u6267\u884c\u00a0<code>vagrant up<\/code>\u00a0\u547d\u4ee4\uff0c\u5728\u6307\u5b9a\u9879\u76ee\u6839\u76ee\u5f55\u4e0b\u4f7f\u7528 Composer \u6267\u884c\u5b89\u88c5\u547d\u4ee4\u5982\u4e0b\uff1a<\/p>\n<pre><code>composer require laravel\/homestead --dev\r\n<\/code><\/pre>\n<p>\u8fd9\u6837\u5c31\u5728\u9879\u76ee\u4e2d\u5b89\u88c5\u4e86 Homestead\u3002Homestead \u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u4f7f\u7528\u00a0<code>make<\/code>\u00a0\u547d\u4ee4\u751f\u6210\u00a0<code>Vagrantfile<\/code>\u00a0\u548c\u00a0<code>Homestead.yaml<\/code>\u00a0\u6587\u4ef6\uff0c<code>make<\/code>\u00a0\u547d\u4ee4\u5c06\u4f1a\u81ea\u52a8\u914d\u7f6e\u00a0<code>Homestead.yaml<\/code>\u00a0\u4e2d\u7684\u00a0<code>sites<\/code>\u00a0\u548c\u00a0<code>folders<\/code>\u00a0\u5c5e\u6027\u3002\u8be5\u547d\u4ee4\u6267\u884c\u65b9\u5f0f\u5982\u4e0b\uff1a<\/p>\n<p>Mac\/Linux\uff1a<\/p>\n<pre><code>php vendor\/bin\/homestead make\r\n<\/code><\/pre>\n<p>Windows:<\/p>\n<pre><code>vendor\\bin\\homestead make\r\n<\/code><\/pre>\n<p>\u63a5\u4e0b\u6765\uff0c\u5728\u7ec8\u7aef\u4e2d\u8fd0\u884c\u00a0<code>vagrant up<\/code>\u00a0\u547d\u4ee4\u7136\u540e\u5728\u6d4f\u89c8\u5668\u4e2d\u901a\u8fc7\u00a0<code>http:\/\/homestead.app<\/code>\u00a0\u8bbf\u95ee\u7ad9\u70b9\u3002\u4e0d\u8981\u5fd8\u8bb0\u5728\u00a0<code>\/etc\/hosts<\/code>\u00a0\u6587\u4ef6\u4e2d\u6dfb\u52a0\u57df\u540d\u00a0<code>homestead.app<\/code>\uff08\u5df2\u914d\u7f6e\u7684\u8bdd\u5ffd\u7565\uff09\u3002<\/p>\n<h4 id=\"toc_6\">\u5b89\u88c5MariaDB<\/h4>\n<p>\u5982\u679c\u4f60\u5e0c\u671b\u4f7f\u7528 MariaDB \u6765\u66ff\u4ee3 MySQL\uff0c\u53ef\u4ee5\u6dfb\u52a0\u00a0<code>mariadb<\/code>\u00a0\u914d\u7f6e\u9879\u5230\u00a0<code>Homestead.yaml<\/code>\u00a0\u6587\u4ef6\uff0c\u8be5\u9009\u9879\u4f1a\u79fb\u9664 MySQL \u5e76\u5b89\u88c5 MariaDB\uff0cMariaDB \u662f MySQL \u7684\u66ff\u4ee3\u54c1\uff0c\u5b8c\u5168\u517c\u5bb9 MySQL\uff0c\u6240\u4ee5\u5728\u5e94\u7528\u6570\u636e\u5e93\u914d\u7f6e\u4e2d\u4f60\u4ecd\u7136\u53ef\u4ee5\u4f7f\u7528\u00a0<code>mysql<\/code>\u00a0\u9a71\u52a8\uff1a<\/p>\n<pre><code>box: laravel\/homestead\r\nip: \"192.168.20.20\"\r\nmemory: 2048\r\ncpus: 4\r\nprovider: virtualbox\r\nmariadb: true\r\n<\/code><\/pre>\n<h3 id=\"toc_7\">\u65e5\u5e38\u4f7f\u7528<\/h3>\n<h4 id=\"toc_8\">\u5168\u5c40\u8bbf\u95ee Homestead<\/h4>\n<p>\u8981\u60f3\u5728\u6587\u4ef6\u7cfb\u7edf\u7684\u4efb\u610f\u8def\u5f84\u90fd\u80fd\u591f\u8fd0\u884c\u00a0<code>vagrant up<\/code>\u00a0\u542f\u52a8 Homestead \u865a\u62df\u673a\uff0c\u5728 Mac\/Linux \u7cfb\u7edf\u4e2d\uff0c\u53ef\u4ee5\u6dfb\u52a0\u00a0<code>Bash<\/code>\u51fd\u6570\u5230\u00a0<code>~\/.bash_profile<\/code>\uff1b\u5728 Windows \u7cfb\u7edf\u4e0a\uff0c\u9700\u8981\u6dfb\u52a0\u201c\u6279\u5904\u7406\u201d\u6587\u4ef6\u5230\u00a0<code>PATH<\/code>\u3002\u8fd9\u4e9b\u811a\u672c\u5141\u8bb8\u4f60\u5728\u7cfb\u7edf\u7684\u4efb\u610f\u4f4d\u7f6e\u8fd0\u884c Vagrant \u547d\u4ee4\uff0c\u5e76\u4e14\u628a\u547d\u4ee4\u6267\u884c\u4f4d\u7f6e\u6307\u5411 Homestead \u7684\u5b89\u88c5\u8def\u5f84\u3002<\/p>\n<p><strong>Mac\/Linux<\/strong><\/p>\n<pre><code>function homestead() {\r\n    ( cd ~\/Homestead &amp;&amp; vagrant $* )\r\n}\r\n<\/code><\/pre>\n<p>\u786e\u4fdd\u5c06\u8be5\u51fd\u6570\u4e2d\u7684\u00a0<code>~\/Homestead<\/code>\u00a0\u8def\u5f84\u8c03\u6574\u4e3a\u6307\u5411\u5b9e\u9645\u7684\u00a0<code>Homestead<\/code>\u00a0\u5b89\u88c5\u8def\u5f84\u3002\u8fd9\u6837\u4f60\u5c31\u53ef\u4ee5\u5728\u7cfb\u7edf\u7684\u4efb\u610f\u4f4d\u7f6e\u8fd0\u884c\u00a0<code>homestead up<\/code>\u00a0\u6216\u00a0<code>homestead ssh<\/code>\u00a0\u6765\u542f\u52a8\/\u767b\u5f55\u865a\u62df\u673a\uff1a<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/static.laravelacademy.org\/wp-content\/uploads\/2017\/09\/15049623343243.jpg\" alt=\"\" \/>\ufffc<\/p>\n<blockquote><p>\u8865\u5145\u77e5\u8bc6\u70b9\uff1a<code>\/etc\/profile<\/code>\u00a0\u548c\u00a0<code>~\/.bash_profile<\/code>\u00a0\u90fd\u53ef\u4ee5\u7528\u6765\u8bbe\u7f6e\u7cfb\u7edf\u00a0<code>PATH<\/code>\uff0c\u4e0d\u540c\u4e4b\u5904\u5728\u4e8e\u524d\u8005\u662f\u7ed9\u7cfb\u7edf\u8d85\u7ea7\u7528\u6237\u4f7f\u7528\uff0c\u540e\u8005\u662f\u7ed9\u666e\u901a\u767b\u5f55\u7528\u6237\u4f7f\u7528\u7684\uff0c\u6b64\u5916\u8981\u8ba9\u00a0<code>~\/.bash_profile<\/code>\u00a0\u4fee\u6539\u540e\u751f\u6548\uff0c\u6709\u4e24\u79cd\u65b9\u6cd5\uff0c\u4e00\u79cd\u662f\u9000\u51fa\u7cfb\u7edf\u91cd\u65b0\u767b\u5f55\uff0c\u4e00\u79cd\u662f\u4f7f\u7528\u00a0<code>source ~\/.bash_profile<\/code>\u00a0\u547d\u4ee4\u3002<\/p><\/blockquote>\n<p><strong>Windows<\/strong><\/p>\n<p>\u5728\u7cfb\u7edf\u7684\u4efb\u610f\u4f4d\u7f6e\u521b\u5efa\u4e00\u4e2a\u6279\u5904\u7406\u6587\u4ef6\u00a0<code>homestead.bat<\/code>\uff1a<\/p>\n<pre><code>@echo off\r\n\r\nset cwd=%cd%\r\nset homesteadVagrant=C:\\Homestead\r\n\r\ncd \/d %homesteadVagrant% &amp;&amp; vagrant %*\r\ncd \/d %cwd%\r\n\r\nset cwd=\r\nset homesteadVagrant=\r\n<\/code><\/pre>\n<p>\u4f60\u9700\u8981\u5c06\u811a\u672c\u4e2d\u5b9e\u4f8b\u8def\u5f84\u00a0<code>C:\\Homestead<\/code>\u00a0\u8c03\u6574\u4e3a Homestead \u5b9e\u9645\u5b89\u88c5\u8def\u5f84\u3002\u521b\u5efa\u6587\u4ef6\u4e4b\u540e\uff0c\u6dfb\u52a0\u6587\u4ef6\u8def\u5f84\u5230\u00a0<code>PATH<\/code>\uff0c\u8fd9\u6837\u4f60\u5c31\u53ef\u4ee5\u5728\u7cfb\u7edf\u7684\u4efb\u610f\u4f4d\u7f6e\u8fd0\u884c\u00a0<code>homestead up<\/code>\u00a0\u6216\u00a0<code>homestead ssh<\/code>\u00a0\u547d\u4ee4\u4e86\u3002<\/p>\n<h4 id=\"toc_9\">\u901a\u8fc7 SSH \u8fde\u63a5<\/h4>\n<p>\u4f60\u53ef\u4ee5\u5728\u00a0<code>Homestead<\/code>\u00a0\u76ee\u5f55\u4e0b\u901a\u8fc7\u8fd0\u884c\u00a0<code>vagrant ssh<\/code>\u00a0\u4ee5 SSH \u65b9\u5f0f\u8fde\u63a5\u5230\u865a\u62df\u673a\u3002\u5982\u679c\u4f60\u8bbe\u7f6e\u4e86\u5168\u90e8\u8bbf\u95ee Homestead\uff0c\u4e5f\u53ef\u4ee5\u5728\u4efb\u610f\u8def\u5f84\u4e0b\u901a\u8fc7\u00a0<code>homestead ssh<\/code>\u00a0\u767b\u5f55\u5230\u865a\u62df\u673a\u3002<\/p>\n<p>\u5982\u679c\u4f60\u9700\u8981\u4ee5\u66f4\u7b80\u6377\u7684\u65b9\u5f0f\u8fde\u63a5\u5230 Homestead\uff0c\u53ef\u4ee5\u4e3a\u4e3b\u673a\u6dfb\u52a0\u4e00\u4e2a\u522b\u540d\u6765\u5feb\u901f\u8fde\u63a5\u5230 Homestead \u76d2\u5b50\uff0c\u521b\u5efa\u5b8c\u522b\u540d\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u00a0<code>vm<\/code>\u00a0\u547d\u4ee4\u4ece\u4efb\u4f55\u5730\u65b9\u4ee5 SSH \u65b9\u5f0f\u8fde\u63a5\u5230 Homestead \u865a\u62df\u673a\uff1a<\/p>\n<pre><code>alias vm=\"ssh vagrant@127.0.0.1 -p 2222\"\r\n<\/code><\/pre>\n<h4 id=\"toc_10\">\u8fde\u63a5\u5230\u6570\u636e\u5e93<\/h4>\n<p>Homestead \u9ed8\u8ba4\u5df2\u7ecf\u5728\u865a\u62df\u673a\u4e2d\u4e3a MySQL \u548c Postgres \u6570\u636e\u5e93\u505a\u597d\u4e86\u914d\u7f6e\uff0c\u66f4\u65b9\u4fbf\u7684\u662f\uff0c\u8fd9\u4e9b\u914d\u7f6e\u503c\u4e0e Laravel \u7684\u00a0<code>.env<\/code>\u00a0\u4e2d\u9ed8\u8ba4\u63d0\u4f9b\u7684\u914d\u7f6e\u4e00\u81f4\u3002<\/p>\n<p>\u60f3\u8981\u901a\u8fc7\u672c\u5730\u7684 Navicat \u6216 Sequel Pro \u8fde\u63a5\u5230 Homestead \u4e0a\u7684 MySQL \u6216 Postgres \u6570\u636e\u5e93\uff0c\u53ef\u4ee5\u901a\u8fc7\u65b0\u5efa\u8fde\u63a5\u6765\u5b9e\u73b0\uff0c\u4e3b\u673a IP \u90fd\u662f 127.0.0.1\uff0c\u5bf9\u4e8e MySQL \u800c\u8a00\uff0c\u7aef\u53e3\u53f7\u662f\u00a0<code>33060<\/code>\uff0c\u5bf9 Postgres \u800c\u8a00\uff0c\u7aef\u53e3\u53f7\u662f\u00a0<code>54320<\/code>\uff0c\u7528\u6237\u540d\/\u5bc6\u7801\u662f\u00a0<code>homestead\/secret<\/code>\uff1a<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/static.laravelacademy.org\/wp-content\/uploads\/2017\/09\/15049626732930.jpg\" alt=\"\" \/>\ufffc<\/p>\n<blockquote><p>\u6ce8\uff1a\u53ea\u6709\u4ece\u672c\u5730\u8fde\u63a5 Homestead \u7684\u6570\u636e\u5e93\u65f6\u624d\u80fd\u4f7f\u7528\u8fd9\u4e9b\u975e\u6807\u51c6\u7684\u7aef\u53e3\uff0c\u5728 Homestead \u865a\u62df\u673a\u4e2d\u8fd8\u662f\u5e94\u8be5\u4f7f\u7528\u9ed8\u8ba4\u7684\u00a0<code>3306<\/code>\u00a0\u548c\u00a0<code>5432<\/code>\u00a0\u7aef\u53e3\u8fdb\u884c\u6570\u636e\u5e93\u8fde\u63a5\u914d\u7f6e\u3002<\/p><\/blockquote>\n<h4 id=\"toc_11\">\u6dfb\u52a0\u66f4\u591a\u7ad9\u70b9<\/h4>\n<p>Homestead \u865a\u62df\u673a\u5728\u8fd0\u884c\u65f6\uff0c\u53ef\u80fd\u9700\u8981\u6dfb\u52a0\u591a\u4e2a Laravel \u5e94\u7528\u5230 Nginx \u7ad9\u70b9\u3002\u5982\u679c\u662f\u5728\u5355\u4e2a Homestead \u73af\u5883\u4e2d\u8fd0\u884c\u591a\u4e2a Laravel \u5e94\u7528\uff0c\u6dfb\u52a0\u7ad9\u70b9\u5f88\u7b80\u5355\uff0c\u53ea\u9700\u5c06\u7ad9\u70b9\u6dfb\u52a0\u5230\u00a0<code>Homestead.yaml<\/code>\u00a0\u6587\u4ef6\uff0c\u7136\u540e\u5728\u00a0<code>Homestead<\/code>\u00a0\u76ee\u5f55\u4e2d\u8fd0\u884c\u00a0<code>vagrant provision<\/code>\u00a0\u547d\u4ee4\u5373\u53ef\uff1a<\/p>\n<pre><code>sites:\r\n    - map: homestead.app\r\n      to: \/home\/vagrant\/Code\/Laravel\/public\r\n    - map: another.app\r\n      to: \/home\/vagrant\/Code\/another\/public\r\n<\/code><\/pre>\n<p>\u5982\u679c Vagrant \u4e0d\u662f\u81ea\u52a8\u7ba1\u7406\u201chosts\u201d\u6587\u4ef6\uff0c\u4ecd\u7136\u9700\u8981\u6dfb\u52a0\u7ad9\u70b9\u57df\u540d\u5230\u672c\u5730\u00a0<code>hosts<\/code>\u00a0\u6587\u4ef6\uff1a<\/p>\n<pre><code>192.168.10.10  homestead.app\r\n192.168.10.10  another.app\r\n<\/code><\/pre>\n<p>\u6dfb\u52a0\u5b8c\u7ad9\u70b9\u540e\uff0c\u5728\u00a0<code>Homestead<\/code>\u00a0\u76ee\u5f55\u4e0b\u8fd0\u884c\u00a0<code>vagrant reload --provision<\/code>\u00a0\u547d\u4ee4\u91cd\u542f\u865a\u62df\u673a\u3002<\/p>\n<p><strong>\u7ad9\u70b9\u7c7b\u578b<\/strong><\/p>\n<p>Homestead \u652f\u6301\u591a\u79cd\u6846\u67b6\uff0c\u6240\u4ee5\u5373\u4f7f\u4f60\u6ca1\u6709\u4f7f\u7528 Laravel \u7684\u8bdd\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528 Homestead\uff0c\u4f8b\u5982\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u00a0<code>symfony2<\/code>\u00a0\u7ad9\u70b9\u7c7b\u578b\u8f7b\u677e\u6dfb\u52a0\u4e00\u4e2a Symfony \u5e94\u7528\uff1a<\/p>\n<pre><code>sites:\r\n    - map: symfony2.app\r\n      to: \/home\/vagrant\/Code\/Symfony\/web\r\n      type: symfony2\r\n<\/code><\/pre>\n<p>\u76ee\u524d\u652f\u6301\u7684\u7ad9\u70b9\u7c7b\u578b\u5305\u62ec\u00a0<code>apache<\/code>\u3001<code>laravel<\/code>\u3001<code>proxy<\/code>\u3001<code>silverstripe<\/code>\u3001<code>statamic<\/code>\u3001<code>symfony2<\/code>\u00a0\u548c\u00a0<code>symfony4<\/code>\u3002<\/p>\n<p><strong>\u7ad9\u70b9\u53c2\u6570<\/strong><\/p>\n<p>\u4f60\u4e5f\u53ef\u4ee5\u901a\u8fc7\u7ad9\u70b9\u6307\u4ee4\u00a0<code>params<\/code>\u00a0\u6dfb\u52a0\u989d\u5916\u7684 Nginx\u00a0<code>fastcgi_param<\/code>\u00a0\u503c\u3002\u4f8b\u5982\u6211\u4eec\u53ef\u4ee5\u6dfb\u52a0\u4e00\u4e2a\u00a0<code>FOO<\/code>\u00a0\u53c2\u6570\uff0c\u5bf9\u5e94\u53c2\u6570\u503c\u662f\u00a0<code>BAR<\/code>\uff1a<\/p>\n<pre><code>sites:\r\n    - map: homestead.app\r\n      to: \/home\/vagrant\/Code\/Laravel\/public\r\n      params:\r\n          - key: FOO\r\n            value: BAR\r\n<\/code><\/pre>\n<h4 id=\"toc_12\">\u914d\u7f6e\u00a0<a title=\"View all posts in Cron\" href=\"http:\/\/laravelacademy.org\/tags\/cron\" target=\"_blank\" rel=\"noopener noreferrer\">Cron<\/a>\u00a0\u8c03\u5ea6\u4efb\u52a1<\/h4>\n<p>Laravel \u63d0\u4f9b\u4e86\u5f88\u65b9\u4fbf\u7684\u65b9\u5f0f\u6765<a href=\"https:\/\/laravel.com\/docs\/5.5\/scheduling\" target=\"_blank\" rel=\"noopener noreferrer\">\u8c03\u5ea6 Cron \u4efb\u52a1<\/a>\uff1a\u53ea\u9700\u6bcf\u5206\u949f\u8c03\u5ea6\u8fd0\u884c\u4e00\u6b21 Artisan \u547d\u4ee4\u00a0<code>schedule:run<\/code>\u00a0\u5373\u53ef\u3002<code>schedule:run<\/code>\u00a0\u4f1a\u68c0\u67e5\u5b9a\u4e49\u5728\u00a0<code>App\\Console\\Kernel<\/code>\u00a0\u7c7b\u4e2d\u5b9a\u4e49\u7684\u8c03\u5ea6\u4efb\u52a1\u5e76\u5224\u65ad\u8fd0\u884c\u54ea\u4e9b\u4efb\u52a1\u3002<\/p>\n<p>\u5982\u679c\u60f3\u8981\u4e3a\u67d0\u4e2a Homestead \u7ad9\u70b9\u8fd0\u884c\u00a0<code>schedule:run<\/code>\u00a0\u547d\u4ee4\uff0c\u9700\u8981\u5728\u5b9a\u4e49\u7ad9\u70b9\u65f6\u8bbe\u7f6e\u00a0<code>schedule<\/code>\u00a0\u4e3a\u00a0<code>true<\/code>\uff1a<\/p>\n<pre><code>sites:\r\n    - map: homestead.app\r\n      to: \/home\/vagrant\/Code\/Laravel\/public\r\n      schedule: true\r\n<\/code><\/pre>\n<p>\u8be5\u7ad9\u70b9\u7684 Cron \u4efb\u52a1\u4f1a\u88ab\u5b9a\u4e49\u5728\u865a\u62df\u673a\u7684\u00a0<code>\/etc\/cron.d<\/code>\u00a0\u76ee\u5f55\u4e0b\uff1a<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/static.laravelacademy.org\/wp-content\/uploads\/2017\/09\/15049628745263.jpg\" alt=\"\" \/>\ufffc<\/p>\n<h4 id=\"toc_13\">\u7aef\u53e3\u8f6c\u53d1\u914d\u7f6e<\/h4>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cHomestead \u7aef\u53e3\u8f6c\u53d1\u914d\u7f6e\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li>SSH: 2222 \u2192 Forwards To 22<\/li>\n<li>HTTP: 8000 \u2192 Forwards To 80<\/li>\n<li>HTTPS: 44300 \u2192 Forwards To 443<\/li>\n<li>MySQL: 33060 \u2192 Forwards To 3306<\/li>\n<li>Postgres: 54320 \u2192 Forwards To 5432<\/li>\n<\/ul>\n<p><strong>\u8f6c\u53d1\u66f4\u591a\u7aef\u53e3<\/strong><\/p>\n<p>\u5982\u679c\u4f60\u60f3\u8981\u4e3a Vagrant \u76d2\u5b50\u6dfb\u52a0\u66f4\u591a\u7aef\u53e3\u8f6c\u53d1\uff0c\u505a\u5982\u4e0b\u8f6c\u53d1\u534f\u8bae\u8bbe\u7f6e\u5373\u53ef\uff1a<\/p>\n<pre><code>ports:\r\n    - send: 93000\r\n      to: 9300\r\n    - send: 7777\r\n      to: 777\r\n      protocol: udp\r\n<\/code><\/pre>\n<h4 id=\"toc_14\"><a title=\"View all posts in \u5206\u4eab\" href=\"http:\/\/laravelacademy.org\/tags\/%e5%88%86%e4%ba%ab\" target=\"_blank\" rel=\"noopener noreferrer\">\u5206\u4eab<\/a>\u4f60\u7684\u73af\u5883<\/h4>\n<p>\u6709\u65f6\u5019\u4f60\u53ef\u80fd\u5e0c\u671b\u548c\u540c\u4e8b\u6216\u5ba2\u6237\u5206\u4eab\u81ea\u5df1\u5f53\u524d\u7684\u5de5\u4f5c\u8fdb\u5ea6\u6216\u6210\u679c\uff0cVagrant \u672c\u8eab\u652f\u6301\u901a\u8fc7\u00a0<code>vagrant share<\/code>\u00a0\u6765\u652f\u6301\u8fd9\u4e2a\u529f\u80fd\uff1b\u4e0d\u8fc7\uff0c\u5982\u679c\u4f60\u5728\u00a0<code>Homestead.yaml<\/code>\u00a0\u6587\u4ef6\u4e2d\u914d\u7f6e\u4e86\u591a\u4e2a\u7ad9\u70b9\u7684\u8bdd\u5c31\u4e0d\u884c\u4e86\u3002<\/p>\n<p>\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0cHomestead \u5185\u7f6e\u4e86\u81ea\u5df1\u7684\u00a0<code>share<\/code>\u00a0\u547d\u4ee4\uff0c\u8be5\u529f\u80fd\u5b9e\u73b0\u7684\u539f\u7406\u662f\u901a\u8fc7\u00a0<a href=\"https:\/\/ngrok.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Ngrok<\/a>\u5c06\u672c\u5730\u670d\u52a1\u5206\u4eab\u5230\u4e92\u8054\u7f51\u4e0a\u8fdb\u884c\u516c\u5f00\u8bbf\u95ee\uff0c\u5173\u4e8e\u8be5\u8f6f\u4ef6\u7684\u7ec6\u8282\u6211\u4eec\u8fd9\u91cc\u4e0d\u8ba8\u8bba\uff0c\u5927\u5bb6\u53ef\u4ee5\u81ea\u884c\u767e\u5ea6\uff0c\u6211\u4eec\u4e3b\u8981\u5173\u6ce8\u5728 Homestead \u4e2d\u5982\u4f55\u4f7f\u7528\u8fd9\u4e00\u529f\u80fd\u3002\u9996\u5148\u901a\u8fc7\u00a0<code>vagrant ssh<\/code>\u00a0\u767b\u5f55\u5230 Homestead \u865a\u62df\u673a\u7136\u540e\u8fd0\u884c\u00a0<code>share homestead.app<\/code>\u00a0\u547d\u4ee4\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u5206\u4eab\u00a0<code>homestead.app<\/code>\u00a0\u7ad9\u70b9\u4e86\uff0c\u5176\u4ed6\u7ad9\u70b9\u5206\u4eab\u4ee5\u6b64\u7c7b\u63a8\uff1a<\/p>\n<pre><code>share homestead.app\r\n<\/code><\/pre>\n<p>\u8fd0\u884c\u5b8c\u8be5\u547d\u4ee4\u4e4b\u540e\uff0c\u4f60\u5c31\u53ef\u4ee5\u770b\u5230\u4e00\u4e2a\u00a0<a title=\"View all posts in Ngrok\" href=\"http:\/\/laravelacademy.org\/tags\/ngrok\" target=\"_blank\" rel=\"noopener noreferrer\">Ngrok<\/a>\u00a0\u754c\u9762\u51fa\u73b0\uff0c\u5176\u4e2d\u5305\u542b\u6d3b\u52a8\u65e5\u5fd7\u548c\u5206\u4eab\u7ad9\u70b9\u6240\u9700\u7684\u516c\u5f00\u8bbf\u95ee URL\uff1a<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/static.laravelacademy.org\/wp-content\/uploads\/2017\/09\/15049630094161.jpg\" alt=\"\" \/>\ufffc<\/p>\n<p>\u53ef\u4ee5\u770b\u5230\u6211\u7684\u5206\u4eab URL \u662f\u00a0<code>http:\/\/95920d84.ngrok.io\/<\/code>\u00a0\u4ee5\u53ca\u00a0<code>https:\/\/95920d84.ngrok.io\/<\/code>\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u8fd9\u4e24\u4e2a\u57df\u540d\u5728\u4efb\u610f\u8054\u7f51\u673a\u5668\u4e0a\u8bbf\u95ee\u6211\u7684 Homestead \u7ad9\u70b9\uff1a<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/static.laravelacademy.org\/wp-content\/uploads\/2017\/09\/15049633379189.jpg\" alt=\"\" \/>\ufffc<\/p>\n<p>\u5982\u679c\u4f60\u60f3\u8981\u6307\u5b9a\u4e00\u4e2a\u81ea\u5b9a\u4e49\u7684\u533a\u57df\uff0c\u5b50\u57df\u540d\u6216\u8005\u5176\u4ed6 Ngrok \u8fd0\u884c\u65f6\u9009\u9879\uff0c\u53ef\u4ee5\u5c06\u5b83\u4eec\u6dfb\u52a0\u5230\u00a0<code>share<\/code>\u00a0\u547d\u4ee4\uff1a<\/p>\n<pre><code>share homestead.app -region=us -subdomain=laravel\r\n<\/code><\/pre>\n<p>\u76ee\u524d\u81ea\u5b9a\u4e49\u57df\u540d\u53ea\u6709\u4ed8\u8d39\u7528\u6237\u624d\u53ef\u4ee5\u4f7f\u7528\uff0c\u6240\u4ee5\u00a0<code>subdomain<\/code>\u00a0\u4f1a\u63d0\u793a\u4e0d\u53ef\u7528\u3002<\/p>\n<blockquote><p>\u6ce8\uff1a\u8bb0\u4f4f\u4e24\u4e2a\u70b9\uff0c\u4e00\u4e2a\u662f Vagrant \u5e76\u6ca1\u6709\u4ec0\u4e48\u7279\u522b\u7684\u5b89\u5168\u9632\u8303\u63aa\u65bd\uff0c\u53e6\u4e00\u4e2a\u662f\u5f53\u4f60\u8fd0\u884c share \u547d\u4ee4\u7684\u65f6\u5019\uff0c\u4f60\u5176\u5b9e\u662f\u5728\u5c06\u81ea\u5df1\u7684\u865a\u62df\u673a\u66dd\u5149\u5230\u4e92\u8054\u7f51\u4e0a\u3002\u6240\u4ee5\uff0c\u5f53\u4f60\u8981\u5206\u4eab\u81ea\u5df1\u7684\u7ad9\u70b9\u4e4b\u524d\uff0c\u5148\u60f3\u60f3\u5b89\u5168\u9690\u60a3\uff0c\u5e76\u5c06\u5176\u89c4\u907f\u6389\u3002<\/p><\/blockquote>\n<h4 id=\"toc_15\">\u591a\u4e2a PHP \u7248\u672c<\/h4>\n<blockquote><p>\u6ce8\uff1a\u8be5\u529f\u80fd\u53ea\u5728 Nginx \u4e0b\u6709\u6548\u3002<\/p><\/blockquote>\n<p>Homestead 6 \u5f15\u5165\u4e86\u5728\u5355\u4e2a\u865a\u62df\u673a\u4e2d\u652f\u6301\u591a\u4e2a PHP \u7248\u672c\u7684\u529f\u80fd\uff0c\u4f60\u53ef\u4ee5\u5728\u00a0<code>Homestead.yaml<\/code>\u00a0\u6587\u4ef6\u4e2d\u4e3a\u7279\u5b9a\u7ad9\u70b9\u6307\u5b9a PHP \u7248\u672c\uff0c\u76ee\u524d\u652f\u6301\u7684 PHP \u7248\u672c\u5305\u62ec\u00a0<code>5.6<\/code>\u3001<code>7.0<\/code>\u00a0\u548c\u00a0<code>7.1<\/code>\uff1a<\/p>\n<pre><code>sites:\r\n    - map: homestead.app\r\n      to: \/home\/vagrant\/Code\/Laravel\/public\r\n      php: \"5.6\"\r\n<\/code><\/pre>\n<p>\u8be5\u529f\u80fd\u5b9e\u73b0\u7684\u539f\u7406\u662f\u901a\u8fc7\u00a0<code>Homestead.yaml<\/code>\u00a0\u4e2d\u914d\u7f6e\u7684 PHP \u7248\u672c\u5728 Homestead \u4e2d\u542f\u52a8\u76f8\u5e94\u7684\u00a0<code>php-fpm<\/code>\u00a0\u670d\u52a1\uff0c\u7136\u540e\u66f4\u65b0 Nginx \u4e2d\u76f8\u5e94\u7684\u7ad9\u70b9\u914d\u7f6e\uff1a<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/static.laravelacademy.org\/wp-content\/uploads\/2017\/09\/15049641493523.jpg\" alt=\"\" \/>\ufffc<\/p>\n<p>\u6b64\u5916\uff0c\u4f60\u53ef\u4ee5\u5728 CLI \u4e2d\u4f7f\u7528\u4efb\u610f\u7248\u672c\u7684 PHP\uff1a<\/p>\n<pre><code>php5.6 artisan list\r\nphp7.0 artisan list\r\nphp7.1 artisan list\r\n<\/code><\/pre>\n<h3 id=\"toc_16\">\u7f51\u7edc\u63a5\u53e3<\/h3>\n<p><code>Homestead.yaml<\/code>\u00a0\u7684\u00a0<code>networks<\/code>\u00a0\u5c5e\u6027\u7528\u4e8e\u914d\u7f6e Homestead \u7684\u7f51\u7edc\u63a5\u53e3\uff0c\u4f60\u53ef\u4ee5\u60f3\u914d\u591a\u5c11\u5c31\u914d\u591a\u5c11\uff1a<\/p>\n<pre><code>networks:\r\n    - type: \"private_network\"\r\n      ip: \"192.168.10.20\"\r\n<\/code><\/pre>\n<p>\u8981\u5f00\u542f\u00a0<a href=\"https:\/\/www.vagrantup.com\/docs\/networking\/public_network.html\" target=\"_blank\" rel=\"noopener noreferrer\"><code>bridged<\/code><\/a>\u00a0\uff08\u6865\u63a5\u6a21\u5f0f\uff09\u63a5\u53e3\uff0c\u9700\u8981\u914d\u7f6e\u00a0<code>bridge<\/code>\u00a0\u8bbe\u7f6e\u5e76\u4fee\u6539\u7f51\u7edc\u7c7b\u578b\u4e3a\u00a0<code>public_network<\/code>\u00a0\uff1a<\/p>\n<pre><code>networks:\r\n    - type: \"public_network\"\r\n      ip: \"192.168.10.20\"\r\n      bridge: \"en1: Wi-Fi (AirPort)\"\r\n<\/code><\/pre>\n<p>\u8981\u5f00\u542f<a href=\"https:\/\/www.vagrantup.com\/docs\/networking\/public_network.html\" target=\"_blank\" rel=\"noopener noreferrer\">DHCP<\/a>\uff08\u52a8\u6001\u4e3b\u673a\u914d\u7f6e\u534f\u8bae\uff09\uff0c\u53ea\u9700\u8981\u4ece\u914d\u7f6e\u4e2d\u79fb\u9664\u00a0<code>ip<\/code>\u00a0\u9009\u9879\u5373\u53ef\uff1a<\/p>\n<pre><code>networks:\r\n    - type: \"public_network\"\r\n      bridge: \"en1: Wi-Fi (AirPort)\"\r\n<\/code><\/pre>\n<h3 id=\"toc_17\">\u66f4\u65b0 Homestead<\/h3>\n<p>\u66f4\u65b0 Homestead \u53ea\u9700\u4e24\u6b65\u5373\u53ef\uff0c\u9996\u5148\uff0c\u4f7f\u7528\u00a0<code>vagrant box update<\/code>\u00a0\u547d\u4ee4\u66f4\u65b0 Vagrant \u76d2\u5b50\uff1a<\/p>\n<pre><code>vagrant box update\r\n<\/code><\/pre>\n<p>\u63a5\u4e0b\u6765\uff0c\u9700\u8981\u66f4\u65b0 Homestead \u6e90\u7801\uff0c\u5982\u679c\u4f60\u662f\u901a\u8fc7 Github \u4ed3\u5e93\u5b89\u88c5\u7684\uff0c\u53ea\u9700\u5728\u514b\u9686\u4ed3\u5e93\u7684\u5730\u65b9\u8fd0\u884c\u00a0<code>git pull origin master<\/code>\u00a0\u5373\u53ef\u3002<\/p>\n<p>\u5982\u679c\u4f60\u662f\u901a\u8fc7\u9879\u76ee\u7684\u00a0<code>composer.json<\/code>\u00a0\u6587\u4ef6\u5b89\u88c5\u7684 Homestead\uff0c\u9700\u8981\u786e\u4fdd\u00a0<code>composer.json<\/code>\u00a0\u6587\u4ef6\u5305\u542b\u00a0<code>\"laravel\/homestead\": \"^6\"<\/code>\u00a0\u5e76\u66f4\u65b0\u4f60\u7684\u4f9d\u8d56\uff1a<\/p>\n<pre><code>composer update\r\n<\/code><\/pre>\n<h3 id=\"toc_18\">\u8001\u7248\u672c<\/h3>\n<blockquote><p>\u6ce8\uff1a\u5982\u679c\u4f60\u53ea\u662f\u9700\u8981\u4f7f\u7528\u8001\u7248\u672c\u7684 PHP\uff0c\u5728\u8003\u8651\u4f7f\u7528\u8001\u7248\u672c\u7684 Homestead \u4e4b\u524d\u67e5\u770b\u4e0b<a href=\"http:\/\/laravelacademy.org\/post\/7658.html#toc_15\">\u591a\u7248\u672cPHP<\/a>\u8fd9\u90e8\u5206<a title=\"View all posts in \u6587\u6863\" href=\"http:\/\/laravelacademy.org\/tags\/%e6%96%87%e6%a1%a3\" target=\"_blank\" rel=\"noopener noreferrer\">\u6587\u6863<\/a>\uff0c\u5982\u679c\u65b0\u7248\u672c\u652f\u6301\u4f60\u6240\u9700\u8981\u7684 PHP \u7248\u672c\uff0c\u90a3\u5c31\u4f7f\u7528\u65b0\u7248\u672c\u7684 Homestead \u5427\u3002<\/p><\/blockquote>\n<p>\u4f60\u53ef\u4ee5\u901a\u8fc7\u6dfb\u52a0\u5982\u4e0b\u8fd9\u884c\u914d\u7f6e\u5230\u00a0<code>Homestead.yaml<\/code>\u00a0\u6587\u4ef6\u6765\u8986\u76d6 Homestead \u4f7f\u7528\u7684\u8001\u7248\u672c\u7684\u76d2\u5b50\uff1a<\/p>\n<pre><code>version: 0.6.0\r\n<\/code><\/pre>\n<p>\u4f8b\u5982\uff1a<\/p>\n<pre><code>box: laravel\/homestead\r\nversion: 0.6.0\r\nip: \"192.168.20.20\"\r\nmemory: 2048\r\ncpus: 4\r\nprovider: virtualbox\r\n<\/code><\/pre>\n<p>\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662f\u66f4\u8001\u7248\u672c\u7684 Homestead \u76d2\u5b50\uff0c\u9700\u8981\u4e3a\u4e4b\u5339\u914d\u4e00\u4e2a\u4e0e\u4e4b\u517c\u5bb9\u7684 Homestead \u6e90\u7801\u3002\u4e0b\u9762\u7684\u8868\u683c\u5217\u51fa\u4e86\u652f\u6301\u7684\u76d2\u5b50\u7248\u672c\uff0c\u4f7f\u7528\u7684 Homestead \u6e90\u7801\u7684\u7248\u672c\uff0c\u4ee5\u53ca\u5bf9\u5e94\u7684 PHP \u7248\u672c\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>PHP<\/th>\n<th>Homestead Version<\/th>\n<th>Box Version<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>7.0<\/td>\n<td>3.1.0<\/td>\n<td>0.6.0<\/td>\n<\/tr>\n<tr>\n<td>7.1<\/td>\n<td>4.0.0<\/td>\n<td>1.0.0<\/td>\n<\/tr>\n<tr>\n<td>7.1<\/td>\n<td>5.0.0<\/td>\n<td>2.6.0<\/td>\n<\/tr>\n<tr>\n<td>7.1<\/td>\n<td>6.0.0<\/td>\n<td>3.0.0<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 id=\"toc_19\">\u865a\u62df\u673a\u6307\u5b9a\u8bbe\u7f6e<\/h3>\n<h4 id=\"toc_20\">VirtualBox<\/h4>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cHomestead \u914d\u7f6e\u9879\u00a0<code>natdnshostresolver<\/code>\u00a0\u88ab\u8bbe\u7f6e\u4e3a\u00a0<code>on<\/code>\uff0c\u4ece\u800c\u5141\u8bb8 Homestead \u4f7f\u7528\u4e3b\u673a\u64cd\u4f5c\u7cfb\u7edf\u7684 DNS \u914d\u7f6e\uff0c\u5982\u679c\u4f60\u60f3\u8981\u8986\u76d6\u8fd9\u4e2a\u884c\u4e3a\uff0c\u6dfb\u52a0\u5982\u4e0b\u884c\u5230\u00a0<code>Homestead.yaml<\/code>\u00a0\u6587\u4ef6\uff1a<\/p>\n<pre><code>provider: virtualbox\r\nnatdnshostresolver: off<\/code><\/pre>\n<p>\u5177\u4f53\u7684\u53ef\u53bb\u5b98\u7f51\u8fdb\u884c\u67e5\u770b\uff1a<span style=\"color: #3366ff;\"><a href=\"https:\/\/laravel.com\/docs\/5.5\/homestead\">https:\/\/laravel.com\/docs\/5.5\/homestead<\/a><\/span><\/p>\n<p><span style=\"color: #ff0000;\">\u51fa\u9519\u95ee\u9898\u89e3\u51b3\uff1a<\/span><\/p>\n<p>1.vagrang box list \u5df2\u7ecf\u5b58\u5728\u00a0laravel\/homestead \u4f46\u662f\u5728Homestead\u76ee\u5f55\u4e0bvagrang up\u65f6\u4f9d\u65e7\u4f1a\u91cd\u65b0\u4e0b\u8f7dbox\u6587\u4ef6<\/p>\n<p>\u539f\u56e0\uff1avagrant up \u65f6\u4f1a\u68c0\u6d4bbox_version \u4fe1\u606f\uff0c\u5177\u4f53\u7684\u7248\u672c\u53f7\u5728Homestead\\scripts\\homestead.rb\u4e2d<\/p>\n<blockquote><p>config.vm.box_version = settings[\"version\"] ||= \"<span style=\"color: #ff0000;\">&gt;= 3.0.0<\/span>\"<\/p><\/blockquote>\n<p>\u5176\u4e2d\u8fd9\u4e2a 3.0.0\u5c31\u662f\u8981\u68c0\u6d4b\u7684\u7248\u672c\u53f7\uff0c\u800c\u6211\u4eec\u4f7f\u7528vagrant box list \u65f6\u5728laravel\/homestead\u540e\u9762\u4f1a\u6709\u7248\u672c\u4fe1\u606f\u5982\uff08virtualbox , 0),\u8fd9\u65f6\uff0c0\u5c0f\u4e8e\u7248\u672c\u53f73.0.0\u6545\u4f1a\u91cd\u65b0\u4e0b\u8f7d \u3002<br \/>\n\u89e3\u51b3\u529e\u6cd5\uff1a\u5728Homestead\u6587\u4ef6\u5939\u4e0b\u6dfb\u52a0\u4e00\u4e2ametadata.json\u6587\u4ef6\uff0c\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<blockquote><p>{<br \/>\n\"name\": \"laravel\/homestead\",<br \/>\n\"versions\": [{<br \/>\n\"version\": \"3.0.0\",<br \/>\n\"providers\": [{<br \/>\n\"name\": \"virtualbox\",<br \/>\n\"url\": \"file:\/\/\/e:\/laravel-homesterad.box\"<br \/>\n}]<br \/>\n}]<br \/>\n}<\/p><\/blockquote>\n<p>\u5176\u4e2dfile:\/\/\/e:\/laravel-homesterad.box\u4e3abox\u955c\u50cf\u6587\u4ef6\u76ee\u5f55\uff0cversion \u4e3a\u68c0\u6d4b\u51fa\u6765\u7684\u5177\u4f53\u53f7\uff0c\u7136\u540e\u6267\u884c\u547d\u4ee4\uff1a<\/p>\n<blockquote><p>vagrant box add\u00a0metadata.json<\/p><\/blockquote>\n<p>\u518d\u67e5\u770bbox\u5217\u8868\uff0c<\/p>\n<blockquote><p>vagrant box list<\/p><\/blockquote>\n<p>\u5982\u679c\u51fa\u73b0<\/p>\n<blockquote><p>laravel\/homestead (<span style=\"color: #ff0000;\">virtualbox, 3.0.0<\/span>)\uff0c<\/p><\/blockquote>\n<p>\u7ea2\u8272\u90e8\u5206\u6570\u5b57\u7248\u672c\u53f7\u4e0e\u68c0\u6d4b\u7248\u672c\u53f7\u4e00\u81f4\uff0c\u5219\u8bf4\u660e\u6210\u529f \uff0c<\/p>\n<blockquote><p>vagrant up<\/p><\/blockquote>\n<p>\u95ee\u9898\u89e3\u51b3\u3002<\/p>\n<p>2.\u8bbf\u95eehttp:\/\/homestead.app\/ \u62a5\u9519 require(\/vendor\/autoload.php): failed to open stream: No such file or dire<\/p>\n<p>\u539f\u56e0\uff1a\u63d0\u793a\u5f88\u660e\u663e\uff0c\u56e0\u4e3a\u6ca1\u6709autoload.php\u6587\u4ef6\uff0c\u5982\u679c\u4f60\u662f\u4f7f\u7528git clone\u76f4\u63a5\u4e0b\u8f7dlaravel\u9879\u76ee\uff0c\u9879\u76ee\u672c\u8eab\u5e76\u6ca1\u6709\u5c06vendor\u76f8\u5173\u7684\u4f9d\u8d56\u5305\u8fdb\u884c\u4e0b\u8f7d<\/p>\n<p>\u89e3\u51b3\u529e\u6cd5\uff1a\u4f7f\u7528<span style=\"color: #ff0000;\">composer update<\/span>\u5728\u9879\u76ee\u76ee\u5f55 \u8fdb\u884c\u66f4\u65b0\uff0c\u7136\u540e\u95ee\u9898\u89e3\u51b3\u3002<\/p>\n<p>3.\u8bbf\u95eehttp:\/\/homestead.app\/\u663e\u793aWhoops, looks like something went wrong<\/p>\n<p>\u89e3\u51b3\u529e\u6cd5\uff1a<br \/>\n\u9996\u5148\u6253\u5f00debug\u6a21\u5f0f\u540e\u663e\u793a\u9519\u8bef\u3002<br \/>\n\u6253\u5f00\u4f60larave\u9879\u76ee\u7684<span style=\"color: #ff0000;\">app\/config\/app.php<\/span>\u6587\u4ef6\uff0c\u5c06\u5176<span style=\"color: #ff0000;\">debug<\/span>\u9009\u9879\u8bbe\u7f6e\u4e3a<span style=\"color: #ff0000;\">true<\/span>\u3002\u518d\u6b21\u8fd0\u884c\u9875\u9762\uff0c\u4f60\u4f1a\u53d1\u73b0\u7a0b\u5e8f\u6253\u5370\u4e86\u5f02\u5e38\u3002<\/p>\n<p>4.\u8bbf\u95eehttp:\/\/homestead.app\/ \u00a0\u62a5\u9519\u00a0lavarel No application encryption key has been specified.<\/p>\n<p>\u539f\u56e0\uff1a\u662f\u56e0\u4e3a\u6ca1\u6709\u751f\u6210app key \u9020\u6210<\/p>\n<p>\u89e3\u51b3\u529e\u6cd5\uff1a\u8fdb\u5165\u9879\u76ee\u76ee\u5f55\u67e5\u770b\u76ee\u5f55\u4e0b\u662f\u5426\u5b58\u5728.env \u6587\u4ef6 \uff0c\u5982\u679c\u6ca1\u6709\u4e14\u6709.env.example \u6587\u4ef6\u7684\u8bdd\u5c06\u00a0.env.example \u91cd\u65b0\u547d\u540d\u4e3a .env,\u7136\u540e\u6267\u884c<\/p>\n<blockquote>\n<pre class=\"lang-php prettyprint prettyprinted\"><code><span class=\"pln\">php artisan key<\/span><span class=\"pun\">:<\/span><span class=\"pln\">generate<\/span><\/code><\/pre>\n<\/blockquote>\n<p>\u5219\u4f1a\u751f\u6210\u4e00\u4e2a app key \u5c06\u6b64key\u8bbe\u7f6e\u4e3aapp\/config\/app.php\u6587\u4ef6\u4e2d<\/p>\n<blockquote>\n<pre class=\"lang-php prettyprint prettyprinted\"><code><span class=\"str\">'key'<\/span> <span class=\"pun\">=&gt;<\/span><span class=\"pln\"> env<\/span><span class=\"pun\">(<\/span><span class=\"str\">'APP_KEY'<\/span><span class=\"pun\">,<\/span> <span class=\"str\">'base64:xxxxxxxxxxxxxxxxxxxx='<\/span><span class=\"pun\">)<\/span><\/code><\/pre>\n<\/blockquote>\n<p>\u5373\u53ef\u89e3\u51b3\u3002<\/p>\n<p>5.\u4f7f\u7528json\u672c\u5730\u5b89\u88c5box\u7684\u65f6\u5019\u5982\u5982\u679c\u51fa\u793a\u4ee5\u4e0b\u4fe1\u606f\uff1a<\/p>\n<p>Invalid file:\/\/hostname\/, expected localhost or 127.0.0.1 or none<\/p>\n<p>\u8bf4\u660ejson\u6587\u4ef6\u4e0d\u6b63\u786e\uff0c\u6b64\u65f6\u5e94\u8be5\u4f7f\u7528\u7edd\u5bf9\u8def\u5f84\u5982\uff1a<span style=\"color: #ff0000;\">vagrant box add \/d\/Homestead\/metadata.json\u00a0<\/span><\/p>\n<p>6.homestead \u9ed8\u8ba4\u4fe1\u606f\uff1a<\/p>\n<p>\u7528\u6237\u540d\uff1ahomestead<wbr \/><\/p>\n<div>\u5bc6\u7801\uff1asecret<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u7b80\u4ecb Laravel\u00a0\u4e3a\u5f00\u53d1\u8005\u63d0\u4f9b\u4e86\u4e00\u5957\u5b8c\u5584\u7684\u91cd\u91cf\u7ea7\u672c\u5730\u5f00\u53d1\u73af\u5883\u00a0\u2014\u2014 Laravel\u00a0Homestead\u3002  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[6,3,5],"tags":[7],"_links":{"self":[{"href":"https:\/\/china-abc.leohe.net.cn\/index.php?rest_route=\/wp\/v2\/posts\/33"}],"collection":[{"href":"https:\/\/china-abc.leohe.net.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/china-abc.leohe.net.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/china-abc.leohe.net.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/china-abc.leohe.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=33"}],"version-history":[{"count":11,"href":"https:\/\/china-abc.leohe.net.cn\/index.php?rest_route=\/wp\/v2\/posts\/33\/revisions"}],"predecessor-version":[{"id":289,"href":"https:\/\/china-abc.leohe.net.cn\/index.php?rest_route=\/wp\/v2\/posts\/33\/revisions\/289"}],"wp:attachment":[{"href":"https:\/\/china-abc.leohe.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=33"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/china-abc.leohe.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=33"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/china-abc.leohe.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=33"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}