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

WAMP虚拟主机配置后,如何让校内其他电脑访问PHP项目?

Hey there! Let's get your virtual host api.local accessible to other machines on your school network. The root problem here is that those other devices don't know how to map the api.local domain to your server's IP (204.XXX.XX.XX). Here are two reliable ways to fix this:

方法1:手动配置每台校内电脑的Hosts文件(适合少量设备)

If you only have a handful of computers that need access, this is straightforward:

  • On each Windows machine, open Notepad as Administrator, then navigate to C:\Windows\System32\drivers\etc\hosts and open it. For Mac/Linux, open a terminal and edit /etc/hosts with sudo nano /etc/hosts (you'll need admin/sudo privileges).
  • Add the exact same line you put on your server:
    204.XXX.XX.XX api.local #api
    
  • Save the file. On Windows, make sure you don't accidentally save it as a .txt file (select "All Files" in the save dialog).
  • Flush the DNS cache to apply changes immediately:
    • Windows: Open Command Prompt and run ipconfig /flushdns
    • Mac: Run sudo dscacheutil -flushcache in Terminal
    • Linux: Depending on your distro, run sudo systemd-resolve --flush-caches or sudo service nscd restart

After this, those machines should be able to reach your project at http://api.local.

方法2:配置校内DNS服务器(适合大量设备)

If you need many devices to access the virtual host, manually editing each Hosts file is a hassle. Instead:

  • Reach out to your school's network administrator and ask them to create a DNS record that maps api.local to your server's IP address (204.XXX.XX.XX).
  • Once the DNS record propagates (usually a few minutes), every computer on the school network can access your project by visiting http://api.local directly—no local Hosts edits required.
Quick Checks to Ensure Everything Works

Before testing, double these:

  • Make sure your server's firewall allows incoming connections on port 80 (the default HTTP port). If WAMP is running, this is often already enabled, but it's worth verifying.
  • Confirm that Apache's virtual hosts module is enabled on your server: Open httpd.conf in WAMP, and make sure the line Include conf/extra/httpd-vhosts.conf isn't commented out (no # at the start).

Once you've set up either method, test by pinging api.local from another school computer—you should see it return your server's IP. Then visit http://api.local in a browser, and your project should load without showing the WAMP default page.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.26 10:35:54