我正在为我的虚拟机使用Laravel Homestead 2.0,并尝试使用YAML文件192.168.10.10中的默认IP地址来提供我的网站
我的/ etc / hosts文件如下所示:
# Homestead
192.168.10.10 beta.dev
192.168.10.10 deploy.dev
我的Homestead.yaml文件如下所示:
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Projects
to: /home/vagrant/Projects
sites:
- map: beta.dev
to: /home/vagrant/Projects/emorybeta/public
- map: deploy.dev
to: /home/vagrant/Projects/deploy/public
...
当我将域名链接到127.0.0.1时会出现这些站点,但是我必须将端口8000附加到URL的末尾(这不是什么大问题,我只想让指定的IP地址工作) 。
当我的域名指向192.168.10.10时,有谁知道为什么我无法连接到服务器?
<小时/> 更新:
当我ping deploy.dev时显示正确的IP地址,但我的浏览器仍然无法连接到服务器。我认为这可能与优胜美地的DNS问题有关。
答案 0 :(得分:5)
几个星期前我遇到了同样的问题。
第一: 确保您的文件夹路径正确,如果是,请仔细检查
下一步: 运行宅基地破坏和宅基地重新初始化虚拟机
如果这一切都不起作用: 检查您家中是否有任何可能位于192.168.10.10的设备。
如果这一切都没有用,你的问题可能很难解决,我建议为它制作一个github问题。
答案 1 :(得分:3)
嘿,我有同样的问题。我最终通过安装弃用的net-tools包来实现它:
sudo apt-get update
和
sudo apt-get install gnome-nettool
在此之后,
homestead destroy
和
homestead up
这使我可以使用&#39;域&#39;从本地计算机的浏览器访问我的虚拟机站点。我在hosts文件中指定了 - 在你的情况下beta.dev和deploy.dev - 没有引用localhost或端口8000.祝你好运,希望这会有所帮助。
答案 2 :(得分:3)
这是我为Windows 10计算机所做的解决方案:
确保向流浪者盒添加持久路线 在Administrator命令提示符下输入 route -p add 192.168.10.0 mask 255.255.255.0 192.168.10.1
并确保您能够 ping 192.168.10.10
同时检查为虚拟机主机专用适配器配置的IP地址是192.168.10.1,掩码为255.255.255.0
答案 3 :(得分:1)
我有同样的情况,但我做了一个改变。
我使用此IP 127.0.0.1
答案 4 :(得分:1)
我昨天在Homestead 5上遇到了类似的问题。事实证明我的问题是因为我运行了错误的Vagrantfile。
实例应该给出ip地址的响应:192.168.10.10
要解决我的问题,我所做的就是按照这些说明操作:http://laravel.com/docs/5.0/homestead
回顾一下:
在终端运行中:
vagrant box add laravel/homestead
然后
git clone https://github.com/laravel/homestead.git Homestead
然后
cd ./Homestead
并运行此命令FROM INSIDE the new&#34; Homestead&#34;夹
bash init.sh
然后将命令vagrant up
和vagrant provision
运行到应该在./Homestead
以下是我的系统上vagrant provision
命令的输出:
vagrant provision
==> default: Running provisioner: file...
==> default: Running provisioner: shell...
default: Running: inline script
==> default: Running provisioner: shell...
default: Running: inline script
==> default: Running provisioner: shell...
default: Running: /var/folders/q6/pgygb1ln4rg7_nvv0p8n1v300000gn/T/vagrant-shell20150714-94163-17xwlzk.sh
==> default: Running provisioner: shell...
default: Running: /var/folders/q6/pgygb1ln4rg7_nvv0p8n1v300000gn/T/vagrant-shell20150714-94163-rncs6l.sh
==> default: nginx stop/waiting
==> default: nginx start/running, process 1751
==> default: php5-fpm stop/waiting
==> default: php5-fpm start/running, process 1766
==> default: Running provisioner: shell...
default: Running: /var/folders/q6/pgygb1ln4rg7_nvv0p8n1v300000gn/T/vagrant-shell20150714-94163-e9qxwn.sh
==> default: Warning: Using a password on the command line interface can be insecure.
==> default: Warning: Using a password on the command line interface can be insecure.
==> default: Running provisioner: shell...
default: Running: /var/folders/q6/pgygb1ln4rg7_nvv0p8n1v300000gn/T/vagrant-shell20150714-94163-14rlz2c.sh
==> default: Running provisioner: shell...
default: Running: /var/folders/q6/pgygb1ln4rg7_nvv0p8n1v300000gn/T/vagrant-shell20150714-94163-16ethaq.sh
==> default: Running provisioner: shell...
default: Running: inline script
==> default: Running provisioner: shell...
default: Running: inline script
==> default: Running provisioner: shell...
default: Running: inline script
==> default: php5-fpm stop/waiting
==> default: php5-fpm start/running, process 1861
==> default: Running provisioner: shell...
default: Running: inline script
==> default: You are already using composer version 92faf1c7a83a73794fb914a990be435e1df373ca.
==> default: Running provisioner: shell...
default: Running: /var/folders/q6/pgygb1ln4rg7_nvv0p8n1v300000gn/T/vagrant-shell20150714-94163-btuuhg.sh
答案 5 :(得分:1)
在我的情况下,通过让vagrant up
安装来宾添加来解决问题:
~/Homestead (master|✔) $ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'laravel/homestead' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
[...]
GuestAdditions versions on your host (5.0.26) and guest (5.0.20) do not match.
[...]
Copy iso file /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
mount: /dev/loop0 is write-protected, mounting read-only
Installing Virtualbox Guest Additions 5.0.26 - guest version is 5.0.20
Verifying archive integrity... All good.
Uncompressing VirtualBox 5.0.26 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 5.0.20 of VirtualBox Guest Additions...
Removing existing VirtualBox DKMS kernel modules ...done.
Removing existing VirtualBox non-DKMS kernel modules ...done.
Copying additional installer modules ...
Installing additional modules ...
Removing existing VirtualBox DKMS kernel modules ...done.
Removing existing VirtualBox non-DKMS kernel modules ...done.
Building the VirtualBox Guest Additions kernel modules ...done.
Doing non-kernel setup of the Guest Additions ...done.
You should restart your guest to make sure the new modules are actually used
在此之后,我得到了一个具有预期IP地址的新界面:
enp0s8 Link encap:Ethernet HWaddr 08:00:27:e8:04:04
inet addr:192.168.8.10 Bcast:192.168.8.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fee8:404/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:996 (996.0 B)
答案 6 :(得分:1)
在ubuntu上安装网络工具为我修复了这个
$ sudo install net-tools
$ vagrant destroy
$ vagrant up
答案 7 :(得分:1)
我的Windows机器上出现了这个问题,事实证明我不小心颠倒了文件夹部分“map”和“to”。当我发现文件夹不在/ vagiation ssh会话中的〜/ code /下面时很明显它没有正常工作,但是仔细检查路径并没有产生任何结果。
以下是在Windows计算机上映射文件夹部分的正确方法:
folders:
- map: D:/Development/PHP/projects/
to: /home/vagrant/code
答案 8 :(得分:0)
我确实遇到了这个问题,结果发现nginx由于加载TLS证书时出错而无法启动。 vagrant up
命令没有报告nginx无法启动,或者任何端口无法绑定。
为了诊断这一点,我做了以下事情:
$ nmap homestead.app
Starting Nmap 7.01 ( https://nmap.org ) at 2017-10-03 16:16 NZDT
Nmap scan report for homestead.app (192.168.10.10)
Host is up (0.00077s latency).
Not shown: 995 closed ports
PORT STATE SERVICE
22/tcp open ssh
1025/tcp open NFS-or-IIS
3306/tcp open mysql
5432/tcp open postgresql
列表中没有端口80。让我们仔细检查端口80。
$ nmap homestead.app -p 80
...
Host is up (0.00020s latency).
PORT STATE SERVICE
80/tcp closed http
所以它肯定是封闭的。客人日志说什么? vagrant ssh
和......
$ systemctl status nginx.service
...
Active: failed (Result: exit-code) since Tue 2017-10-03 03:06:12 UTC; 1min 30s ago
...
homestead systemd[1]: Starting A high performance web server and a reverse proxy server...
homestead nginx[1250]: nginx: [emerg] PEM_read_bio_X509_AUX("/etc/nginx/ssl/homestead.app.crt") failed (SSL: error:0906D06C:PEM routines:PEM_read_bio:no start line:Expecting: TRUSTED CERTIFICA
homestead nginx[1250]: nginx: configuration file /etc/nginx/nginx.conf test failed
homestead systemd[1]: nginx.service: Control process exited, code=exited status=1
homestead systemd[1]: Failed to start A high performance web server and a reverse proxy server.
homestead systemd[1]: nginx.service: Unit entered failed state.
homestead systemd[1]: nginx.service: Failed with result 'exit-code'.
由于其配置错误,Nginx无法启动。 PEM_read_bio_X509_AUX
错误指向/etc/nginx/ssl/homestead.app.crt
文件。配置中使用的文件在哪里?
$ sudo vim /etc/nginx/sites-enabled/homestead.app
我评论了相关的行:
@@ -1,6 +1,6 @@
server {
listen 80;
- listen 443 ssl http2;
+# listen 443 ssl http2;
server_name homestead.app;
root "/home/vagrant/Code/public";
@@ -42,7 +42,7 @@ server {
deny all;
}
- ssl_certificate /etc/nginx/ssl/homestead.app.crt;
- ssl_certificate_key /etc/nginx/ssl/homestead.app.key;
+# ssl_certificate /etc/nginx/ssl/homestead.app.crt;
+# ssl_certificate_key /etc/nginx/ssl/homestead.app.key;
}
使用$ sudo service start nginx
启动nginx并再次从主机运行nmap
。
$ nmap homestead.app -p 80,443
...
PORT STATE SERVICE
80/tcp open http
443/tcp closed https
端口80已打开,现在可以从http://homestead.app访问。当然TLS不会起作用,但你应该能够通过生成新证书来修复它。我不确定证书首先无法加载的原因。
答案 9 :(得分:0)
唯一的原因是需要将主机名和IP放在主机文件中
C:\Windows\System32\drivers\etc
完成!
答案 10 :(得分:0)
使用这个 Vagrant 插件
vagrant plugin install vagrant-hostmanager
然后在您的 homestead 文件夹中运行它以再次配置
vagrant reload --provision
这样就不用每次添加新项目都更新host文件了!