You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Vagrant配置后无法访问localhost站点,寻求解决方法

Troubleshooting Vagrant Homestead: Can't Access crm.local Site

Hey there, let’s work through why your crm.local site isn’t loading even after setting up Vagrant Homestead. I’ve gone over your config and logs, so here are targeted checks and fixes to get things working:

1. Double-Check Your Hosts File Entry

Even though you mentioned configuring it, let’s confirm the Windows hosts file (located at C:\Windows\System32\drivers\etc\hosts) has the correct line—make sure you edited it with administrator privileges (otherwise changes won’t save):

192.168.10.10  crm.local

Ensure there are no extra spaces or typos, and save the file before proceeding.

2. Verify Network Connectivity to the VM

First, test if your host machine can reach the VM’s IP:

ping 192.168.10.10

If ping fails, check VirtualBox’s network settings for your Homestead VM:

  • Open VirtualBox, select your VM, go to Settings > Network
  • Confirm Adapter 1 is set to "NAT", and Adapter 2 is set to "Host-Only Adapter" with an IP range matching 192.168.10.x

3. Validate Your Homestead YAML Configuration

Your config looks solid, but let’s confirm a few critical details:

  • Folder Mapping: Ensure D:/Work/crm exists on your Windows machine, with no special characters (spaces, Chinese, etc.) in the path.
  • Site Root: Confirm the public directory exists inside the VM. Log into the VM and check:
    vagrant ssh
    ls -la /home/vagrant/code/crm/public
    
    You should see your app’s entry file (like index.php) here.

4. Check Nginx Configuration & Status

Homestead auto-generates Nginx configs, but sometimes they can have issues:

  1. Log into the VM and view your site’s Nginx config:
    cat /etc/nginx/sites-available/crm.local
    
    Confirm the root directive points to /home/vagrant/code/crm/public and there are no syntax errors.
  2. Restart Nginx to apply any fixes:
    sudo service nginx restart
    
  3. Verify Nginx is listening on port 80:
    sudo netstat -tulpn | grep nginx
    
    You should see a line showing 0.0.0.0:80 if it’s running correctly.

5. Rule Out Firewall Interference

Windows Firewall might block traffic to the VM. Try temporarily disabling it to see if crm.local loads. If it does, add an inbound rule to allow traffic to 192.168.10.10 on port 80.

6. Re-Provision the VM

If the initial setup had errors (common in log outputs), re-run the provisioning process to fix configs:

vagrant provision

Start with the network ping test first—it’s the quickest way to narrow down if the issue is network-related or app/config-related. Let me know which step uncovers the problem!

内容的提问来源于stack exchange,提问作者ToujouAya

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 09:23:42