使用 Homestead 来打造舒适的开发环境

2016-04-25 11:30:08 +08:00
 songjiaxin2008
因为不支持全文转载,所以直接贴出链接,希望可以帮助初学者,欢迎指正 :)
https://solarhell.com/post/2016/04/homestead
6941 次点击
所在节点    PHP
40 条回复
Magician
2016-04-25 11:32:15 +08:00
然后你会发现 打开你的 homestead.app 会出现 502
songjiaxin2008
2016-04-25 11:33:17 +08:00
@Magician 不会呀 0.0
Magician
2016-04-25 11:33:53 +08:00
楼主是个坑货 为什么不 讲一下那个 /etc/nginx/sites-enabled/ 那个 php5 要改成 php7.0
Magician
2016-04-25 11:34:25 +08:00
你这个是 php5.6 啊
songjiaxin2008
2016-04-25 11:35:49 +08:00
@Magician 不不不 不用配置的 默认就是 php7-fpm
songjiaxin2008
2016-04-25 11:36:34 +08:00
Magician
2016-04-25 11:40:46 +08:00
@songjiaxin2008 我装好后是

root@homestead:/etc/nginx/sites-enabled# cat homestead.app
server {
listen 80;
listen 443 ssl;
server_name homestead.app;
root "/home/vagrant/Projects/laravel/public";

index index.html index.htm index.php;

charset utf-8;

location / {
try_files $uri $uri/ /index.php?$query_string;
}

location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }

access_log off;
error_log /var/log/nginx/homestead.app-error.log error;

sendfile off;

client_max_body_size 100m;

location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
}

location ~ /\.ht {
deny all;
}

ssl_certificate /etc/nginx/ssl/homestead.app.crt;
ssl_certificate_key /etc/nginx/ssl/homestead.app.key;
}
songjiaxin2008
2016-04-25 11:42:26 +08:00
运行 vagrant box list 后,我的输出是 laravel/homestead (virtualbox, 0.4.4) 。或许你的 box 版本旧一点?
Magician
2016-04-25 11:43:19 +08:00
☁ manage vagrant box list
laravel/homestead (virtualbox, 0) 我的是这个呢
lissome
2016-04-25 12:05:06 +08:00
@Magician
这个应该不是用官方源添加的 box ,估计是旧版本的
songjiaxin2008
2016-04-25 12:17:52 +08:00
@Magician 你这个是手动下载添加的吗
isCyan
2016-04-25 12:28:02 +08:00
最新的 0.4.4
http://ws.penbeat.cn/laravel-homestead/0.4.4/virtualbox.box
这是七牛存储下载,我从我的美国 VPS 传到七牛的。
songjiaxin2008
2016-04-25 12:29:21 +08:00
@isCyan 感谢。我拜托过教育网的同学帮我下载过,确实能正确执行 vagrant box add xxx.box 但是 homestead 不认--
isCyan
2016-04-25 12:35:26 +08:00
@songjiaxin2008 那该怎么办?等它几十 KB 的速度?我这似乎也是不认,我以为是操作不对。
lujjjh
2016-04-25 12:51:43 +08:00
@songjiaxin2008
@isCyan

Homestead 对 box 的版本号有要求(>= 0.4.0 ),手动添加的 box 的版本号是 0 (下载下来的 box 文件不含 metadata ),所以会出问题。

解决方法就是创建一个 metadata.json 文件指明 box 的版本号,具体可以看这里:

http://stackoverflow.com/questions/34946837/box-laravel-homestead-could-not-be-found
Magician
2016-04-25 13:11:43 +08:00
@songjiaxin2008 我把箱子弄到 美国的 VPS 上的 弄到本地 加上的
Light3
2016-04-25 14:01:10 +08:00
想弄过 不过网速不行阿 你既然下过了 你不弄个网盘分享下。。= =
songjiaxin2008
2016-04-25 14:01:16 +08:00
@lujjjh 感谢 马上更新到文章里
pengbo37877
2016-04-25 18:30:49 +08:00
今天才被这个配置坑过
songjiaxin2008
2016-04-25 18:48:21 +08:00
@pengbo37877 对 所以写在博客备忘

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/274197

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX