php 如何在另一台本地计算机上访问我的 Wamp 服务器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22805093/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 16:16:43  来源:igfitidea点击:

How to access my Wamp Server on another Local Computer

phpapachehttpwamp

提问by user2707013

How can i access my local wamp server on another computer

如何在另一台计算机上访问我的本地 wamp 服务器

<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Allow from all
</Directory>

i use this code in http.config file but not work

我在 http.config 文件中使用此代码但不起作用

回答by Shankar Damodaran

You could simply use the Put Onlineoption of your WAMP Server and you can use this current system IP address and to directly access from the other computer.

您可以简单地使用Put OnlineWAMP 服务器的选项,您可以使用此当前系统 IP 地址并直接从其他计算机访问。

Do this on system tray

在系统托盘上执行此操作

enter image description here

在此处输入图片说明

Then, you could find your IP address using typing ipconfigor whatismyip.comwebsite and then access it on another system.

然后,您可以使用键入ipconfigwhatismyip.com网站找到您的 IP 地址,然后在另一个系统上访问它。

回答by SaidbakR

As you are able to access it from the local computer that run the server by http://localhostyou have two options to access it from your local area network LAN:

由于您可以从运行服务器的本地计算机访问它,因此http://localhost您有两个选项可以从局域网 LAN 访问它:

  1. Using the local IP of the computer for example: http://192.168.1.20
  2. Using the computer name for example: http://computer1/
  1. 例如使用计算机的本地 IP: http://192.168.1.20
  2. 例如使用计算机名称: http://computer1/

To know your current IP: Start -> in search field write cmdand hit enter to open the command line -> in the command line write: ipconfig you will get something like that:

要知道您当前的 IP:开始 -> 在搜索字段中写入cmd并按回车键打开命令行 -> 在命令行中写入: ipconfig 你会得到类似的东西:

enter image description here

在此处输入图片说明

Your computer IP address is the value of IPv4 Address.

您的计算机 IP 地址是 IPv4 地址的值。

To know your computer name just right click on the computer icon in the start menu then choose properties to get this screen shot:

要知道您的计算机名称,只需右键单击开始菜单中的计算机图标,然后选择属性即可获取此屏幕截图:

enter image description here

在此处输入图片说明

However, for computer name method you have to be sure that every computer in your LAN has a unique name.

但是,对于计算机名称方法,您必须确保 LAN 中的每台计算机都有唯一的名称。

Update

更新

There are some routers firmware supports local DNS on the router, so you have not need to edit the hosts files for every machinein the network. For example that I already have, dd-wrtfirmware on Linksys WRT54G:

有一些路由器固件支持路由器上的本地 DNS,因此您无需为网络中的每台机器编辑主机文件。例如,我已经有了Linksys WRT54G 上的dd-wrt固件:

enter image description here

在此处输入图片说明

回答by vinays84

Mine wasn't working before when I tried using my computer's IP in the URL. I found the reason to be the line in httpd.conf:

当我尝试在 URL 中使用计算机的 IP 时,我的无法正常工作。我发现原因是 httpd.conf 中的那一行:

ServerName localhost:80

服务器名称本地主机:80

which I updated to be

我更新为

ServerName {My comp's IP}:80

ServerName {My comp's IP}:80

回答by rightstuff

If you just need to access the wamp server from another LAN PC, as some of the answers have pointed out, you can use the LAN IPor Computer-Namein the URL, as long as VirtualHost's ServerNameor ServerAliasdirective contains that LAN IPor Computer-Name(so Apache can return the correct website).

如果您只需要从另一台 LAN PC 访问 wamp 服务器,正如某些答案所指出的那样,您可以在 URL 中使用LAN IPComputer-Name,只要 VirtualHost 的ServerNameServerAlias指令包含该LAN IPComputer-Name(以便 Apache 可以返回正确的网站) .

But if you need to use a domain-name, you'll have to edit every PC's Hosts fileand update it with the correct domain-name to LAN IP address resolve (and make sure that LAN IP is assigned each time to the correct device by the Router).

但是,如果您需要使用域名,则必须编辑每台 PCHosts file并使用正确的域名更新它以解析 LAN IP 地址(并确保 LAN IP 每次都被分配给正确的设备)路由器)。

Though there are much better solutions that will work for all devices (including Mac, Linux, mobile devices such as iPhones, Android phones, etc) if you have a WiFi Router that can either be flashed with one of the open firmwares or is already capable of DNS Masqueradingas outlined here: Accessing Websites on a Local Network (LAN) Web Server. "DNS Masquerading" (in this context) is basically using the WiFi Router's own "Hosts file" to do the domain-name to LAN IP resolve.

虽然有更好的解决方案适用于所有设备(包括 Mac、Linux、移动设备,如 iPhone、Android 手机等),如果您有一个 WiFi 路由器,可以使用其中一个开放固件刷新或已经能够的DNS Masquerading如下所示:访问本地网络(LAN)Web服务器上的网站。“DNS Masquerading”(在此上下文中)基本上是使用 WiFi 路由器自己的“主机文件”来进行域名到 LAN IP 的解析。

回答by Sumit

Step 1 : Press window button + r at same time which open run tool of window.
Step 2 : Write CMD, then press 'enter button'. Open CMD terminal.
Step 3 : Then write 'ipconfig' command
Step 4 : Then note your ipv4 Address : 192.168.x.x (From Wireless Lan Adapter Wi-Fi Hedaer) (This Ip address is needed by other computer in the place of localhost in URL)
Step 5 : Go to phpmyadmin.conf file of hosting system(Where wamp is installed...File path -> C:\wamp\alias\phpmyadmin.conf)
Step 6 : Replace this statement

步骤1:同时按下窗口按钮+ r,打开窗口的运行工具。
第 2 步:写入 CMD,然后按“输入按钮”。打开 CMD 终端。
第三步:然后写'ipconfig'命令
第四步:然后记下你的ipv4地址:192.168.xx(来自无线局域网适配器Wi-Fi Hedaer)(其他计算机需要这个IP地址来代替URL中的本地主机)
第五步: 转到宿主系统的phpmyadmin.conf文件(wamp安装位置...文件路径-> C:\wamp\alias\phpmyadmin.conf)
步骤6 : 替换此语句

     <ifDefine APACHE24>
      Require local
     </ifDefine>
     <ifDefine !APACHE24>
     Order Deny,Allow
     Deny from all
     Allow from localhost ::1 127.0.0.1
     </ifDefine>

    with

    Require local
    Require ip 192.168.0
    Note : (If your Ip is something like 192.147.x.x) then you write 'Require 192.147.0' instead of 'require 192.168.0')  

Step 7 : Restart your Wamp server
Step 8 : Enter the 192.x.x.x/phpmyadmin in the url bar of your own system from which you want to access the hosting wamp server
Step 9 : End.

第 7 步:重新启动 Wamp 服务器
第 8 步:在您要访问托管 wamp 服务器的系统的 url 栏中输入 192.xxx/phpmyadmin
第 9 步:结束。

回答by mnis.p

Hope this helps

希望这可以帮助

I couldn't connect event after doing all the above-mentioned steps. Then I uninstalled my current wampserver (3.0 version) and installed 2.5 version of wampserver. And it worked perfectly. You just need to click on 'Put Online' and you are done. Others can access your server by putting your ip address in the URL instead of localhost.

完成上述所有步骤后,我无法连接事件。然后我卸载了我当前的 wampserver(3.0 版本)并安装了 2.5 版本的 wampserver。它工作得很好。您只需要点击“在线”即可完成。其他人可以通过将您的 IP 地址放在 URL 而不是 localhost 来访问您的服务器。